MySQL basic commands

Source: Internet
Author: User

Querying existing databases: show databases;

Operations on the database:

1. Delete database: Run drop database + name;

2. Add Database: Run CREATE DATABASE + name;

Operations on a table:

First you have to open the database of the table you want to manipulate before you can operate, run the Use+ database name

Querying tables in the database: Run show tables;

1. Add Table: Create TABLE + table name (ID int,name varchar (20));

When querying the table again, one more table was added successfully

2. Delete tables: Drop table O

When you query the table again, you can find that an OS table is missing, indicating that the deletion was successful.

Operations on data in a table

1, query the contents of the table: SELECT * from student;

2. Delete the contents of the table: Delete from table name where condition (note: Be careful when performing this step to ensure that "from deletion to escape" does not occur)

2, add the contents of the table: divided into 3 kinds

(1) Single: Insert into student (user_name, sex, birthday) values (' Little red ', ' male ', ' 2001-09-18 ');

(2) Multiple: Insert into student (user_name, sex, birthday) VALUES (' xiaoming ', ' Male ', ' 2001-09-18 '), (' xiaoming ', ' Male ', ' 2001-09-18 '), (' xiaoming ', ' Male ') , ' 2001-09-18 ');

(3) Insert query result: INSERT into student (user_name,sex,birthday) (select User_name,sex,birthday from student where id=10);

MySQL basic commands

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.