GBase 8a
适配迁移
文章
create table as select语句约束继承问题解决方法
发表于2025-12-24 14:43:2234次浏览0个评论
其他数据库执行create table as select语句时,默认不会继承源表的约束,如
create table t1(a int not null,b varchar(10));
create table t2 as select * from t1 where 1<>1;
t2表的a列无not null约束,那么insert时可以忽略a列只插入b列
gbase8a数据库执行上述语句时会继承表的约束,因为a列非空又没有默认值,所以insert时必须也要指定a列,解决办法执行以下语句
create table t2(a int default null) as select * from t1 where 1<>1; -- 取消a列的非空约束,不需要输入其他列信息即可
评论
登录后才可以发表评论
热门帖子
- 12025-12-01浏览数:182764
- 22023-05-09浏览数:25062
- 42023-09-25浏览数:18526
- 52020-05-11浏览数:17529