Oracle command to create a primary key foreign key

Source: Internet
Author: User


Oracle command to create a primary key foreign key 1. create a student table [SQL] SQL> create table t_stu (2 stuid number (10) primary key, 3 stuname varchar2 (20) not null, 4 stusex varchar2 (2) default 'male' check (stusex in ('male', 'female '))); table created Executed in 0.547 seconds 2. create a curriculum [SQL] SQL> create table t_couse (2 couseid number (10) primary key, 3 cousename varchar2 (20) not null, 4 cousetype varchar2 (4); www.2cto.com Table created Executed in 0.062 seconds 3. Create a student course quota Table (including the primary and Foreign keys) [SQL] SQL> create table t_score (2 scoreid number (10) primary key, 3 stuid number (10) references t_stu (stuid), 4 couseid number (10 ), 5 constraint fk_couseid foreign key (couseid) 6 references t_couse (couseid) 7 on delete cascade); Table created

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.