oracle 数据库怎样设置默认值

oracle 数据库怎样设置默认值,第1张

如果表已经存在,用如下方法设置默认值。

alter table 表名 modify 字段名 default 默认值

如test表中设置age字段为30,可用如下语句

alter table test modify age default 30

设置默认值后在insert into table1(col1) values(value1)语句的字段列表中不能出现有默认值的字段

如果有字段,即使你的值是NULL也认为是有值,不会取默认的

create table test

(

col1 integer,

col2 varchar2(30) default '无内容'

)

insert into test(col1) values(3)

select * from test


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/8029229.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-12
下一篇2023-04-12

发表评论

登录后才能评论

评论列表(0条)

    保存