Create a table, create a database, delete a table, delete a database

Source: Internet
Author: User

Create a table, create a database, delete a table, delete a database

    1. Create a database

Create DATABASE Text2 Text2

2. Deleting a database

Drop database Text2 Delete the databases Text2

    1. Create a table

The CREATE table class creates a form called class, which is a primary table.

(

Code varchar (primary key), creating the serial number

Name varchar () Not NULL creates a name that is not nullable

)

CREATE TABLE Ceshi creates a list called Ceshi this is from the table

(

IDS int Auto_increment Primary key, complete with commas for each sentence

UID varchar (20),

Name varchar (20),

Foreign key (Class) references class (code) to establish a foreign key relationship

)

*auto_increment Self-growth

*primary Key Primary Key

*foreign key (column name) references Main Table name (column name)

*not NULL non-null

Attention:

    1. The type contains the length of the parentheses after the type, and the parentheses write the length
    2. Add a comma when you finish writing the previous column
    3. Don't write a comma in the last column
    4. Be sure to add a semicolon after each SQL statement
    5. Write the program code when you write in the English state
    6. If you have a foreign key relationship, you must first create the main table * or it will go wrong!

    1. Delete a table

DROP table class cannot delete a primary table with a foreign key relationship can be deleted from the table

Create a table, create a database, delete a table, delete a database

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.