SQL table addition, modification, and deletion

Source: Internet
Author: User

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.

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.