Oracle Learning record two creation tables and other operational exercises

Source: Internet
Author: User

After the first chapter of the basic data operation instructions are practiced, some operations of the database are performed.

  1. Create a table class has two columns: numbers and names:

CREATE table Class (numbers number, names char (20));

This is the name of the case, don't want to add "" "double quotation mark numbers this is the column, number this is the data type

2. When you are building a table, limit which data can be stored

CREATE table Class2 (numbers number not NULL, names char (20));

This is numbers, this column is not allowed to be empty.

CREATE table CLASS3 (numbers number unique, names char (20));

This is numbers data cannot be duplicated, that is, the only

CREATE table CLASS4 (numbers number check (Numbers > 0), name Char (20));

This is a value of numbers that must be greater than 0

CREATE table CLASS5 (numbers number primary key, name Char (20));

This is the creation of a table with a primary key, and the primary key is numbers.

ALTER TABLE CLASS4 add primary key (numbers);

This is the Modify table, set the primary key for CLASS4 to numbers.

ALTER TABLE CLASS3 add primary key (numbers);

Here is to modify the CLASS3 just built the table, but not successful, said that there is already a unique or primary key.










Oracle Learning record two creation tables and other operational exercises

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.