Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have two questions about inline constraints declarations for Oracle tables:

  1. Is it a bad practice? If so, why?

  2. How could one declare a different tablespace for the primary key and index like it's done when using the outline declaration? Something like

    create table THIS_TABLE (
        id number, 
        constraint THIS_TABLE_PK (id) tablespace INDEX_TABLESPACE
    ) tablespace DATA_TABLESPACE;
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Like this:

create table THIS_TABLE (
  id number NOT NULL, 
  constraint THIS_TABLE_PK PRIMARY KEY(id) 
             USING INDEX TABLESPACE INDEX_TABLESPACE
) tablespace DATA_TABLESPACE;

USING INDEX TABLESPACE is the syntax - you weren't far off.

As far as good/bad practice is concerned, that's opinion-based, so not really something that should be asked here. The alternative is to use the ALTER TABLE .... syntax after table creation.

share|improve this answer
    
Well, now I feel dumb. I should have tried the same syntax as for an outline declaration. Thanks for the feedback! –  Pedro Mendes Sep 5 '13 at 23:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.