作者:海滨的微博小窝 | 来源:互联网 | 2023-09-15 16:03
是的。只需在您正在创建的表的列列表中声明约束:createtablea(anumbernotnull,bvarchar2(10));descaNameNullType--
是的。只需在您正在创建的表的列列表中声明约束:
create table a ( a number not null , b varchar2 ( 10 ) ) ;
desc a
Name Null Type
---- -------- ------------
A NOT NULL NUMBER
B VARCHAR2(10)
create table b ( a null, b null) as
select * from a;
desc b
Name Null Type
---- ---- ------------
A NUMBER
B VARCHAR2(10)
你也可以添加其他约束,使一个可空列非null,如果你想:
drop table b purge;
create table b ( a null unique, b not null) as
select * from a;
desc b
Name Null Type
---- -------- ------------
A NUMBER
B NOT NULL VARCHAR2(10)