MySQL Base (DDL)

Source: Internet
Author: User

SQL classification
SQL statements can be divided into 3 categories
DDL: Data definition language, defining data segments, databases, data tables, and other DML: data manipulation statements for adding, deleting, updating, and querying database records DCL: Data control statements, statements that control the level of permission and access to different data segments directly

to get started, start MySQL service net start MySQL, go to MySQL, mysql-u root-p (U back with database user,-p indicates need to enter password)

     
1. DDL statements

The language in which objects inside the database are created, deleted, modified, and so on.

1.1 Creating a DatabaseCREATE database----;        
    

After creating the database, view the database show databases;

                

Select the database you want to manipulate use---
View the tables in the database show tables;

                           1.2 Deleting a database

drop database----;


1.3 Creating a Table

CREATE TABLE---(name1 type constraint, name2 type constraint ...);
Look at the table you just created to see if it meets the requirements desc--;


1.4 Deleting a table

drop table----;


1.5 Modifying a table

To modify the data type of an item in a table ALTER TABLE---modify---;

           

Add new field ALTER TABLE---add colum----;

         


delete field ALTER TABLE---drop colum---;
Modify the field name ALTER TABLE---change---;


MySQL Base (DDL)

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.