kingbaseESV8修改表

本文详细介绍了在KingBase数据库管理系统中进行SQL操作,包括修改表结构(如schema、表名、约束名)、创建和管理表空间、表的复制、列类型修改、事务处理以及临时表的使用。

--修改表的schema
alter table exam.score set schema new_schema;
--修改表名
alter table xxx rename to new_xxx;
--修改约束名
alter table xxx rename constraint fk_1 to fk_2;

--建表like语法
create table t02 (like t01 including default including constrains including indexes);
create table new_schema.studetlike (like exam.student including all);

--表所在的表空间
select table_name,tablespace_name from dba_tables;

mkdir tbs01;
mkdir tbs02;
--创建表空间
create tablespace tbs01 location '/home/kingbase/tbs01';
create tablespace tbs02 location '/home/kingbase/tbs02';
--修改表空间
alter table exam.course set tablespace tbs01;
select table_name,tablespace_name from dba_tables t where t.table_name = 'COURSE';
--迁移表空间中的所有表
alter table all in tablespace tbs01 set tablespace sys_default;

--修改列类型
create table aaa (id char(1));
alter table aaa alter column id type int;
--删除表
drop table if exists aaa;

--事务结束保留记录
create temporary table temp01(id int primary key,name text) on commit preserve rows;
--事务结束清除记录
create temporary table temp02(id int primary key,name text) on commit delete rows;
--事务结束删除临时表
create temporary table temp02(id int primary key,name text) on commit drop;

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值