ORA-00906 missing left parenthesis error while creating table - oracle

Getting ORA-00906 error while creating table.
CREATE TABLE TEST.BSTXTEST(
PDBC_PFX CHAR NOT NULL,
BSBS_TYPE CHAR NOT NULL,
BSTX_SEQ_NO NUMBER NOT NULL,
BSTX_TEXT RAW NOT NULL,
BSTX_LOCK_TOKEN NUMBER NOT NULL,
ATXR_SOURCE_ID TIMESTAMP NOT NULL,
BSTXTEXT VARCHAR2(500) NOT NULL,
LENTEXT NUMBER NOT NULL
)

For a RAW datatype the size portion of the definition is mandatory.
e.g.
BSTX_TEXT RAW(2000) NOT NULL,

Related

Trying to create a table in mysql but i got a little trouble in my query

I am trying to create a table in mysql but i got a little trouble in my query
CREATE TABLE Mastertbl(
mid int(11) PRIMARY KEY AUTO_INCREMENT NOT NULL,
speciesName varchar(225) NOT NULL,
localName varchar(225) NOT NULL,
familyName varchar(225) NOT NULL,
pila int(11) NOT NULL,
areaNumber int(11) NOT NULL,
plotNumber int(11) NOT NULL,
Longitude double(225) NOT NULL,
Latitude double(225) NOT NULL
);
Error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') , Latitude double(225) )' at line 9 –
You should replace last two column names like this:
Longitude DOUBLE(225,2) NOT NULL,
Latitude DOUBLE(225,2) NOT NULL
Here, (M,D) means than values can be stored with up to M digits in total, of which D digits may be after the decimal point. For example, a column defined as DOUBLE(7,4) is displayed as -999.9999.

Missing right parenthesis error while creating a table with SQL code generated in Vertabelo

I want to create a Database for my school project. Some tables were created without an error, but when I wanted to create a more complex table, I had this error:
ORA-00907: missing right parenthesis
The code is following (the names of the table and attributes are in Romanian):
CREATE TABLE Curse (
id_cursa int NOT NULL,
id_tura int NULL,
moment_inceput_cursa timestamp NULL,
moment_sfarsit_cursa timestamp NULL,
adresa_initiala text NULL,
GPS_punct_start text NULL,
adresa_destinatie text NULL,
destinatie_GPS text NULL,
stare_cursa char NOT NULL DEFAULT 0,
modalitate_plata int NULL,
pret decimal NULL,
CONSTRAINT Curse_pk PRIMARY KEY (id_cursa)
);
The actual fault is the DEFAULT clause comes before the NOT NULL clause. So this the correct syntax:
stare_cursa char DEFAULT 0 NOT NULL
Beyond that you need to change the text datatype to something like varchar2(1000) or whatever length you need.
A few objections:
TEXT datatype is invalid; I used VARCHAR2(100); could be larger, or CLOB
correct order is DEFAULT 0 NOT NULL (not NOT NULL DEFAULT 0)
Although it is not an error, you don't have to specify that NULL values are allowed
SQL> CREATE TABLE curse(
2 id_cursa INT NOT NULL,
3 id_tura INT NULL,
4 moment_inceput_cursa TIMESTAMP NULL,
5 moment_sfarsit_cursa TIMESTAMP NULL,
6 adresa_initiala VARCHAR2(100)NULL,
7 gps_punct_start VARCHAR2(100)NULL,
8 adresa_destinatie VARCHAR2(100)NULL,
9 destinatie_gps VARCHAR2(100)NULL,
10 stare_cursa CHAR DEFAULT 0 NOT NULL,
11 modalitate_plata INT NULL,
12 pret DECIMAL,
13 CONSTRAINT curse_pk PRIMARY KEY(id_cursa)
14 );
Table created.
SQL>

ERROR: null value in column "id" violates not-null constraint

I just migrated my app from mysql to postgres but when I try to insert a record in a specific table I get violates not-null constraint error:
ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, 1, 1, null, null, null, 2016-03-09 09:24:12.841891, 2012-12-31 23:00:00, 2012-12-31 23:00:00, null, null, f, null, f, XYZAssignment, null, null, null, null).
********** Error **********
ERROR: null value in column "id" violates not-null constraint
SQL state: 23502
Detail: Failing row contains (null, 1, 1, null, null, null, 2016-03-09 09:24:12.841891, 2012-12-31 23:00:00, 2012-12-31 23:00:00, null, null, f, null, f, XYZAssignment, null, null, null, null).
When I try to create the record using factory_girl:
#assignment = FactoryGirl.create(:assignment)
It builds this sql query:
INSERT INTO assignments(
id, account_id, l_id, viewed_at, accepted_at, declined_at,
expires_at, created_at, updated_at, decline_reason, decline_reason_text,
promotion, c_checked_at, forwardable, type, f_promo,
c_check_successful, c_check_api_result, c_check_human_result)
VALUES (null, 1, 1, null, null, null, '2016-03-09 09:24:12.841891', '2012-12-31 23:00:00', '2012-12-31 23:00:00', null, null, 'f', null, 'f', 'XYZAssignment', null, null, null, null);
This is the assignment factory:
FactoryGirl.define do
factory :assignment do
expires_at 24.hours.from_now
account
lead
end
end
this is the table description:
CREATE TABLE assignments(
id serial NOT NULL, account_id integer NOT NULL, l_id integer NOT NULL, viewed_at timestamp without time zone, accepted_at timestamp without time zone, declined_at timestamp without time zone, expires_at timestamp without time zone, created_at timestamp without time zone, updated_at timestamp without time zone, decline_reason character varying(16), decline_reason_text character varying(256), promotion boolean NOT NULL DEFAULT false, c_checked_at timestamp without time zone, forwardable boolean DEFAULT true, type character varying(64), f_promo boolean, c_check_successful boolean, c_check_api_result character varying(32), c_check_human_result character varying(32), CONSTRAINT assignments_pkey PRIMARY KEY (id)
) WITH (
OIDS=FALSE
);
Looks its not able to auto increment the id, any idea?
You have to skip id in the INSERT operation:
INSERT INTO assignments(account_id, l_id, ...)
VALUES
(1, 1, ...)
The id will automatically get the next sequence number, since it is an auto-increment field.

SQL Error: ORA-00906: missing left parenthesis 00906. 00000 - "missing left parenthesis"

i have been trying to make a simple table and i it keeps coming up with SQL Error: ORA-00906: missing left parenthesis 00906. 00000 - "missing left parenthesis"
CREATE TABLE USER_TABLE(
USER_ID int NOT NULL,
Username varchar NULL,
Password varchar NULL,
Email varchar NOT NULL,
DOB Date NULL,
Address VARCHAR NOT NULL,
First_name VARCHAR NOT NULL,
Telephone_number int NULL,
PRIMARY KEY (User_ID));
You simply need to add the size of VARCHAR colums:
CREATE TABLE USER_TABLE
(
USER_ID INT NOT NULL,
Username VARCHAR(1) NULL,
Password VARCHAR(1) NULL,
Email VARCHAR(1) NOT NULL,
DOB DATE NULL,
Address VARCHAR(1) NOT NULL,
First_name VARCHAR(1) NOT NULL,
Telephone_number INT NULL,
PRIMARY KEY(User_ID)
);
Notice that VARCHAR is deprecated, better use VARCHAR2

sqlite error near '''' syntax error data input

I am using sqlite3 and trying to put data into my database.
CREATE TABLE CLUB(
cl_id INT PRIMARY KEY NOT NULL,
naam TEXT NOT NULL,
adres VARCHAR(200) NOT NULL,
dtm_opricht TEXT NOT NULL
);
CREATE TABLE STADION(
sta_id INT PRIMARY KEY NOT NULL,
cl_id INT REFERENCES CLUB(cl_id),
naam TEXT NOT NULL,
adres VARCHAR(200) NOT NULL,
capaciteit INT NOT NULL,
dtm_bouw TEXT NOT NULL
);
CREATE TABLE TECHNISCHDIRECTEUR(
td_id INT PRIMARY KEY NOT NULL,
cl_id INT REFERENCES CLUB(cl_id),
naam TEXT NOT NULL,
adres VARCHAR(200) NOT NULL,
salaris REAL NOT NULL,
nationaliteit TEXT NOT NULL,
geslacht TEXT NOT NULL,
dtm_geboorte TEXT NOT NULL
);
Everything was going fine with putting in data for the first 2 tables.
insert into CLUB values(101, 'Ajax', 'Amsterdamstraat 1', '05-01-1916');
insert into STADION values(201, 101, 'ArenA', 'Arenaweg 10', 50000, '05-03-1990');
However when I tried to put data into my 3rd table it gave me a syntax error near "301".
insert into TECHNISCHDIRECTEUR(301, 101, 'Michael Kinsbergen', 'Kalverstraat 18', 120000.13,
'Nederlands', 'Man', '03-09-1960');
What could it be?
You're missing the keyword values:
insert into TECHNISCHDIRECTEUR values(301,...

Resources