人大金仓(kingbase)数据库常用sql命令
•
数据库
一. 字段
1. 添加
alter table book add column book_id varchar not null, book_title varchar(10) default '';
2. 删除
alter table book drop book_id, book_title; // 外键时 alter table book drop book_id, book_title cascade;
3. 修改类型
alter table book alter column book_title type varchar;
4. 重命名
alter table book rename column book_title to book_name;
二、主键
1. 添加
alter table book add primary key(book_id);
2. 删除
alter table book drop constraint book_id;
三、约束
1. 增加
// 唯一约束 alter table book add conversion book_id_unique unique(book_id); // 非空约束 alter table book alter column book_title set not null;
2. 删除
// 删除唯一约束 alter table book drop constraint book_id_unique; // 删除非空约束 alter table book alter column book_title drop constraint not null;
四、默认值
1. 添加和修改
alter table book alter column book_title set default '无';
3. 删除
alter table book alter column book_title dorp default;
无、注释
1. 表
comment on table book is '书';
2. 字段
comment on column book.book_id is '书ID';
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/072b4c7300.html
