MySQL common SQL statements and scripts

Source: Internet
Author: User

MySQL common SQL commands

Import
Mysql-uroot-proot test <c: \ test. SQL

Export
Mysqldump-uroot-proot test> C: \ test. SQL

Mysqldump-uroot-proot-r test> C: \ All. SQL-r stored procedure

Create a database
Create Database test;

Show Database
Show databases;

Use Database
Use test;

Show table names in the database
Show tables;

Create a table
Create Table D (ID int (10) Not null primary key auto_increment, username varchar (20 ));

Delete table
Drop table article;

Add data
Insert into article (article_type, article_content, article_title) values ('1', '2', '3 ');

Modify
Update article set article_content = '5' where article_id = 3;

Query
Select * from article where article_id = 3;

Delete table data

Delete from article where article_id = 3;

Delete Database
Drop database test;

######################################## ###############

MySQL Problems

MySQL garbled
MySQL DATA too long

/Usr/local/MySQL/bin/mysqldump-uroot-p $ PWD-r-B -- tables -- default-character-set = GBK test> D: \ A. SQL

-R can dump stored procedures

Zookeeper -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Script

Show database instances
Show databases;

Create database instance j1116
Create Database j1116;

Delete database instance j1116
Drop database j1116;

Create a table in a database instance
Use the database j1116;
Show tables in the database instance;
Create Table tab_student (ID int not null primary key auto_increment, name varchar (32), sex varchar (2), age int, XH varchar (10 ));

Display table structure
Desc tab_student;

Insert data
Insert into tab_student (name, sex, age, XH) values ('zhang san', 'female ', 23, '123 ');

Query statement
Select * From tab_student; query all fields in the table
Select name from tab_student; only query the name field
Select name from tab_student where age = 23; query the names of students whose ages are 23

Delete statement
Delete from tab_student; Delete full table data
Delete from tab_student where age <24; Delete students younger than 24 years old

Update statement
Update tab_student set sex = 'nv ', age = 21 where id = 7; update the gender and age of students whose ID is 7.

Delete table
Drop table tab_student;

 

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.