MySQL basic (DDL)

Source: Internet
Author: User

MySQL basic (DDL)
SQL Classification

        SQL statements can be divided into three categories.
DDL: Data Definition Language, defining data segments, databases, data tables, and other DML: data manipulation statements, used to add, delete, update, and query database records DCL: Data Control statements, statements used to control the direct permission and access level of different data segments

Prepare, first start MySQL Service net start mysql, and enter mysql, mysql-u root-p (-u is followed by the database user,-p indicates that the password needs to be entered)


1. DDL statements

Language used to create, delete, and modify objects in the database.

1.1 create database ----;
    

After creating the database, view the database show databases;

Select the database use ---
View the table show tables in the database;

1.2 delete a database

Drop database ----;

1.3 create a table

Create table --- (name1 type constraint, name2 type constraint ......);
Check the created table to see if it meets the requirements of desc --;

1.4 delete a table

Drop table ----;

1.5 modify a table

Alter table --- modify ---;

Add the new field alter table --- add colum ----;

Delete field alter table --- drop colum ---;
Alter table --- change ---;


Related Article

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.