Create multiple tables using single .sql script file

85,895

You need to separate the create table scripts with / or end the command with ;, Try like this,

CREATE TABLE ACCOUNT_DETAILS_TB ( CUSTOMER_ID VARCHAR2(20) NOT NULL , ACCOUNT_ID VARCHAR2(20) NOT NULL )
/
CREATE TABLE ADDRESS_DETAILS_TB ( ACCOUNT_ID VARCHAR2(20) NOT NULL , ADDRESS_ID VARCHAR2(20) NOT NULL )
/

OR

CREATE TABLE ACCOUNT_DETAILS_TB ( CUSTOMER_ID VARCHAR2(20) NOT NULL , ACCOUNT_ID VARCHAR2(20) NOT NULL );

CREATE TABLE ADDRESS_DETAILS_TB ( ACCOUNT_ID VARCHAR2(20) NOT NULL , ADDRESS_ID VARCHAR2(20) NOT NULL );
Share:
85,895
vashishth
Author by

vashishth

I am a JEE application developer, where i mostly work on middleware technologies such as, JMS, Mule ESB, Fuse ESB. My GitHub handle - https://github.com/rvashishth

Updated on July 12, 2022

Comments

  • vashishth
    vashishth almost 2 years

    I have created multiple table in oracle xe 11g database and i have saved the script for each table in different .sql file. But i need to create all tables at once using single .sql file. I tried to run below script but it is creating only once table at once.

    CREATE TABLE ACCOUNT_DETAILS_TB 
    (
      CUSTOMER_ID VARCHAR2(20) NOT NULL 
    , ACCOUNT_ID VARCHAR2(20) NOT NULL 
    );
    
    CREATE TABLE ADDRESS_DETAILS_TB 
    (
      ACCOUNT_ID VARCHAR2(20) NOT NULL 
    , ADDRESS_ID VARCHAR2(20) NOT NULL 
    );
    
  • a_horse_with_no_name
    a_horse_with_no_name over 10 years
    And how does a screenshot for a SQL Server tool answer a question that is clearly marked as Oracle?
  • Admin
    Admin over 5 years
    It would be really nice and consistent with the other statements if sql could interpret create table (...), table2 (...), table3 (...) as it interprets the VALUES clause of INSERT statement, for instance.