Oracle SQL 维护 管理

来源:互联网 发布:疯狂的java讲义 pdf 编辑:程序博客网 时间:2024/05/22 14:52

//创建序列
create sequence emp_sequence
increment by 1
start with 1
cache 10
nocycle
nomaxvalue
//查看序列
select   *   from   user_sequences
//删除序列
drop   sequence   your_sequence_name
//创建触发器
CREATE OR REPLACE TRIGGER BIGBRANDS_TRIGGER
BEFORE INSERT ON WS2_RP_BIGBRANDS
FOR EACH ROW
BEGIN
SELECT BIGBRANDS_SEQUENCE.NEXTVAL INTO :NEW.ID FROM SYS.DUAL;
END;
//禁用/删除触发器
ALTER TRIGGER 名称 DISABLE;
drop trigger 名称;

//建表
create table WS2_RP_MachineModels(
Id number not null,
Name nvarchar(50) not null,
MachineTypeId number not null,
constraint PK_ID primary key(Id),
constraint FK_MachineTypeId foreign key(MachineTypeId) references
WS2_RP_MachineTypes(Id)
) tablespace system;
//查看用户所建的表
select   table_name   from   user_tables;
select   *   from   tab
select   *   from   dba_tables
select   *   from   user_tables   where   user= ' '
select   *   from   cat
//删除一列
alter table 表名 drop colum 列名
则将该表中这一列删除包括该列的关系