Getting invalid datatype error while creating table regestration - oracle10g

CREATE TABLE regestration
(
email VARCHAR(30),
PASSWORD VARCHAR(15),
f_name VARCHAR(25),
contactno VARCHAR(10),
address VARCHAR(30),
city VARCHAR(15),
country VARCHAR(20),
gen VARCHAR(15),
ac_type VARCHAR(20),
e-bank VARCHAR(15),
status VARCHAR(10)
);

The object naming rules include:
Nonquoted identifiers can contain only alphanumeric characters from
your database character set and the underscore (_), dollar sign ($),
and pound sign (#). Database links can also contain periods (.) and
"at" signs (#). Oracle strongly discourages you from using $ and # in
nonquoted identifiers.
Quoted identifiers can contain any characters and punctuations marks
as well as spaces. However, neither quoted nor nonquoted identifiers
can contain double quotation marks or the null character (\0).
You are trying to create a nonquoted identifier as e-bank. That is not a valid name; the hyphen/dash punctuation mark is not allowed in a nonquoted identifier. While you could quote it it will only cause you problems later, anyone who has to refer to the column will struggle (and possibly curse you for making their lives harder), and based on the other column names you probably meant to use an underscore anyway:
CREATE TABLE regestration
(
email VARCHAR(30),
PASSWORD VARCHAR(15),
f_name VARCHAR(25),
contactno VARCHAR(10),
address VARCHAR(30),
city VARCHAR(15),
country VARCHAR(20),
gen VARCHAR(15),
ac_type VARCHAR(20),
e_bank VARCHAR(15),
status VARCHAR(10)
);
Table REGESTRATION created.

Related

Creating my first table- Syntax error at or near ();

First day of postgreSQL- sorry if this is too basic, but couldn't find the answer on here.
So basically I'm following a video tutorial, and have written exactly the same lines as tutorial, yet I get above mentioned syntax error when trying to clear:
CREATE TABLE Actors(
actor_id SERIAL PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30)NOT NULL,
gender CHAR(1),
date_of_birth DATE,
);
I know there is probably a super simple solution but I cant seem to find out what after nearly 2 hours- help
No need to apologize!
For clean queries, always recommended to put a [SPACE] after datatypes (for example: VARCHAR(30)[SPACE]NOT NULL ) and always be sure to remove your COMMAS right before your closing parenthesis.
CREATE TABLE Actors(
actor_id SERIAL PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30) NOT NULL,
gender CHAR(1),
date_of_birth DATE
)
Remove the , after date_of_birth and perhaps add a space before NOT NULL
CREATE TABLE Actors (
actor_id SERIAL PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30) NOT NULL,
gender CHAR(1),
date_of_birth DATE
);

Troubleshooting ERROR: extra data after last expected column

I'm trying to add CSV data to my Postgres table:
CREATE TABLE IF NOT EXISTS Review (
review_id BIGSERIAL NOT NULL,
product_id_Metadata INTEGER,
date DATE,
summary VARCHAR(255),
body VARCHAR(500),
rating INTEGER,
recommend BOOLEAN,
reported BOOLEAN
reviewer_name VARCHAR(50),
reviewer_email VARCHAR(50),
response VARCHAR(255),
helpfulness INTEGER,
FOREIGN KEY product_id(product_id) REFERENCES Metadata(product_id)
);
Running the CMD:
COPY review (product_id_Metadata, summary, body, rating, recommend, reported, reviewer_name, reviewer_email, response, helpfulness) FROM '/Users/luke82601/Desktop/csv/reviews.csv' DELIMITER ',' CSV HEADER;
The CSV file has the same number of columns as my Postgres table, so I'm not sure why this error occurs

PostgreSQL displaying integer inserted without commas, with commas (formatted like currency or similar)

SQL Server guy, new to PostgreSQL. Created the below table, performed the below insert, then ran a SELECT to see the data, yet the row shows the integer formatted with columns to break up the integer. Is this just a formatting style in the HeidiSQL utility I'm using, or is the data actually being stored as x,xxx,xxx,xxx rather than xxxxxxxxxx.
Table:
CREATE TABLE customer (
business_partner_id INTEGER PRIMARY KEY,
first_name VARCHAR(100),
last_name VARCHAR(100),
organisation_name VARCHAR(200),
date_of_bith DATE,
gender VARCHAR(50),
customer_type VARCHAR(50),
store_joined VARCHAR(10),
store_joined_date DATE,
created_date_time TIMESTAMP,
updated_date_time TIMESTAMP);
Insert:
-- Insert a customer
INSERT INTO customer VALUES
(1029884766,'James','Matson','Unknown','1980-02-17','M','Standard','303',CURRENT_DATE,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)
Query results:

Why is the format of the sql files affecting if they can run or not in PG?

I have placed a file in my docker-entrypoint-initdb.d/ directory. Here is what is in the file:
CREATE TABLE user_test (
user_id INTEGER,
name VARCHAR(100),
email VARCHAR(128),
active_flg BOOLEAN,
type VARCHAR(20),
CONSTRAINT pk_user PRIMARY KEY (user_id)
);
The error I am getting is psql:/docker-entrypoint-initdb.d/0001-initial-database-design.sql:8: ERROR: syntax error at or near "CREATE".
What am I missing in being able to run a file? How do I change this file to work?
USER is a reserved keyword in Postgres, see the documentation. In general, you should avoid naming your tables and columns using reserved SQL keywords. If you really wanted to proceed as is, then place user into double quotes:
CREATE TABLE "user" (
user_id INTEGER,
name VARCHAR(100),
email VARCHAR(128),
active_flg BOOLEAN,
type VARCHAR(20),
CONSTRAINT pk_user PRIMARY KEY (user_id)
);
But, keep in mind that if you choose to name your table user, then you will forever have to escape it with double quotes.

Oracle "ORA-00904: : invalid identifier" = Error in Bold SQL Commands on Oracle 10 G [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
create table Coordinator(
cor_id char(6) primary key,
cor_name varchar(10) not null,
contact_no char(12),
address varchar(50));
create table Student(
student_id char(6) primary key,
name varchar(10) not null,
department char(20),
grade char(6),
percentage smallint,
contact_no char(12),
address varchar(50));
create table Criteria(
crt_id char(6) primary key,
min_cutoff smallint);
create table Company(
cmp_id char(6) primary key,
crt_id char(6),
cmp_name varchar(25) not null,
grade char(6),
package int,
contact_no char(12),
address varchar(50),
foreign key (crt_id) references Criteria(crt_id));
**create table Coordinate_with(
cor_id char(6),
cmp_id char(6),
date char(10),
shift varchar(10),
primary key (cor_id,cmp_id),
foreign key (cor_id) references Coordinator(cor_id),
foreign key (cmp_id) references Company(cmp_id));**
create table Placed_in(
cmp_id char(6),
student_id char(6),
primary key (cmp_id,student_id),
foreign key (comp_id) references Company,
foreign key (student_id) references Student);
create table Criteria_Branch(
crt_id char(6),
branch_allowed varchar(20),
primary key (crt_id, branch_allowed),
foreign key (crt_id) references Criteria(crt_id);
shift is a reserved word. You need to name that column differently.
You should never, ever store dates as char or varchar columns!
Additionally the name date is also not a very good choice. Apart from being a reserved word as well, it doesn't document what the column is about. A "start date", an "end date", a "join date", a "due date", ...
Using char datatype is almost always not going to do what you want due to its values being padded to the defined length. I'm pretty sure you want varchar (or varchar2) instead.
If your IDs (cor_id, ...) are really numbers, you should define those columns as number (or integer).
So the table in question should at least look like this:
create table Coordinate_with
(
cor_id char(6),
cmp_id char(6),
start_date date, -- or whatever name describes better what kind of date that is.
shifted varchar(10), -- the name is just a suggestion, use what best describes this column
primary key (cor_id,cmp_id),
foreign key (cor_id) references Coordinator(cor_id),
foreign key (cmp_id) references Company(cmp_id)
);