1.创建表
1.创建表 create table "c_user"( "id" number primary key, "username" varchar(255), "password" varchar(255), "p_name" varchar(255), "p_number" varchar(255), "p_date" varchar(255), "p_referenceNumber" varchar(255), "tech_area" varchar(255), "platformLevel" varchar(255), "address" varchar(255), "permission" int(10), "type1" varchar(255), "union1" int(10), "BTHconStruction" int(10), "service1" varchar(255), "service2" varchar(255), "service3" varchar(255), "course1" varchar(255), "course2" varchar(255), "course3" varchar(255), "relyName" varchar(255), "credit" varchar(255), "relylegalName" varchar(255), "phone" varchar(255), "unitType" varchar(255), "constructionUnit" varchar(255), "directorName" varchar(255), "directorSex" varchar(255), "directorBirthyear" varchar(255), "directorTitle" varchar(255), "directorProfessional" varchar(255), "directorEducation" varchar(255), "directorDegree" varchar(255), "directorTele" varchar(255), "directorPhone" varchar(255), "directorEmail" varchar(255), "webName" varchar(255), "webSite" varchar(255), "addrplatformAddressess" varchar(255), "email" varchar(255), "state" int(2), "u_type" int(6), "p_type" int(2) );
#查看约束
select * from user_constraints;
////设置主键自增////
2.创建序列
create sequence c_user_id_seq start with 1 increment by 1;
#查看序列
select * from user_sequences;
3.设置触发器 //若表名为小写时,操作时应加“”号查找,列字段相同,在NAvicat中需要,eclipse可以不用。
create or replace trigger c_user_trigger before insert on "c_user" for each row when(new."id" is null) begin select c_user_id_seq.nextval into:new."id" from dual; end;
#查看触发器
select * from user_triggers;
#测试
commit;//命令行操作需要 select * from "c_user";
来源:https://www.cnblogs.com/zhao-teng-ass/p/9356819.html