本文介绍: 【代码】人大金仓(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://blog.csdn.net/jl15988/article/details/134799273

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_50879.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注