Before adding, modifying, and deleting tables, let's first introduce the basic structure of a relational database.
As shown in figure 1-2, a relational database mainly consists of three structures: database, table, and field. The top layer is RDBMS (database management software), and the actual database is created under RDBMS. Each database can contain one or more tables, strictly speaking, databases can not contain tables, but such databases do not have any function! We can also see that tables are the mainstay of the entire database system.
Create a table: Use the SQL cerate TABLE statement to name the table, define the column, and define the data type of each column.
Basic Syntax:
Create Table name_of_table 'create table is a keyword, which defines the list of data types of each column and each column in the table (name_of_column column_datatype 'each field must end with a comma)
Table change: Use the SQL ALTER TABLE statement. This statement can be used to add or delete columns in an existing table, but cannot change the data type of the existing columns.
Add column Syntax: alter table name_of_table add name_of_field data_type delete column: alter table name_of_table drop column name_of_field
Table deletion: Use the SQL drop TABLE statement
Syntax:
DROP TABLE name_of_table
PS: When deleting a table, you must consider it carefully. The data is priceless.