Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

create table as SELECT (question)

Roger25Sep 1 2011 — edited Sep 1 2011
Hi,

Regarding to create table as subquery, I've read that:

The column data type definitions and the NOT NULL constraint are passed to the new table. Note that only the explicit NOT NULL constraint will be inherited. The PRIMARY KEY column will not pass the NOT NULL feature to the null column. Any other constraint rules are not passed to the new table. However, you can add constraints in the column definition.

Can someone explain me, how to do this? Or, how should we specify the constraints (and also the default values of the columns, because it is possible) for the columns in the column definition?

Also, i don't understand this: The PRIMARY KEY column will not pass the NOT NULL feature to the null column.
Can someone give me some small examples regarding to these?
For example, this generates an error:
create table test1 (a, b, c default sysdate) 
as 
select 1, 'b' from dual
Thanks!

Edited by: Roger22 on 01.09.2011 11:37
This post has been answered by 32685 on Sep 1 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 29 2011
Added on Sep 1 2011
12 comments
7,808 views