Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating Tables with a Script

784563Jul 12 2010 — edited Jul 13 2010
I am trying to create tables using a script, but it seems like consecutive statments in the script will not execute --- can anyone tell me what syntax I need to use?

****************************************************************************
Here is my script - I am using SQL-Plus:

CREATE TABLE regions
( region_id NUMBER
CONSTRAINT region_id_nn NOT NULL
, region_name VARCHAR2(25)
)

CREATE TABLE countries
( country_id CHAR(2)
CONSTRAINT country_id_nn NOT NULL
, country_name VARCHAR2(40)
, region_id NUMBER
, CONSTRAINT country_c_id_pk
PRIMARY KEY (country_id)
)
ORGANIZATION INDEX

Here is what I key in:

SQL> get c:\oracle\test.txt

Here is the error that comes out:

1 CREATE TABLE regions
2 ( region_id NUMBER
3 CONSTRAINT region_id_nn NOT NULL
4 , region_name VARCHAR2(25)
5 )
6 CREATE TABLE countries
7 ( country_id CHAR(2)
8 CONSTRAINT country_id_nn NOT NULL
9 , country_name VARCHAR2(40)
10 , region_id NUMBER
11 , CONSTRAINT country_c_id_pk
12 PRIMARY KEY (country_id)
13 )
14* ORGANIZATION INDEX
15 run;
CREATE TABLE countries
*
ERROR at line 6:
ORA-00922: missing or invalid option
****************************************************************************
If I trim down the script - to just 1 create table command, no semi-colons, it works:

Script:

CREATE TABLE regions
( region_id NUMBER
CONSTRAINT region_id_nn NOT NULL
, region_name VARCHAR2(25)
)

Key in:
SQL> get c:\oracle\test.txt
1 CREATE TABLE regions
2 ( region_id NUMBER
3 CONSTRAINT region_id_nn NOT NULL
4 , region_name VARCHAR2(25)
5* )
SQL> run;

Recieve:

1 CREATE TABLE regions
2 ( region_id NUMBER
3 CONSTRAINT region_id_nn NOT NULL
4 , region_name VARCHAR2(25)
5* )

Table created.
****************************************************************************
adding a semicolon between the create table statements doesn't solve this issue - does anyone have any ideas?

Thanks,

-Tom
This post has been answered by ZahKar on Jul 12 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2010
Added on Jul 12 2010
11 comments
2,394 views