I'm trying to create a simple table but it's giving me an error says:
Error starting at line : 1 in command -
CREATE TABLE dj_abonent
(
nr_klienti int NOT NULL,
emer_klienti varchar2(10),
sasia_cel int
CONSTRAINT dj_klientID PRIMARY KEY(nr_klienti)
)
Error at Command Line : 6 Column : 35
Error report -
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Error starting at line : 1 in command -
CREATE TABLE dj_abonent
(
nr_klienti int NOT NULL,
emer_klienti varchar2(10),
sasia_cel int,
CONSTRAINT dj_klientID PRIMARY KEY(nr_klienti)
)
Error at Command Line : 1 Column : 14
Error report -
SQL Error: ORA-00955: name is already used by an existing object
00955. 00000 - "name is already used by an existing object"
*Cause:
*Action:
You are missing a comma:
CREATE TABLE dj_abonent
(
nr_klienti int NOT NULL,
emer_klienti varchar2(10),
sasia_cel int, -- this one right here
CONSTRAINT dj_klientID PRIMARY KEY(nr_klienti)
)
Your have the second error because you use dj_klientID as name for both of the constraints. They have to be unique.
Try renaming one of the two constraints and also your second query will be fixed.
Related
I'm trying to create partitioned on oracle table but getting ORA-00922 error.
Error starting at line : 1 in command -
CREATE TABLE "RATE_REQUEST_BKP_PARIATIONED"
(
"RATE_REQUEST_ID" NUMBER(10,0),
"PRODUCT_CUSTOMER_ID" NUMBER(10,0),
"DESTINATION_ID" NUMBER(10,0),
"CREATED_DT" DATE,
"CREATED_BY" NUMBER(10,0),
"MODIFIED_DT" DATE,
"MODIFIED_BY" NUMBER(10,0),
"RATE_STATUS_ID" NUMBER(10,0)
)
PARTITION BY RANGE
(
CREATED_DT
)
INTERVAL
(
NUMTOYMINTERVAL(1, 'MONTH')
)
(
PARTITION p0 VALUES LESS THAN (TO_DATE('1-3-2017', 'DD-MM-YYYY')),
PARTITION p1 VALUES LESS THAN (TO_DATE('1-4-2017', 'DD-MM-YYYY')),
PARTITION p2 VALUES LESS THAN (TO_DATE('1-5-2017', 'DD-MM-YYYY'))
)
Error report -
SQL Error: ORA-00922: missing or invalid option
00922. 00000 - "missing or invalid option"
*Cause:
*Action:
Table "RATE_REQUEST_BKP_PARIATIONED" dropped.
Commit complete.
Please help me finding out the issue with query.
May this Help you
If an invalid option is specified while defining a storage clause or column, ORA-00922 will be thrown. ORA-00922 mentions that to specify that the column is not able to contain any NULL values, the valid option while specifying a column is NOT NULL, and solely constraints can follow the datatype.
Also notable to ORA-00922, which can also cause this error to be thrown, is that specifying a maximum length on LOG or DATE datatype.
Correcting ORA-00992 consists of correcting the syntax in your specifications, minding to take out the erroneous option or length specification from the storage of column specification
Answer got from this link
http://www.dba-oracle.com/t_ora_00922_missing_or_invalid_option.htm
I have the sample CUSTOMERS table.
I exported the values from table as INSERT script.
I took one row, modified the value from PK and re-executed the insert.
Insert into oe.customers (CUSTOMER_ID,
CUST_FIRST_NAME,
CUST_LAST_NAME,
CUST_ADDRESS,
PHONE_NUMBERS,
NLS_LANGUAGE,
NLS_TERRITORY,
CREDIT_LIMIT,
CUST_EMAIL,
ACCOUNT_MGR_ID,
CUST_GEO_LOCATION,
DATE_OF_BIRTH,
MARITAL_STATUS,
GENDER,
INCOME_LEVEL,
CREDIT_CARDS)
values ( oe.customer_seq.nextval,
'Donald',
'Hunter',
OE.CUST_ADDRESS_TYP('5122 Sinclair Ln','21206','Baltimore','MD','US'),
OE.PHONE_LIST_TYP('+1 410 123 4795'),
'us',
'AMERICA',
2600,
'Donald.Hunter#CHACHALACA.EXAMPLE.COM',
145,
MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(-76.545732,39.322775,NULL),NULL,NULL),
to_date('20-JAN-60','DD-MON-RR'),
'married',
'M',
'G: 130,000 - 149,999',
OE.TYP_CR_CARD_NST(OE.TYP_CR_CARD('Visa',100000000000011)));
and I have the following error message:
Error at Command Line : 32 Column : 29 Error report - SQL Error:
ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
which refers to line:
OE.TYP_CR_CARD_NST(OE.TYP_CR_CARD('Visa',100000000000011)));
The definition of types are:
create or replace type typ_cr_card as object
( card_type VARCHAR2(25)
, card_num NUMBER);
create or replace type typ_cr_card_nst as table of typ_cr_card;
Can someone tell me, please, what is wrong with this insert line as it is the one provided by SQL DEVELOPER?
NOTE: Also, I tried to use a procedure which inserts values in this table and the error refers to TYP_CR_CARD_NST datatype.
When I create a table like this:
CREATE TABLE "Movie_list" (
"Movie_id" NUMBER(8) NOT NULL,
"Company" VARCHAR2(30) NOT NULL,
"Rating" DECIMAL(5,1) NOT NULL,
"Storyline" VARCHAR2(255) NOT NULL,
"Award_id" VARCHAR2(255) NOT NULL,
"Cast_and_Crew_id" VARCHAR2(255) NOT NULL,
CONSTRAINT Movie_pk PRIMARY KEY (Movie_id),
);
An Error report is producded -
SQL Error: ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
I don't see any problem, please help.
Errors:
Table and column names enclosed in quotes
NUMBER and VARCHAR2 are not a valid mysql type
A , is at the end of the constraint specification which is invalid
The main problem is in your primary key specification, which reads
CONSTRAINT Movie_pk PRIMARY KEY (Movie_id),
However, in the table definition you've quoted the name of this field, i.e.
"Movie_id" NUMBER(8) NOT NULL,
Because the name of this field (and in fact every field in the table, and the name of the table itself) is quoted the names are stored by the database as the specified mixed-case name, and because Oracle converts all unquoted identifiers to UPPER_CASE it means that EVERY TIME YOU REFER TO THIS TABLE AND ITS FIELDS, YOU MUST QUOTE THEM. So your constraint should be
CONSTRAINT Movie_pk PRIMARY KEY ("Movie_id")
My recommendation is that you dispense with the quoted "Mixed_case" names. Get rid of the quotes and Oracle will store the names in UPPER_CASE internally. You can still refer to them using Mixed_Case if you want to but you won't have to "Quote_Them_Every_Time_You_Use_Them", which gets really old and reads very badly. I suggest you change you table definition to
CREATE TABLE Movie_list (
Movie_id NUMBER(8) NOT NULL,
Company VARCHAR2(30) NOT NULL,
Rating DECIMAL(5,1) NOT NULL,
Storyline VARCHAR2(255) NOT NULL,
Award_id VARCHAR2(255) NOT NULL,
Cast_and_Crew_id VARCHAR2(255) NOT NULL,
CONSTRAINT Movie_pk PRIMARY KEY (Movie_id)
);
Best of luck.
This also happened to me when I was trying to use some sort of keyword as a column name.
I tried to create a table with a column name of "uid" (without "" evidently), and i was getting this error:
ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
Changing the column's name solved the error.
I am working on an Advantage Database Server 8.1 and I have created a new table. I want to add a unique constraint for the combination of 2 columns.
I tried
ALTER TABLE TableName
ADD CONSTRAINT ConstraintName
UNIQUE (ColumnName1, ColumnName2)
but I get the error
"ERROR IN SCRIPT: poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2115; [Extended Systems][Advantage SQL Engine]Expected lexical element not found: You are missing the column names. -- Location of error in the SQL
statement is: 33 (line: 2 column: 5)"
Ok the solution I found is:
CREATE UNIQUE INDEX ConstraintName ON TableName (ColumnName1, ColumnName2);
I am getting the below error while trying to select * from ext_poc
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "identifier": expecting one of: "binary_double, binary_float, comma, char, date, defaultif, decimal, double, float, integer, (, no, nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned, varrawc, varchar, varraw, varcharc, zoned"
KUP-01008: the bad identifier was: varchar2
KUP-01007: at line 4 column 10
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.
Below is the ddl for the table:
CREATE TABLE "JDASTG"."EXT_POC"
( "ID" varchar2(100),
"NAME" varchar2(100),
"DOB" varchar2(100)
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "SCPO_EXT_DATA"
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(id varchar2(100),
name varchar2(100),
dob varchar2(100)
)
)
LOCATION
( 'xyz_aldrin.csv'
)
);
PS:
This error however doesn't occur if the varchar2(100) is changed to char(100):
MISSING FIELD VALUES ARE NULL
(id char(100),
name char(100),
dob char(100)
)
It is important to distinguish between oracle internal data types specified on the table, and the external data types specified in the access parameters for the external table (control file for sqlldr). Read the manual again with that in mind. It should become clear. CHAR is allowed in SQL loader whereas VARCHAR2 is not