EXEC SQL & CREATE TABLE

Hi,
I am trying to create table using EXEC SQL. But, the table that I had created using EXEC SQL is not shown in data dictionary. I can not see that table from SE11. If I run the same program again, then gives error about there is already a table that I want to create. So, How can see it? Is seeing that table possible?
EXEC SQL.
CREATE TABLE ZCOPYTABLE(
NAME CHAR(15) NOT NULL,
SURNAME CHAR(15) NOT NULL,
TEL CHAR(10) NOT NULL,
PRIMARY KEY (NAME, SURNAME)
ENDEXEC.

Hello Huseyin,
I don't think you can use the Native SQL statements for DDL (data definition language) statements in SQL.
The reason is that the Native SQL statements by-pass the SAP Application Server and are executed directly at the Database Server. You will find more information on the SAP Online Help Documentation site.
Since the ABAP Dictionary is very much an application, it fails to recognize the tables which were not created through it.
The DDL statements in Native SQL are only for advanced database adminstration tasks.
Hope this helps.
Regards,
Anand Mandalika.

Similar Messages

  • JDBB SQL create table PreparedStatement

    Hi
    How can I use preparedSatement to create a variable table?
    PreparedStatement ps=con.prepareStatement("what is the SQL Code for a table named [?]");
    ps.setString(1, tableName);
    ResultSet r = ps.executeQuery();

    I think it'd be the usual SQL:
    CREATE TABLE X
       FOO INTEGER,
       BAR VARCHAR2(80),
       etc.
    )The types would have to be correct for your RDB.
    I don't think it'd be a query, so it wouldn't return a ResultSet. I believe it's like an UPDATE, so you'd call executeUpdate on the statement. - MOD

  • SQL Create Table

    Hi guys
    im getting an exception with create table. Im sure im doing it with the right syntax but maybe you guys could help me.
    This is the exception:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in CREATE TABLE statement.
            at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
            at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
            at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
            at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
            at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)this is the code
    Statement stmt1 = conn.createStatement();
    stmt1.executeQuery("CREATE TABLE " + t_UID + "Bank (Type int(5), amount int(10))");Ne help is appreciated thanks guys

    Statement stmt1 = conn.createStatement();
    stmt1.executeQuery("CREATE TABLE " + t_UID + "Bank
    (Type int(5), amount int(10))");Print out the String you are trying to execute - I would guess you are missing a space or a "." between t_UID and "Bank".

  • PL\SQL Create table

    Hi can anyone help with the below i have 3 variables that I select into then I want to use these variables in the create table but the CREATE table part errors saying it was expecting some thing else ???
    declare
    month_1 date;
    month_2 date;
    month_3 date;
    begin
    select cast('15-'||to_char(add_months(trunc(sysdate),-2),'Mon')||to_char(add_months(trunc(sysdate),-2),'-YYYY')as date) into month_1 from dual ;
    select cast('15-'||to_char(add_months(trunc(sysdate),-1),'Mon')||to_char(add_months(trunc(sysdate),-1),'-YYYY')as date) into month_2 from dual ;
    select cast('15-'||to_char(trunc(sysdate),'Mon')||to_char(trunc(sysdate),'-YYYY')as date) into month_3 from dual ;
    CREATE TABLE TEMP_TABLE
    (ACCOUNT_NO      NUMBER(11),
    ACCOUNT_NAME VARCHAR(152bytes),
    month_1          NUMBER,
    month_2 NUMBER,
    month_3          NUMBER
    END;

    There were some issues with your code. You can't (without the use of double quotes) start a column name with a number or include hyphens. Also, VARCHAR(152bytes) should be VARCHAR2(152 byte) or even VARCHAR2(152).
    This may help;
    SQL> declare
       month_1 varchar2(11);
       month_2 varchar2(11);
       month_3 varchar2(11);
    begin
       select to_char(add_months(trunc(sysdate,'mm')+14,-2),'MON_DD_YYYY') into month_1 from dual;
       select to_char(add_months(trunc(sysdate,'mm')+14,-1),'MON_DD_YYYY') into month_2 from dual;
       select to_char(trunc(sysdate,'mm')+14,'MON_DD_YYYY') into month_3 from dual;
       execute immediate 'create table temp_table( '
                                 || 'ACCOUNT_NO NUMBER(11), '
                                 || 'ACCOUNT_NAME VARCHAR(152), '
                                 || month_1 || ' NUMBER, '
                                 || month_2 || ' NUMBER, '
                                 || month_3 || ' NUMBER) ';
    end;
    PL/SQL procedure successfully completed.
    SQL> desc temp_table
    TABLE temp_table
    Name                                      Null?    Type                       
    ACCOUNT_NO                                         NUMBER(11)                 
    ACCOUNT_NAME                                       VARCHAR2(152)              
    DEC_15_2006                                        NUMBER                     
    JAN_15_2007                                        NUMBER                     
    FEB_15_2007                                        NUMBER

  • In training, PL/SQL create table and insert question. (easy for some of you

    I have an empty table called messages. The task is this:
    a)Insert the numbers 1 to 10, excluding 6 and 8.
    b)Commit before the end of the block.
    I did this:
    SET SERVEROUTPUT ON
    SET VERIFY OFF
    BEGIN
    INSERT INTO messages VALUES (1,2,3,4,5,6,7,9,10);
    END;
    Which fails at messages. The table is there, I checked and it's empty. ORA-06550:

    Hello,
    c1 is not a valid column name I posted as an example , you need to provide valid column name of your table.
    Either post your table structure or replace c1, c2, c3 ... with valid column name from your table.
    INSERT INTO MESSAGES (c1, c2, c3, c4, c5, c9, c10)
    or
    insert into messages (your table column name1 , column name2 ,....) values (....);Regards
    Edited by: OrionNet on Feb 21, 2009 9:51 PM

  • Randomly generate an ID for SQL Create Table command

    Hi,
    I need help to randomly generate an integer, which i can use as a primary key for the ID of a table field. I have no idea how to do this so that it generates a different number every single time.
    Right now it just increments the ID by 1. Maybe, is there a way to get the last ID value of the table field and then increment starting from that one? thanks

    Your analysis is flawed! One of my main reasons for
    doing this is to reduce the load on the db server. I
    don't have to go to the db to get an id every time I
    need one. Every now and again (usually less than one
    in a 2000) I have to repeat an insert operation.
    You already stated that this was the reason, so I used that as part of my assessment. With most, perhaps all databases, the ability to increment a key is done as part of the insert operation. It requires no additional 'trip' to the database to get the ID. There is so much wrong with your idea, I hardly know where to start. I wouldn't be so firm except you stated that you do this all the time. Even using it once is very questionable I wouldn't want this idea to profilerate to other peoples systems without comment.
    You also said:
    On one project I was having to place usage transaction records
    into a database with each one needing an ID. I started using your
    technique but it was taking almost as much time as the insert of
    each transaction into the database.I agree, and I think dcminter agreed that there are less expensive practices then max(fld)+1 which are in fact using the vendor specific capabilities. However, if this was taking as long as your insert, there was probably something else wrong. For example, if the field you are getting the max value for isn't indexed, or isn't the first field in a contatenated index (an index of multiple fields), then some databases (there are exceptions like redbrick) will require either a full table scan, an index scan or an ackward index lookup to give back the max value. It shouldn't be that way, but it is and you have undestand how your database is resolving max() in order to make the best decisions.
    I stand by analysis and I would suggest that rather then use your method "all the time" that you save it for that unusual situation where nothing else will work for you.

  • Parameter into a CREATE TABLE with PRO*C

    Hi,
    I use PRO*C and i've a problem with a CREATE TABLE request.
    My program asks for the name of my variable mission, quite simply that I get with a scanf.
    So, I want to create a table where one of the fields of the table must be the same that the char of the name of the mission. But, the function doesn't do anything… But when i write the name of the variable there is no problem.
    Thanks for your answers and sorry for my english.
    Code :
         void creer_table1(char nom_mission[50])
    EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR TABLE[50];
    EXEC SQL END DECLARE SECTION;
    strcpy(TABLE.arr,nom_mission);
    TABLE.len =strlen(TABLE.arr);
    EXEC SQL CREATE TABLE mission.msn_test AS
    SELECT * FROM mission.msn_mission
    WHERE missionname=:TABLE;
    printf("Table MSN_TEST creee dans le schema MISSION\n");
    PS: My IDE is code::blocks
    Bonjour à tous,
    J'utilise Pro*C et j'ai un problème avec une requête CREATE TABLE. Je m'explique:
    Mon programme demande quel est le nom de ma variable mission, que je récupère tout bêtement avec un scanf.
    Je veux alors créer une table où un de mes champs doit avoir comme valeur le char qui est le nom de la mission. Mais voila, la fonction qui doit créer la table ne la crée pas... Alors que quand je rentre cette variable en dur, cela fonctionne très bien. J'aimerais avoir un petit coup de pouce de votre part si c'est possible. Si ça se trouve j'essaie de faire quelque chose pas forcément possible.
    Voila mon code de la fonction servant à lire la table:
    Voila le code servant créer la fonction:
    Code :
    void creer_table1(char nom_mission[50])
    EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR TABLE[50];
    EXEC SQL END DECLARE SECTION;
    strcpy(TABLE.arr,nom_mission);
    TABLE.len =strlen(TABLE.arr);
    EXEC SQL CREATE TABLE mission.msn_test AS
    SELECT * FROM mission.msn_mission
    WHERE missionname=:TABLE;
    printf("Table MSN_TEST creee dans le schema MISSION\n");
    Merci d'avance pour votre aide.
    PS:Je travaille sous code blocks et avec oracle
    Laurent Barale
    Edited by: 899981 on 30 nov. 2011 08:16

    Hi,
    I hadn't got errors.
    Bit, i solved my problem using dynamic sql.
    exemple:
    void function(char name[50]){
    EXEC SQL BEGIN DECLARE SECTION;
    char *varsql;
    EXEC SQL END DECLARE SECTION;
    char toto[150]="CREATE TABLE test AS SELECT * FROM tutu WHERE employe='";
    varsql=strcat(toto,name);
    strcat(varsql,"'");
    EXEC SQL EXECUTE IMMEDIATE :varsql;
    I hope that could help somebody.
    Bye and thank you for your answer.
    Edited by: 899981 on 20 déc. 2011 05:28

  • Create table cause TT6003

    Hi Chirs
    Recently we found this error in JAVA below, as per my understanding, a create operation is holding X lock on table SYS.TABLES for at least 30s, this cause another query operation requering IS lock on table SYS.TABLES is waiting for more than 30s and lead to TT6003 at last.
    But I still have some problems about this error:
    1. Create table operation normally should be very shot, how it hold the X lock on table SYS.TABLES for serveral seconds.
    2. The error indicates query table operation also need locks on table SYS.TABLES. I understand create table needs lock on SYS.TABLES before updating information on it, but query table also need lock (IS lock) on SYS.TABLES? Query table no need to require lock  as I thought.
    3. How can we create table correctly to avoid TT6003?
    Thank you in advance!
    java error:
    2014-10-23 16:41:25.920 [ajp-bio-10002-exec-2] INFO  webstore - 1414053654227_4289_300174投放异常
    org.springside.modules.service.ServiceException: 异常
    ### Error querying database.  Cause: java.sql.SQLException: [TimesTen][TimesTen 11.2.2.6.0 ODBC Driver][TimesTen]TT6003: Lock request denied because of time-out
    Details: LockWait[30000ms] Tran 37.108 (pid 16637) wants IS lock on table SYS.TABLES. But tran 19.1078876 (pid 14894) has it in X (request was X). Holder SQL (create table PLATWD_SZTQ_TQXC
                      zctfrwid VARCHAR2(20) not null,
                      lasttime DATE not
    null...) -- file "lockMgr.c", lineno 9410, procedure "sbLockENQandCheckTbl()"
    ### The error may exist in file [/opt/tompolicy/webapps/ROOT/WEB-INF/classes/mybatis/BestPlatPolicyMapperTimesten.xml]
    ### The error may involve cn.vetech.platpolicy.dao.PlatpolicyMybatisDao.getBestByPlatWd
    ### The error occurred while executing a query
    ### SQL: select * from (    select * from PLATWD_SZHZHK_TAOB where zctfrwid=? and zt=1  and code > ?  order by code    ) where 15000 >= rownum
    ### Cause: java.sql.SQLException: [TimesTen][TimesTen 11.2.2.6.0 ODBC Driver][TimesTen]TT6003: Lock request denied because of time-out
    Regards
    Li

    Hi Chris
    Here is the sys.odbc.ini for your reference.
    [timesten@policies info]$ cat sys.odbc.ini
    [ODBC Data Sources]
    TT_1122=TimesTen 11.2.2 Driver
    [TT_1122]
    Driver=/opt/TimesTen/tt1122/lib/libtten.so
    DataStore=/opt/TimesTen/tt1122/info/TT_1122
    DatabaseCharacterSet=ZHS16GBK
    ConnectionCharacterSet=ZHS16GBK
    PermSize=60000
    TempSize=8000
    OracleNetServiceName=vedb
    Connections=300
    LogFileSize=128
    LogBufMB=128
    LockWait=30
    [ODBC Data Sources]
    tt_1122_c=TimesTen 11.2.2 Client Driver
    [tt_1122_c]
    TTC_SERVER=tt_1122_c_s
    TTC_SERVER_DSN=tt_1122
    As to the full text of the CREATE TABLE, I haven't get it from the programmer, will update to you latter.
    We sometimes create/truncate table,seldom drop table.
    Thanks
    Li

  • Can create view, but cannot create table / materialized view: Xpath is null

    Hi all,
    We recently moved some XML documents into the database in an XMLType column and want to query the data. I've been writing some queries and turning them into materialized views. I got to one query, and something really strange is happening. My query returns the expected results, but I am getting an error when I try to create a materialized view out of it. Even stranger, I can create a view out of it, and I can manually insert its data into an existing table, but I cannot create a materialized view out of it and I cannot create a table out of it. Here is a brief summary, please let me know if anyone has suggestions.
    Issuing the following commands fails in SQLDeveloper
    -- Creating a materialized view out of the query fails:
    create materialized view element REFRESH COMPLETE ON DEMAND as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    -- Creating a table out of the query with the following shortcut fails:
    create table element as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    Issuing the following commands in SQLDeveloper works fine:
    -- Creating a view out of the query works:
    create or replace view element as [query];
    -- Creating a blank table from the query and then inserting data works:
    create table element as select * from [query] where 1 = 2;
    insert into element select * from [query];
    Here is a simplified version of the query...
    I have changed the names around, and cut the query down so maybe it will be a little easier to understand. I did confirm that this query is also having the same symptoms described above. Since I changed the names, executing the query returns no results. However creating a materialized view out of the query still fails with the 'Xpath is null' error.
    create materialized view element REFRESH COMPLETE ON DEMAND as
    select
    m.resource_id,
    xml.*
    from metadata_sources m,
    xmltable(
    'for $i in /metadata/app//*[(self::elem1 or self::elem2) and (parent::form or parent::subform)]
    let $formName := if($i/parent::subform) then $i/../../@name else $i/../@name
    let $subformName := if($i/parent::subform) then $i/../@name else ""
    return <data
    appId="{$i/ancestor::app[1]/idField}"
    formName="{$formName}"
    subformName="{$subformName}"
    elemName="{$i/@name}"></data>' passing m.xml_content
    columns
    app_id NUMBER path '@appId',
    form_name VARCHAR2(50 char) path '@formName',
    subform_name VARCHAR2(50 char) path '@subformName',
    elem_name VARCHAR2(50 char) path '@elemName'
    ) xml;
    Edited by: user11949534 on Feb 22, 2013 1:55 PM

    As far as creating a structured index, I was under the impression that I would need to then register an XSD. No, you can use it without an XML schema.
    How about a regular relational view, with an underlying xml index?
    That way you also eliminate the need for an explicit refresh step as you would then be querying real-time data, as if it were relational data.
    For example :
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL> create table tmp_xml of xmltype ;
    Table created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="1">ABC</item><item id="2">DEF</item></root>')
      3  ) ;
    1 row created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="3">GHI</item><item id="4">JKL</item></root>')
      3  ) ;
    1 row created.
    SQL> create or replace view tmp_xml_v as
      2  select x.item_id, x.item_val
      3  from tmp_xml
      4     , xmltable(
      5         '/root/item' passing object_value
      6         columns item_id  number      path '@id'
      7               , item_val varchar2(3) path '.'
      8       ) x
      9  ;
    View created.
    SQL> create index tmp_xml_sxi on tmp_xml (object_value)
      2  indextype is xdb.xmlindex
      3  parameters (q'#
      4  XMLTABLE tmp_xml_xtb '/root/item'
      5  COLUMNS item_id  number      path '@id'
      6        , item_val varchar2(3) path '.' #'
      7  ) ;
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user, 'TMP_XML');
    PL/SQL procedure successfully completed.
    SQL> set autotrace on explain
    SQL> set lines 200
    SQL> select * from tmp_xml_v ;
       ITEM_ID ITE
             3 GHI
             4 JKL
             1 ABC
             2 DEF
    Execution Plan
    Plan hash value: 4168126828
    | Id  | Operation                    | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                        |       |       |            |          |
    |   2 |   NESTED LOOPS               |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | SYS_C009273            |     2 |    34 |     1   (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN          | SYS30366_30367_OID_IDX |     2 |       |     0   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| TMP_XML_XTB            |     2 |    48 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("TMP_XML"."SYS_NC_OID$"="SYS_SXI_0"."OID")

  • Unable to create tables through dbms_sql

    Hai
    I got the below error when i am createing table through dbms_sql package at any user except sys user.Our database is 8.1.6 standard edition
    SQL>CONNECT MOHAN/MOHAN;
    SQL> CREATE OR REPLACE Procedure EXECUTESQL (SQLStatement IN VARCHAR2) IS cursor
    _name INTEGER; ret
    2 INTEGER; BEGIN cursor_name := DBMS_SQL.OPEN_CURSOR; DBMS_SQL.PARSE(cursor_n
    ame, SQLStatement,
    3 DBMS_SQL.native); ret := DBMS_SQL.Execute(cursor_name); DBMS_SQL.CLOSE_CURS
    OR(cursor_name); END;
    4 /
    Procedure created.
    SQL> exec EXECUTESQL('create table test(name number)');
    BEGIN EXECUTESQL('create table test(name number)'); END;
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 782
    ORA-06512: at "SYS.DBMS_SQL", line 32
    ORA-06512: at "MOHAN.EXECUTESQL", line 2
    ORA-06512: at line 1
    Any idea about that
    Thanks in advance
    mohan

    Since you are using Oracle 8.1.6, you can use EXECUTE IMMEDIATE instead of DBMS_SQL. Make sure that the necessary privileges have been granted directly, not through roles. Click on the link below for more about privileges and roles and the error message that you got:
    http://osi.oracle.com/~tkyte/Misc/RolesAndProcedures.html
    Once you have the privileges granted properly, you should be able to use the code below. I should point out that this is still doing things the hard way. You can just issue the create table statement from the SQL prompt. I must assume that this is just a minimal experiment and that the eventual code involves more.
    SQL> CREATE OR REPLACE PROCEDURE executesql
      2    (SQLStatement IN VARCHAR2)
      3  IS
      4  BEGIN
      5    EXECUTE IMMEDIATE SQLStatement;
      6  END executesql;
      7  /
    Procedure created.
    SQL> EXEC executesql ('CREATE TABLE test (name NUMBER)')
    PL/SQL procedure successfully completed.
    SQL> DESC test
    Name                                      Null?    Type
    NAME                                               NUMBER

  • How to grant create table privilege for a user on a specific table

    Hi:
    I created a user, for a test scenario. I granted this user create any table, and I made the default tablespace as example.
    When I connect as the user and try to create a table, I get this:
    SQL> create table T1 (NAME varchar2 (500), AGE number(2));
    create table T1 (NAME varchar2 (500), AGE number(2))
    ERROR at line 1:
    ORA-01950: no privileges on tablespace 'EXAMPLE'
    How can I grant the necessary privilege to have user create/delete tables on tablespace example?
    Thanks.
    DA

    create user ADAM identified by radge default tablespace EXAMPLE
    quota 10M on EXAMPLE;
    for example 10Mbytes given to Example tablespace.... or you can write:
    .....quota unlimited on EXAMPLE
    and
    grant connect to ADAM
    grant create table to ADAM .....
    or
    grant connect , resource to ADAM .... although grant resource is not recommended...
    ....and something else....
    you should define temporary tablespace in create user command... otherwise the system would be used...
    Greetings...
    Sim
    Message was edited by:
    sgalaxy

  • Getting error while creating table from one database to other.

    Hi,
    We are getting below error while creating the table from one database to other.
    SQL> create table fnd_lobs parallel compress as select * from [email protected];
    create table fnd_lobs parallel compress as select * from [email protected]
    ERROR at line 1:
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    Regards,
    Bhatia

    hi
    what are the apps version local and remote database???
    Snapshot too old errors occur because Oracle can 't reconstruct a consistent
    image of a block for the purposes of a consistent read.
    I feel at remote database, you are using UNDO, it will be rather easy to iincrease the undo retention time or increase the undo tablespace size.. if you are dealing with roll back segments, you may have rollback segments whose optimal values are too small...
    increase roll back segments size and select again then
    the following metalink notes might be helpful
    ORA-01555 "Snapshot too old" - Detailed Explanation Doc ID: 40689.1
    How To Avoid ORA-01555: Snapshot Too Old When Running PAAPIMP Doc ID: 603259.1
    OERR: ORA 1555 "snapshot too old (rollback segment too small)" Doc ID: 18954.1

  • While creating Table it shows error as 'missing or invalid option

    I had log on to ap/ap@vis in sqlplus and try to create table but showing error.....here below is the table
    Create table Purchase_Order
    (Item varchar2(10),
    Item_Desc varchar2(100),
    Item_Cost Number(7),
    Item_Qty Number(7),
    Item_Date Date,
    Need_by_date date,
    Last_updated_date date,
    last_updated_by number(10),
    creation_date date,
    created_by number(10),
    Attributed_category varchar2(100),
    attribute1 varchar2(100),
    attribute2 varchar2(100),
    attribute3 varchar2(100),
    attribute4 varchar2(100),
    attribute5 varchar2(100),
    attribute6 varchar2(100));
    But it showing error as ORA-00922:missing or invalid option

    It works for me
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> Create table Purchase_Order
      2  (Item varchar2(10),
      3  Item_Desc varchar2(100),
      4  Item_Cost Number(7),
      5  Item_Qty Number(7),
      6  Item_Date Date,
      7  Need_by_date date,
      8  Last_updated_date date,
      9  last_updated_by number(10),
    10  creation_date date,
    11  created_by number(10),
    12  Attributed_category varchar2(100),
    13  attribute1 varchar2(100),
    14  attribute2 varchar2(100),
    15  attribute3 varchar2(100),
    16  attribute4 varchar2(100),
    17  attribute5 varchar2(100),
    18  attribute6 varchar2(100));
    Table created.
    SQL>

  • ORA - 00922 Missing or Invalid option error while creating table

    I am tryin to create a table with the following syntax
    1 CREATE TABLE TEST_FOR_SCRIPT (
    2 TEST_A NUMBER NOT NULL
    3 ,TEST_B VARCHAR2(30) DEFAULT 'UNDEFINED' NOT NULL
    4 )
    5* @storage_parms_table_cmn
    6 /
    @storage_parms_table_cmn
    ERROR at line 5:
    ORA-00922: missing or invalid option
    Here, storage_parms_table_cmn.sql reads like this
    tablespace DBK_CMN_DATA
    Can anyone please guide me how to overcome this error.

    What is your Oracle Version?
    i can do it exactly what you did without error
    sql> CREATE TABLE vd.TEST_FOR_SCRIPT (
    2 TEST_A NUMBER NOT NULL
    3 ,TEST_B VARCHAR2(30) DEFAULT 'UNDEFINED' NOT NULL
    4 )
    5 @test1.sql
    6 /
    Table created.
    Cheers
    http://fiedizheng.blogspot.com/

  • Create Table using DBMS_SQL package and size not exceeding 64K

    I have a size contraint that my SQL size should not exceed 64K.
    Now I would appriciate if some one could tell me how to create a table using
    Dynamic sql along with usage of DBMS_SQL package.
    Brief Scenario: Users at my site are not given permission to create table.
    I need to write a procedure which the users could use to create a table .ALso my SQL size should not exceed 64K. Once this Procedure is created using DBMS_SQL package ,user should pass the table name to create a table.
    Thanks/

    "If a user doesn't have permission to create a table then how do you expect they will be able to do this"
    Well, it depends on what you want to do. I could write a stored proc that creates a table in my schema and give some other user execute privilege on it. They would then be able to create a able in my schema without any explicitly granted create table privilege.
    Similarly, assuming I have CREATE ANY TABLE granted directly to me, I could write a stroe proc that would create a table in another users schema. As long as they have quota on their default tablespace, they do not need CREATE TABLE privileges.
    SQL> CREATE USER a IDENTIFIED BY a
      2  DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
    User created.
    SQL> GRANT CREATE SESSION TO a;
    Grant succeeded.
    SQL> CREATE TABLE a.t (id NUMBER, descr VARCHAR2(10));
    CREATE TABLE a.t (id NUMBER, descr VARCHAR2(10))
    ERROR at line 1:
    ORA-01950: no privileges on tablespace 'USERS'So, give them quota on the tablespace and try again
    SQL> ALTER USER a QUOTA UNLIMITED ON users;
    User altered.
    SQL> CREATE TABLE a.t (id NUMBER, descr VARCHAR2(10));
    Table created.Now lets see if it really belongs to a:
    SQL> connect a/a
    Connected.
    SQL> SELECT table_name FROM user_tables;
    TABLE_NAME
    T
    SQL> INSERT INTO t VALUES (1, 'One');
    1 row created.Yes, it definitely belongs to a. Just to show that ther is nothing up my sleeve:
    SQL> create table t1 (id NUMBER, descr VARCHAR2(10));
    create table t1 (id NUMBER, descr VARCHAR2(10))
    ERROR at line 1:
    ORA-01031: insufficient privilegesI can almost, but not quite, see a rationale for the second case if you want to enforce some sort of naming or location standards but the whole thing seems odd to me.
    Users cannot create tables, so lets give them a procedure to create tables?
    John

Maybe you are looking for