达梦数据库个人学习笔记分享

目录

约束:........................................................................................................................ 1

视图:........................................................................................................................ 2

索引:........................................................................................................................ 2

表空间及数据文件:............................................................................................... 2

重做日志:............................................................................................................... 3

归档:........................................................................................................................ 3

内、外连接:........................................................................................................... 4

账户及权限:........................................................................................................... 5

常用函数:............................................................................................................... 7

备份:........................................................................................................................ 7

其他:........................................................................................................................ 8

约束:

alter table test modify aaa not null; 为test表aaa字段创建非空约束。注意:如果表已经有数据,并且该列有 NULL 值,非空的约束我们是无法添加的。

alter table test modify aaa null;删除非空约束

alter table test modify aaa default ‘贵阳’; 修改表test列aaa的默认值为贵阳

alter table test alter aaa drop default; 删掉默认设置

alter table test add constraint qwe unique (aaa);为test表aaa字段创建唯一约束qwe。

alter table test add constraint qwe primary key (aaa);

alter table test add constraint qwe primary key (aaa,bbb); 同时添加2个主键,一个一个添加的时候会报错。

alter table test add constraint qwe check(aaa>3);

alter table test add constraint qwe foreign key (aaa) references test2(eee); 外键约束,一个表可以有多个外键,外键是另外一张表的主键,同时外键列的内容必须包含在另外一张表主键列的内容中。我们也可以在创建表时指定。

alter table test disable constraint qwe; 禁用约束qwe

alter table test enable constraint qwe; 启用约束qwe

select * from dba_constraints;

alter table test drop constraint qwe;

当drop或delete某张表失败提示锁超时时,select * from v$lock 查看被锁事务的TRX_ID,再select * from v$sessions,根据TRX_ID查找该事务对应的SESS_ID,最后 sp_colse_session(找到的SESS_ID)关闭对应的会话。

视图:

create view test as select……创建视图

create or replace view test as ……修改视图

索引:

create unique index qwe on test(aaa);创建唯一索引

create bitmap index qwe on test(aaa);创建位图索引

create cluster indx qwe on test(aaa);创建聚集索引

位图索引与聚集索引不能在一张表上

select * from dba_indexes where table_name like ‘TEST’;查询表test的索引,注意是index后面加es,而不是加s

drop index qwe;

表空间及数据文件:

在 DM 数据库中,表空间由一个或者多个数据文件组成。DM 数据库中的所有对象在逻辑上都存放在表空间中,而物理上都存储在所属表空间的数据文件中。

create tablespace test datafile '/home/dmdba/dmdbms/data/DAMENG/test.dbf' size 1024  autoextend on next 4 maxsize  unlimited;

alter tablespace test resize datafile '/home/dmdba/dmdbms/data/DAMENG/test.dbf' to 1025;

alter tablespace test add datafile '/home/dmdba/dmdbms/data/DAMENG/test.dbf' size 1024;

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值