1.alter database 增加分配给数据库的控件量
alter database mydb on mydate =50 --(在数据库设备mydb 上加
log on mylog=10 --(在数据库设备mylog上加
2.alter role 定义角色之间的互斥关系;为角色添加,删除和更改口令;指定口令有效期,最小口令长度以及知道角色允许的最大登陆尝试失败次数.
例子1:将intern_role和specialist_role定义为互斥:
alter role specialist_role add exclusive membership intern_role
例子2:在成员资格级别和激活级别将角色定义为互斥
alter role specialist_role add exclusive membership intern_role
alter role intern_roleadd add exclusive activation surgeon_role
例子3:添加口令到现有的角色
alter role doctor_role add password “zhang”
例子4:从现有角色删除口令
alter role doctor_role drop password
例子5:锁定角色physician_role
alter role physician_role lock
例子6:解锁角色physician_role
alter role physician_role unlock
例子7:将physician_role允许的最大登陆尝试失败次数改为5
alter role physician_role set max failed_logins 5
例子8:将现有角色physician_role的最短口令长度设置为5个字符
alter role physician_role set min password length 5
例子9:替换所有角色的最短口令长度
alter role “all overrides” set min password length-1
例子10 删除所有角色的最大登陆失败次数的替换值
alter role “all overrides” set max password length-1
注意:一般为角色更改口令,请先删除口令,在添加口令.
3.alter table 向表添加新列;删除或修改现在的列;添加,更改或删除约束;更改现有表的属性;启用或禁用表上的触发器;
例子1:向表中添加一列
alter table tablename add manager_name varchar(50) null
例子2: 向表中添加identity列
alter table tablename add user_id numeric(19,0) identity
例子3 向表中添加主键约束.
alter table autors add constraint au_identification primary key(au_id,au_lname,au_fname)
例子4 在authors表上创建索引,设置reservepagegap值为16,在索引中为每15个分配的页留一个空白页
alter table authors
add constraint au_identification
primary key(au_id,au_lname,au_fname)
with reservepagegap=16
例子5 删除au_identification约束
alter table tablename
drop constraint au_identification
例子6 删除authors表中phone列的缺省约束.如果列允许为空值,则没有指定值时会插入空值.如果列不允许空值,则不指定列的插入,操作将失败
alter table authors
replace phone default null
例子7:为表创建4个新的页链.将表分区后,现有的数据会保存在第一个分区,但是新的行会插入到所有这5个分区中
alter table tablename partition 5
例子8 并置表的所有页链,然后将其重新分区为6个分区
alter table tablename unpartition
alter table tablename partition 6
例子9 将tablename表的锁定方案更改为数据行锁定
alter table tablename lock datarows
例子10 将非空列author_type 添加到缺省值为primary_author的authors表
alter table authors
add author_type varchar(20)
default “primary_author” not null
例子11 从表中删除列
alter table tablename
drop id,name
例子12 将表authors的city列修改为默认值为空值的varchar(30)
alter table authors
modify city varchar(30) null
例子13 将stores表中的name列修改为非空.
alter table stores
modify name not null
例子14 修改titles表的type列,并将titles表的锁定方案从所有页锁定更改为数据行锁定
alter table titles
modify type varchar(10)
lock datarows
例子15 将titles表的notes列由varchar(50),将缺省值由空更改为非空,并知道exp_row_size值为40
alter table titles
modify notes varhcar(50) not null
with exp_row_size=40
例子16 添加,修改和删除一列,然后在同一查询中添加另一列.改变锁定方案,并指定新列的exp_row_size值.
alter table titles
modify city varhcar(50) null
drop notes
add sec_advance money default 1000 not null
lock datarows
with exp_row_size=40

浙公网安备 33010602011771号