Setting primary keys in Oracle

Source: Internet
Author: User

1. Create a table

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(Ten), "Type1"varchar(255), "Union1"int(Ten), "Bthconstruction"int(Ten), "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));
View Code

#查看约束

Select *  from User_constraints;
View Code


////Setting the primary key auto-increment////


2. Create a sequence

Select *  from User_constraints;
View Code

#查看序列

Select *  from User_sequences;
View Code

3. Setting up triggers //If the table name is lowercase, the operation should be the "" number lookup, the same column field, required in Navicat, Eclipse can not.

Create or Replace Trigger  Insert on ' C_user ' for each row and is NULL )beginSelect into from dual; End;
View Code


     #查看触发器
      

 Select *  from User_triggers;
View Code


     #测试

commit; // command-line operations                        require Select *  from "C_user";
View Code

Setting primary keys in Oracle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.