I am relatively new to SQL and only dabble with it when it is required. I have done some research on this but have limited success. I need to remove the tablespace references from the code. The settings already exist in the database for a default tablespace. By the way it is an Oracle database.
If I have these lines of code:
EXECUTE IMMEDIATE 'CREATE TABLE RAND_CATEGORY(
-------- insert random vars ---------------
CONSTRAINT RAND_CATEGORY PRIMARY KEY(cat_id,ver_num)
USING INDEX TABLESPACE VG_NDX ENABLE
)TABLESPACE VG_DATA';
Here’s what I have so far:
EXECUTE IMMEDIATE 'CREATE TABLE RAND_CATEGORY(
-------- insert random vars ---------------
CONSTRAINT RAND_CATEGORY PRIMARY KEY(cat_id,ver_num)
USING INDEX TABLESPACE VG_NDX ENABLE
)';
My question is, should I remove the entire line:
USING INDEX TABLESPACE VG_NDX ENABLE
Or should I just remove the “TABLESPACE VG_NDX” and leave it as:
USING INDEX ENABLE
Keep in mind that I am new to this and I just need help with this. I have been learning SQL for the past 2 weeks and tablespaces are a bit funky to me. Thanks in advance! 😀
The
USING INDEXclause allow to have more control over the constraint associated index creation, see http://docs.oracle.com/cd/B28359_01/server.111/b28310/indexes003.htm.In your case the
TABLESPACEstorage clause.If you want to let Oracle use the default tablespace you can remove the
USING INDEXclause entirely leavingENABLE.Although in a
CREATE TABLEa primary key constraint associated index is automatically enabled (unless I missed something) so I can’t see any point of keeping theENABLE.