Create basic table, database, column-level/table-level constraints

Source: Internet
Author: User

3.5 Create the drug table, the drug code is the main code, the lot number is unique Create table medicine (Medicinecode char) primary key,medicinename  varchar (Pycode char), Dosagefrom char (Ten), Standard char (), Batchnumber char (  unique,productiondate date,expirationdate date,category char (+), Yb char (10)); 3.7 Create a Vendor table, the main code is a table-level constraint Create table provider (Providercode char (4)  not null,providername  char ( not null,pycode char), Address char (6), Tel char (Zip char) ), Email char (+), Relation char (8), Primary key (Providercode)-Main code constraint, table-level constraint), 3.8 set up the supply table, including the main code, external code, are tag constraints create table pm (Medicinecode char)  not null,providercode char (4)   Not null,pmdate date not null,price  number,  qyt int,primary  key (Medicinecode,providercode,pmdate), Foreign key (Medicinecode)  references medicine ( Medicinecode), Foreign key (prOvidercode) References provider (Providercode)); 

Attention:
Column-level constraints: There are spaces separated before the constraint conditions;
Table-level constraints: As with defining attributes, make a single sentence, ending with a comma!


This article is from the "Sanghaidan blog column" blog, please be sure to keep this source http://10602803.blog.51cto.com/10592803/1683064

Create basic table, database, column-level/table-level constraints

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.