Generate create table script?

If I have a table called "customer" in my oracle database and I want to create the same table on another server. There are any way to generate Create table script to create this table?
Thank you for your help.
Regards,
Kevin

The documentation for the GET_DDL method in the DBMS_METADATA package is here
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_metad2.htm#1024701
Basically, you'll want something like
DECLARE
  l_clob CLOB;
BEGIN
  l_clob := dbms_metadata.get_ddl( 'TABLE', '<<table name>>');
  <<Do something with the DDL>>
END;Justin

Similar Messages

  • Error when generating create table script

    Hi,
    I am trying to generate create table script from an existing table. But I get the following error when doing so,
    ORA-20001: Rem Unable to generate DDL for ORA-06502: PL/SQL: numeric or value error ORA-31605: the following was returned from LpxXSLResetAllVars in routine kuxslResetParams: LPX-1: NULL pointer ORA-22921: length of input buffer is smaller than amount requested .
    Any suggestions on what could be wrong?
    Thanks.
    -B

    this is my bad, i should have updated this thread when we originally troubleshot this issue...
    that error you're getting on htmldb.oracle.com when you try to generate ddl for tables and such is a manifestation of a database bug (#3372908) that's recently been filed. checking the worklog for that bug suggests that those guys are still working out the issue. unfortunately, there's no current work-around on htmldb.oracle.com at the moment. if you want to generate ddl for your objects, you'd have to query the appropriate data dictionary views to get the info you need.
    ...i'll update the htmldb.oracle.com interface in a bit to prevent other users from hitting this issue. so you know, this is only an issue on db versions 9.2.0.3 and 9.2.0.4 running on some platforms and only (as far as i know) those using the AL32UTF8 characterset ...which does include our hosted site for now.
    hope this helps,
    raj

  • Generate "create table" stmt based on oracle8.1.7 dictionary

    I plan to create a DEMO database as a copy of our production database. The storage allocation of the tables should in the DEMO database be much smaller than in the production one. I assume, I have to write an sql-script to export the table definitions from the oracle dictionary (oracle 8.1.7) generating CREATE TABLE statements, which are written to a flat file.
    Do you maybe already have a working solution?

    you can create a schema, then a dblink to the db you want to copy, set up your default sizings to the size you want in your DEMO database and then
    select
    'create table '||table_name||' as select * from '||table_name||'@dblink where 1=0;'
    from user_tables
    save and run the output.
    That's the way I do it sometimes. Hope that's handy enough.

  • Is there a system table that stores the "create table" scripts

    Does a Oracle system table exist that contains the "create table" scripts for tables defined under a schema?
    I know I can build this with SQL by querying the user_tab_columns, but I was wondering whether the entire DML
    statement is already stored in some other system table. In the Quest Toad software you can simply go to the "Schema Brower", "Tables",
    then select the "Script" tab and it shows you the "create table" statement for the particular table that you are
    looking at. I'm wondering whether Toad behind the scenes is building this "create table" script via the user_tab_columns
    table or using another system table.
    Thank you in advance,
    Wes

    you can use the DBMS_METADATA.GET_DDL procedure to obtain the details regarding the ddl statement used to create the table.

  • Create table script by passing value from table

    I Have a procedure to check if the table exists, if yes drop and re-create else create table.
    CREATE OR REPLACE
    PROCEDURE test_proc authid current_user
    AS
    v_cnt NUMBER:=0;
    BEGIN
    SELECT COUNT(*)
    INTO v_cnt
    FROM all_tables
    WHERE table_name='T1'
    AND owner = 'WORKSPACE';
    IF v_cnt = 1 THEN
    EXECUTE immediate 'DROP TABLE WORKSPACE.T1';
    END IF;
    EXECUTE immediate 'CREATE TABLE WORKSPACE.T1
    ITM_NBR NUMBER ,
    LCT_NBR NUMBER
    SELECT COUNT(*)
    INTO v_cnt
    FROM all_tables
    WHERE table_name='T2'
    AND owner = 'WORKSPACE';
    IF v_cnt = 1 THEN
    EXECUTE immediate 'DROP TABLE WORKSPACE.T2';
    END IF;
    EXECUTE immediate 'CREATE TABLE WORKSPACE.T2
    LCT_NBR NUMBER(5, 0) NOT NULL ,
    PRY_CD NUMBER(5, 0) NOT NULL )';
    END;
    Requirement: Instead of passing the Owner,tablename & the create table scripts directlyin the query, it should be passed from a database table which will be in given format.
    TableName Query Owner
    T1 CREATE TABLE WORKSPACE.T1(ITM_NBR NUMBER, LCT_NBR NUMBER) WORKSPACE
    T2 CREATE TABLE WORKSPACE.T2(LCT_NBR NUMBER(5, 0) NOT NULL ,PRY_CD NUMBER(5, 0) NOT NULL) WORKSPACE

    user12276240 wrote:
    Excuse all. The database columns are yet to be finalized and every time changes come in we are currently dropping and re-creating the tables which leads in changing the script, hence we are going in for this approach.
    Moreover if i am going to have this script everytime i have to drop and re-create all the tables which can be elimated by this way.So why not have a SQL script as follows?
    drop table emp purge;
    create table emp(
    create index .. on emp( .. );
    ..It drops the existing table (if exists). It then creates the table with constraints and indexes. This script is now the master definition of the table. You can slap a change log header to it. Any changes that needs the table to be redefined and recreated are done via this script. Which means it is also checked into the source code repository as it is part of the code of that system/application.
    I would however remove the drop table from it in case some developer accidentally run it at the wrong time and trash the table.
    The bottom line is that DDL code is part and parcel of the installation, configuration and setup code - and that this is as important as the source code. This code also needs to be "formalised" in proper scripts, checked into SVN/CVS/etc, and used to bootstrap the system (or parts of it), as and when needed.

  • Privilege error while running Create Table Script inside Stored Procedure.

    Hello All,
    I have Oracle 10G server and SQL Developer Client,
    I have One User with Appropriate Rights, Login with that user from SQL Developer(client),
    Within my Procedure, Dynamic SQL script is like If I pass in a TABLE NAME as parameter, It Creates that table, but now problem is It throws an error for Privilege.
    Where as if I Execute Create table script outside the procedure(as Normal SQL), it executes Ok, but why it throws Privilege error within procedure ?
    Whether any extra Rights needed for this user to execute such Create Table Dynamic SQL?
    Please Help.
    Thanks,
    j@y

    Elic
    Thanks a lot dude...
    It works now,
    regards,
    j@y

  • Does anyone have sqlmenu50 create table script

    Hi,
    I need to create the sqlmenu50 database tables, but I seem to have lost the create table script for this.
    If anyone could please help me, I would be very grateful.
    Please email to [email protected]
    Many thanks
    Tony

    Ken , many, many thanks!
    I have actually broken down the import scripts to about 5 with about 200 entries each.
    I do find that about a dozen entires have errored with parameter has wrong length, the odd thing is all the TPIMPORT statements were created from the same Excell macro. ie., the transports were sequentially entered in an excell spreadsheet to ensure the correct sequence
    I then created a macro (as recommended from this thread) that created a large script for import
    I took this one step further and split this large file into smaller files/scripts of about 200 entries. 
    I have only run the first of 5 entries, and it is puzzling to me why I get the error 'parameter has wrong length'  the statements are cookie cutter statements, exactly the same. see error below
    E:\SAP Software\SAPPHYR Transport Log\TPImport Scripts>tp import ECDK901251 ECP client=200 U126 pf=d:\usr\sap\transcopy\bin\TP_DOMAIN_ECP.PFL
    This is tp version 372.04.40 (release 700, unicode enabled)
    ERROR: : parameter U126 has wrong length
    And a successfully statement result below
    E:\SAP Software\SAPPHYR Transport Log\TPImport Scripts>tp import ECDK900229 ECP client=200 U126 pf=d:\usr\sap\transcopy\bin\TP_DOMAIN_ECP.PFL
    This is tp version 372.04.40 (release 700, unicode enabled)
    This is R3trans.exe version 6.14 (release 700 - 28.07.08 - 15:52:00).
    unicode enabled version
    R3trans.exe finished (0004).
    tp finished with return code: 4
    meaning:
      A tool used by tp produced warnings
    You can observe the statements are identical starting at "tp import ECDKxxxxx ECP etc...
    any ideas why they would error?
    Regards,
    Maria

  • Generating Create Table As Statements

    Hi all - just after a bit of guidance on the following procedure:
    I have identified various columns that need their numeric values upgrading during a cutover. These are stored in the table FOR_UPGRADE which contains the columns TABLE_NAME, COLUMN_NAME, and FACTOR, (the factor is assigned depending on the object type being upgraded and is used in the calculation to create the new 'upgraded' value for that column).
    My problem is that I'm dealing with very large volumes, (TBs) of data and speed is a key factor here. As such I've been asked to upgrade these using create table statements rather than updates, (I believe this was down to being able to turn almost all the logging off during creates, but not updates). So the plan would be to use CTAS a select from the existing table, but apply the upgrades based on the factor during this, then rename these upgraded tables to match the original.
    Now I'd rather not manually create 200+ of these create table statements so I was hoping someone could advise as to how I could use a combination of FOR_UPGRADE table and ALL_TABLE_COLS to dynamically output all the statements required.
    Any help greatly appreciated.

    Write one script manually and use it as a template to create other scripts.
    The easiest way would be loop through FOR_UPGRADE table
    - as soon as the table name changes you know that next statement starts and previous end so you should do something different than for all other rows.
    - for each column generate its part of insert statement and oputput for example using dbms_output.
    Question remains would you really need user/all_tab_columns view because as I've understood you have already all column names in FOR_UPGRADE table.
    In case you need it (for example to check data type or whatever) you can simply join it to your base cursor.
    With one template already created and a bit of PL/SQL it should not be that hard :)
    Gints Plivna
    http://www.gplivna.eu

  • Generate Create Table Statements

    Hi, the problem is:
    My company want to migrate our SQL Server DB to Winwows Azure Server (currently we have our own domain and server), but Azure doesn't support the sentence 'Into' to create temporary tables, so we should replace all 'Into' sentences to corresponding 'Create
    Table' statements. Our system have up 1000 SP's with 'Into' sentences and many SP's have a lot of them.
    My question: is possible generate a 'Create Table' statement automatically, from a 'select into' sentence? i want to know if Management Studio or external tool have this feature o something similar.
    Sorry for my poor english but this is not my native language.
    Thanks!

    Try this one on for size. Run it against your existing DB. It'll give you create scripts you can use on your new DB.
    WITH allCols AS (
    SELECT s.name as sName, o.name AS oName, c.name AS cName, column_id,
    CASE WHEN st.name in ('float','bigint','tinyint','int','smallint','bit','datetime','money','date','datetime2','uniqueidentifier','sysname','geography','geometry') THEN st.name
    WHEN st.name in ('numeric','real') THEN st.name + '('+CAST(c.scale AS VARCHAR)+','+CAST(c.precision AS VARCHAR)+')'
    WHEN st.name in ('varbinary','varchar','binary','char','nchar','nvarchar') THEN st.name + '(' + CAST(ABS(c.max_length) AS VARCHAR) + ')'
    ELSE st.name + ' unknown '
    END + ' '+
    CASE WHEN c.is_identity = 1 THEN 'IDENTITY ' ELSE '' END +
    CASE WHEN c.is_nullable = 0 THEN 'NOT ' ELSE '' END + 'NULL' AS bText,
    f.name AS fileGroupName
    FROM sys.columns c
    INNER JOIN sys.objects o
    ON c.object_id = o.object_id
    AND o.type = 'U'
    INNER JOIN sys.systypes st
    ON c.user_type_id = st.xusertype
    INNER JOIN sys.schemas s
    ON o.schema_id = s.schema_id
    INNER JOIN sys.indexes i
    ON o.object_id = i.object_id
    AND i.index_id = (SELECT MIN(index_id) FROM sys.indexes WHERE object_ID = o.object_id)
    INNER JOIN sys.filegroups f
    ON i.data_space_id = f.data_space_id
    ), rCTE AS (
    SELECT sName, oName, cName, column_id, CAST(cName + ' ' + bText AS VARCHAR(MAX)) as bText, CAST(cName AS VARCHAR(MAX)) AS colList, fileGroupName
    FROM allCols
    WHERE column_id = 1
    UNION ALL
    SELECT r.sName, r.oName, r.cName, c.column_id, CAST(r.bText +', ' + c.cName + ' ' +c.bText AS VARCHAR(MAX)), CAST(r.colList+ ', ' +c.cName AS VARCHAR(MAX)), c.fileGroupName
    FROM allCols c
    INNER JOIN rCTE r
    ON c.oName = r.oName
    AND c.column_id - 1 = r.column_id
    ), allIndx AS (
    SELECT 'CREATE '+CASE WHEN is_unique = 1 THEN ' UNIQUE ' ELSE '' END+i.type_desc+' INDEX ['+i.name+'] ON ['+CAST(s.name COLLATE DATABASE_DEFAULT AS NVARCHAR )+'].['+o.name+'] (' as prefix,
    CASE WHEN is_included_column = 0 THEN '['+c.name+'] '+CASE WHEN ic.is_descending_key = 1 THEN 'DESC' ELSE 'ASC' END END As cols,
    CASE WHEN is_included_column = 1 THEN '['+c.name+']'END As incCols,
    ') WITH ('+
    CASE WHEN is_padded = 0 THEN 'PAD_INDEX = OFF,' ELSE 'PAD_INDEX = ON,' END+
    CASE WHEN ignore_dup_key = 0 THEN 'IGNORE_DUP_KEY = OFF,' ELSE 'IGNORE_DUP_KEY = ON,' END+
    CASE WHEN allow_row_locks = 0 THEN 'ALLOW_ROW_LOCKS = OFF,' ELSE 'ALLOW_ROW_LOCKS = ON,' END+
    CASE WHEN allow_page_locks = 0 THEN 'ALLOW_PAGE_LOCKS = OFF' ELSE 'ALLOW_PAGE_LOCKS = ON' END+
    ')' as suffix, index_column_id, key_ordinal, f.name as fileGroupName
    FROM sys.indexes i
    LEFT OUTER JOIN sys.index_columns ic
    ON i.object_id = ic.object_id
    AND i.index_id = ic.index_id
    LEFT OUTER JOIN sys.columns c
    ON ic.object_id = c.object_id
    AND ic.column_id = c.column_id
    INNER JOIN sys.objects o
    ON i.object_id = o.object_id
    AND o.type = 'U'
    AND i.type <> 0
    INNER JOIN sys.schemas s
    ON o.schema_id = s.schema_id
    INNER JOIN sys.filegroups f
    ON i.data_space_id = f.data_space_id
    ), idxrCTE AS (
    SELECT r.prefix, CAST(r.cols AS NVARCHAR(MAX)) AS cols, CAST(r.incCols AS NVARCHAR(MAX)) AS incCols, r.suffix, r.index_column_id, r.key_ordinal, fileGroupName
    FROM allIndx r
    WHERE index_column_id = 1
    UNION ALL
    SELECT o.prefix, COALESCE(r.cols,'') + COALESCE(', '+o.cols,''), COALESCE(r.incCols+', ','') + o.incCols, o.suffix, o.index_column_id, o.key_ordinal, o.fileGroupName
    FROM allIndx o
    INNER JOIN idxrCTE r
    ON o.prefix = r.prefix
    AND o.index_column_id - 1 = r.index_column_id
    SELECT 'CREATE TABLE ['+sName+'].[' + oName + '] ('+bText+') ON [' + fileGroupName +']'
    FROM rCTE r
    WHERE column_id = (SELECT MAX(column_id) FROM rCTE WHERE r.oName = oName)
    UNION ALL
    SELECT prefix + cols + CASE WHEN incCols IS NOT NULL THEN ') INCLUDE ('+incCols ELSE '' END + suffix+' ON [' + fileGroupName +']'
    FROM idxrCTE x
    WHERE index_column_id = (SELECT MAX(index_column_id) FROM idxrCTE WHERE x.prefix = prefix)
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • SQL Authentication provider - create tables script

    Hi all!
    I'd like to use SQL Authentication provider for my Web application. I cannot find the script for creating users/roles tables used by the provider.
    Can you suggest me a link where I can download them ?
    Thanks
    Frank

    Hi Frank,
    Configure SQL authenticator:
    Start Oracle XE DB and open SQL propmt to execute below commands:
    CREATE TABLE USERS (
    U_NAME VARCHAR(200) NOT NULL,
    U_PASSWORD VARCHAR(50) NOT NULL,
    U_DESCRIPTION VARCHAR(1000))
    ALTER TABLE USERS
    ADD CONSTRAINT PK_USERS
    PRIMARY KEY (U_NAME)
    CREATE TABLE GROUPS (
    G_NAME VARCHAR(200) NOT NULL,
    G_DESCRIPTION VARCHAR(1000) NULL)
    ALTER TABLE GROUPS
    ADD CONSTRAINT PK_GROUPS
    PRIMARY KEY (G_NAME)
    CREATE TABLE GROUPMEMBERS (
    G_NAME VARCHAR(200) NOT NULL,
    G_MEMBER VARCHAR(200) NOT NULL)
    ALTER TABLE GROUPMEMBERS
    ADD CONSTRAINT PK_GROUPMEMS
    PRIMARY KEY (
    G_NAME,
    G_MEMBER
    ALTER TABLE GROUPMEMBERS
    ADD CONSTRAINT FK1_GROUPMEMBERS
    FOREIGN KEY ( G_NAME )
    REFERENCES GROUPS (G_NAME)
    ON DELETE CASCADE
    Generally customers can add users directly in DB with help below commands:
    insert into USERS (U_NAME,U_PASSWORD,U_DESCRIPTION) values('system','weblogic','admin user');
    insert into GROUPS (G_NAME,G_DESCRIPTION) values('Administrators','Administrators');
    insert into GROUPMEMBERS (G_NAME,G_MEMBER) values('Administrators','system');
    But in this case password is not encrypted so either you can add users via console or via WLST script to store them in encrypted form.
    We had executed above commands just to verify user which is directly stored in DB gets authenticated properly or not from SQL authenticator configured as below
    Now start weblogic admin server and access console to create Data source by navigating Services ->JDBC -> Data sources
    Create Data source named SqlDS
    JNDI: SqlDS
    DB type: Oracle
    DB Driver: Oracle Thin XA driver
    DB name: XE
    DB host: <hostname>
    Port: 1521
    DB user: <username>
    DB password: <password>
    Keep rest of the configuration same and click on test Configuration. If its successful click on next and target it to "AdminServer"
    Click on Finish and activate chnages
    Now navigate to Security Realms -> myrealm -> Providers
    Click on New and provide Name as SqlAuthenticator and select Type as SQLAuthenticator
    Now click on newly created provider and make Control Flag as "Sufficient"
    Navigate to provider specific page:
    1. Check on Plaintext Passwords Enabled.
    2. Provide Data source Name: SqlDS
    Keep rest of the parameters as it is and Save this configuration. It will ask you to restart Admin server.
    Now again navigate Security Realms -> myrealm -> Users & groups
    Check user which was created directly in DB is listed in table with SqlAuthenticator, Once its listed go ahead and add users as below
    B. Cretae users using Admin console:
    Login to Admin console
    Navigate to Security Realms -> myrealm -> Users & groups
    Click on users tab and try creating new user
    User name: <user name>
    Select Authentication provider: SqlAuthenticator
    User Password: <password>
    Once user is created check DB table, this user musted be added with encypted password
    C. Create multiple users using WLST script:
    Navigave to $DOMAIN_HOME/bin folder and execute setDomainEnv file as below:
    Unix: . ./setDomainEnv.sh (Do not forget to put two dots before / )
    Windows: setDomainEnv.cmd
    Now change below script as per your environment and execute as suggested in step 3:
    connect('weblogic','weblogic123','t3://localhost:7001')
    edit()
    startEdit(-1,-1,'false')
    serverConfig()
    cd('/SecurityConfiguration/base_domain/Realms/myrealm/AuthenticationProviders')
    ls()
    cd('SqlAuthenticator')
    cmo.createUser('vaishali','weblogic123','SQLuser')
    cmo.createUser('pavashe','weblogic123','SQLuser')
    edit()
    stopEdit('y')
    NOTE: Change user,password and ADMIN_URL in 1st line.
    Replace domain name " base_domain' with your domain name in line no: 5
    Chnage SQL authenticator name in line no: 6 as per your authenticator name
    Next lines create users. You need to add however users you need to create programatically.
    Syntax : cmo.createUser('user_name','user_password','user_description')
    Now save these commands in a file with extention .py and execute as below:
    # java weblogic.WLST create_user.py
    If your script fails the try executing each command separately. For this start WLST session as below:
    # java weblogic.WLST
    Now execute commands specified in above script. You will be able to debug if anything went wrong while executing script.
    Regards,
    Kal

  • Generate create index script

    Kindly some one tell me how to get a script which contains CREATE INDEX COMMAND for all the indexes avillable for different schema in a database as I have to
    create it in other location. kindly help me.

    hi, for example
    declare
    s varchar2(4000);
    begin
    for cur in (select dbms_metadata.get_ddl(object_type=>'INDEX',name=>cur.index_name) from dba_indexes where owner='TEST') loop
    s := dbms_metadata.get_ddl(object_type=>'INDEX',name=>cur.index_name);
    end loop;
    dbms_output.put_line('S= '||s);
    end;
    or
    select dbms_metadata.get_ddl('INDEX',index_name) from dba_indexes where owner='test'

  • Issue with Generate Create Script in new ODT 11.1.0.5.10 beta

    So I'm trying to determine if there's an issue with the Generate Create Script option in the new ODT 11.1.0.5.10 beta (when you right click on a table in Server Explorer).
    The SQL create script that it generates lacks the slash between lines. For example I generated the create script for my User table and this is what was generated:
    CREATE TABLE "DEV"."SYSTEM_USER_TB" ("RID" NUMBER(10,0),"USER_NAME" VARCHAR2(256 CHAR),"APPLICATION_RID" NUMBER(10,0),"FIRST_NAME" VARCHAR2(256 CHAR),"LAST_NAME" VARCHAR2(256 CHAR),"PW" VARCHAR2(128 CHAR),"PW_FORMAT" NUMBER,"PW_SALT" VARCHAR2(128 CHAR),"LAST_ACTIVITY_DT" DATE,"EXPIRATION_DT" DATE,"EMAIL" VARCHAR2(256 CHAR),"PW_QUESTION" VARCHAR2(256 CHAR),"PW_ANSWER" VARCHAR2(256 CHAR),"APPROVED_FLG" NUMBER(1,0),"LOCKED_OUT_FLG" NUMBER(1,0),"LAST_LOGIN_DT" DATE,"LAST_PW_CHANGED_DT" DATE,"LAST_LOCKOUT_DT" DATE,"FAILED_PW_ATTEMPT_CNT" NUMBER(6,0),"FAILED_PW_ATTEMPT_WINSTART" DATE,"FAILED_PW_ANSW_ATTEMPT_CNT" NUMBER(8,0),"FAILED_PW_ANSW_ATTEMPT_WINSTRT" DATE,"CREATED_BY_RID" NUMBER(10,0),"CREATED_DT" DATE,"MODIFIED_BY_RID" NUMBER(10,0),"MODIFIED_DT" DATE) TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 131072 MAXEXTENTS 2147483645 MINEXTENTS 1 )
    CREATE UNIQUE INDEX "DEV"."XPKSTAFF" ON "DEV"."SYSTEM_USER_TB" ("RID" ) TABLESPACE "USERS"
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033033" PRIMARY KEY ("RID") USING INDEX "DEV"."XPKSTAFF" ENABLE VALIDATE )
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033032" CHECK ("RID" IS NOT NULL) ENABLE VALIDATE )
    CREATE TRIGGER "DEV"."SYSTEM_USER_TRG1"
    BEFORE
    INSERT
    ON "DEV"."SYSTEM_USER_TB"
    FOR EACH ROW
    begin
         select SYSTEM_USER_SEQ.nextval into :new.RID from dual;
    end;
    In my new Oracle Database Project, if I right click on the script and select "Run" or "Run On", the script fails saying:
    Connected.
    CREATE UNIQUE INDEX "DEV"."XPKSTAFF" ON "DEV"."SYSTEM_USER_TB" ("RID" ) TABLESPACE "USERS"
    ERROR at line 2:
    ORA-00922: missing or invalid option
    If I then add, a slash between lines, the script runs successfully and creates the table/trigger and whatever else just fine. For example, I changed the above generated code to look as follows:
    CREATE TABLE "DEV"."SYSTEM_USER_TB" ("RID" NUMBER(10,0),"USER_NAME" VARCHAR2(256 CHAR),"APPLICATION_RID" NUMBER(10,0),"FIRST_NAME" VARCHAR2(256 CHAR),"LAST_NAME" VARCHAR2(256 CHAR),"PW" VARCHAR2(128 CHAR),"PW_FORMAT" NUMBER,"PW_SALT" VARCHAR2(128 CHAR),"LAST_ACTIVITY_DT" DATE,"EXPIRATION_DT" DATE,"EMAIL" VARCHAR2(256 CHAR),"PW_QUESTION" VARCHAR2(256 CHAR),"PW_ANSWER" VARCHAR2(256 CHAR),"APPROVED_FLG" NUMBER(1,0),"LOCKED_OUT_FLG" NUMBER(1,0),"LAST_LOGIN_DT" DATE,"LAST_PW_CHANGED_DT" DATE,"LAST_LOCKOUT_DT" DATE,"FAILED_PW_ATTEMPT_CNT" NUMBER(6,0),"FAILED_PW_ATTEMPT_WINSTART" DATE,"FAILED_PW_ANSW_ATTEMPT_CNT" NUMBER(8,0),"FAILED_PW_ANSW_ATTEMPT_WINSTRT" DATE,"CREATED_BY_RID" NUMBER(10,0),"CREATED_DT" DATE,"MODIFIED_BY_RID" NUMBER(10,0),"MODIFIED_DT" DATE) TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 131072 MAXEXTENTS 2147483645 MINEXTENTS 1 )
    CREATE UNIQUE INDEX "DEV"."XPKSTAFF" ON "DEV"."SYSTEM_USER_TB" ("RID" ) TABLESPACE "USERS"
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033033" PRIMARY KEY ("RID") USING INDEX "DEV"."XPKSTAFF" ENABLE VALIDATE )
    ALTER TABLE "DEV"."SYSTEM_USER_TB" ADD ( CONSTRAINT "SYS_C0033032" CHECK ("RID" IS NOT NULL) ENABLE VALIDATE )
    CREATE TRIGGER "DEV"."SYSTEM_USER_TRG1"
    BEFORE
    INSERT
    ON "DEV"."SYSTEM_USER_TB"
    FOR EACH ROW
    begin
         select SYSTEM_USER_SEQ.nextval into :new.RID from dual;
    end;
    So, does anyone know if this is a bug? Could I be missing an option to add in the slashes to the generated code? Is there an option to not require the slashes? Could there be another way to execute these scripts?
    Seriously, I think I'm having deja vu from the last release of the Dev Tools: Generate Create Script creates scripts that won't run: ORA-00922: missing..
    ...except this time the documentation says I should be able to use the "Run" and "Run On" commands in the Oracle Database Project (see page 8): http://www.oracle.com/technology/tech/dotnet/pdf/ODT11_whatsnew.pdf
    null

    There are 2 issues in the generated script :
    1. Missing semicolons at the end of the create stmts
    2. Missing slashes
    Both of these fixes will be available in the ODT 11.1 release.

  • How to see DDL script(create table) from view

    i want to view create table script(DDL command)
    can u suggest me any view for that.

    Hi
    There's no view where the DDL statement is directly available. It must be reconstructed from many views...
    If you use 9i the simpler way to do that is with DBMS_METADATA. Below and example....
    SQL&gt; SET LONG 1000000
    SQL&gt; SELECT dbms_metadata.get_ddl('TABLE','EMP') FROM dual;
    DBMS_METADATA.GET_DDL('TABLE','EMP')
    CREATE TABLE "SCOTT"."EMP"
    ( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
    "ENAME" VARCHAR2(10),
    "JOB" VARCHAR2(9),
    "MGR" NUMBER(4,0),
    "HIREDATE" DATE,
    "SAL" NUMBER(7,2),
    "COMM" NUMBER(7,2),
    "DEPTNO" NUMBER(2,0),
    CONSTRAINT "EMP_PK" PRIMARY KEY ("EMPNO")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS" ENABLE,
    CONSTRAINT "EMP_DEPT_FK" FOREIGN KEY ("DEPTNO")
    REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"
    Chris

  • SQL Developer  Create Table Statement to ERD Visio Diagram

    I have the following Create table statement from SQL Developer and I am trying to generate an ERD Diagram using 2003 Visio. I was wondering what I need to do to convert the Create Table to an ERD Diagram Using Visio. Thanks
    CREATE TABLE “TT_TEAM”.”HR_REVOKED_SECURITY_ORGS”
    “ID” NUMBER NOT NULL ENABLE,
    “ACAT_CODE” VARCHAR2(6 BYTE) NOT NULL ENABLE,
    “APPR_SEQ_NO” NUMBER(3,0) NOT NULL ENABLE,
    “USER_ID” VARCHAR2(30 BYTE) NOT NULL ENABLE,
    “ACTION_IND” VARCHAR2(1 BYTE) NOT NULL ENABLE,
    “ACTIVITY_DATE” DATE NOT NULL ENABLE,
    “COAS_CODE” VARCHAR2(1 BYTE),
    “ORGN_CODE” VARCHAR2(6 BYTE),
    “POSN” VARCHAR2(6 BYTE) NOT NULL ENABLE,
    “MANDATORY_APPR_IND” VARCHAR2(1 BYTE),
    “APPR_POSN” VARCHAR2(6 BYTE),
    “ORGN_MANAGER” VARCHAR2(6 BYTE) NOT NULL ENABLE;

    I'm pretty Visio is a non-Oracle product.
    In the mean-time, you can easily import a DDL script file and create a relational model/diagram using SQL Developer. Use the Import feature and point to your CREATE TABLE script(s)

  • Database Diff - Generates Create commands only (does not list alter command

    Hi I'm using very latest version of the SQL developer. I was using Database Diff feature and found issue that when there is differences in table (say a addition column exits in one of the database), generate script generates "Create table..."statement. I would rather expect alter table because table exist on both databases but a column was different.
    If I take that script try to create table on the database that has difference, then I would have to lose all data (of course there are alternatives), which is not very efficient script then.
    any ideas if there is an option to show alter commnads?
    thanks.

    The usage of the Diff wizard is not crystal clear.
    If your connections are as user X, but the objects are owned by user Y, they won't be picked up in the target connection. Although you are allowed to pick objects from different users (user Y) on the source side, the comparison seems to be with user X on the target side. For it to work properly, you need to define connections ob both sides as user Y. I haven't really tested this thoroughly because I don't have the change management pack licensed anywhere.

Maybe you are looking for