sql语句创建 表,索引, sequence。
来源:互联网 发布:美工刀架图片 编辑:程序博客网 时间:2024/05/17 07:26
SQL> create table t_inspection_d
2 (id number(10) not null constraint pk_t_inspection_d primary key,
3 inspection_code varchar2(3),inspectionflag number(1),
4 staffcode varchar2(6),loggingdate DATE default SYSDATE)
5 tablespace cosf;
Table created.
SQL> create table t_inspection
2 (id number(10) not null constraint pk_t_truckinspection primary key,
3 lccode varchar2(6),truckcode varchar2(8),
4 inspection_did number(10) not null,
5 loggingdate DATE default SYSDATE,
6 constraint fk_t_inspection foreign key(inspection_did) references
7 t_inspection_d(id))
8 tablespace cosf;
Table created.
SQL> create sequence t_inspection_seq increment by 1
2 start with 1
3 nomaxvalue nocycle cache 20;
Sequence created.
SQL> create sequence t_inspection_d_seq increment by 1
2 start with 1 maxvalue 9999999999 nocycle cache 20;
Sequence created.
SQL> create or replace trigger "t_inspection_id"
2 before
3 insert on "COSF"."T_INSPECTION" for each row
4 declare next_checkup_no number;
5 begin
6 select t_inspection_seq.nextval into next_checkup_no from dual;
7 :new.id := next_checkup_no;
9 end;
10 /
Trigger created.
SQL> create or replace trigger "t_inspection_d_id"
2 before
3 insert on "COSF"."T_INSPECTION_D" for each row
4 declare next_no number;
5 begin
6 select t_inspection_d_seq.nextval into next_no from dual;
7 :new.id := next_no;
8 end;
9 /
Trigger created.
===========================================
创建sequence
CREATE SEQUENCE emp_sequence
INCREMENT BY 1 -- 每次加几个
START WITH 1 -- 从1开始计数
NOMAXVALUE -- 不设置最大值
NOCYCLE -- 一直累加,不循环
NOCACHE -- 不建缓冲区
==================
创建索引:CREATE UNIQUE INDEX LY.HARD ON LY.HARD(hard_id);
- sql语句创建 表,索引, sequence。
- SQL创建表索引语句
- SQL语句-创建索引
- SQL语句-创建索引
- SQL语句-创建索引
- SQL语句-创建索引
- sql语句创建全文索引
- T-SQL语句创建索引
- sql语句创建唯一索引
- SQL语句创建(数据库|数据表|索引)
- mysql 创建索引,删除索引的sql语句 【转】
- SQL语句---创建表
- Sql语句创建表
- SQL语句-创建表
- sql语句创建表
- SQL语句创建表
- SQL语句创建表
- 查询数据库表索引名称、索引字段、创建索引语句
- asp.net 解决js传递参数时,url汉字乱码的问题
- 【顶】利用分子分母有理化或者平方开方解题的典型及一道待解决的问题
- Android关于Content Provider的电话本小研究
- cmd 命令行乱码问题
- 【算法导论】21:并查集Disjoint sets
- sql语句创建 表,索引, sequence。
- 一个完整的Oracle建表的例子
- Linux 下串口编程入门
- ORA-39095: 转储文件空间已耗尽: 无法分配 4096 字节
- IIS安装前已经安装了.NET Framework,安装后如何启用.NETFramework
- 运用RUP 4+1视图方法进行软件架构设计
- 数据结构_二叉堆普通操作
- Intel HEX格式文件说明
- 基于RBAC的权限管理系统的实现