Create a table, create a database, delete a table, delete a database
- Create a database
Create DATABASE Text2 Text2
2. Deleting a database
Drop database Text2 Delete the databases Text2
- 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:
- The type contains the length of the parentheses after the type, and the parentheses write the length
- Add a comma when you finish writing the previous column
- Don't write a comma in the last column
- Be sure to add a semicolon after each SQL statement
- Write the program code when you write in the English state
- If you have a foreign key relationship, you must first create the main table * or it will go wrong!
- 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