Mysql common SQL statements for table creation

Source: Internet
Author: User
My experience in using common SQL statements for mysql table creation Mysql common SQL statements for table creation

Connection: mysql-h host address-u user name-p user password (note: u and root do not need to add spaces, the same is true for others)
Disconnected: exit (press enter)

Create authorization: grant select on database. * to username @ login host identified by/"password /"
Change password: mysqladmin-u username-p old password new password
Delete authorization: revoke select, insert, update, delete om *. * from test2 @ localhost;

Display database: show databases;
Show table: show tables;
Display table structure: describe table name;

Database creation: create database name;
Delete database: drop database name;
Use Database (selected database): use database name;

Create table: create table name (field setting list );
Delete table: drop table name;
Alter table t1 rename t2
Query table: select * from table name;
Clear table: delete from table name;
Backup table: mysqlbinmysqldump-h (ip)-uroot-p (password) databasename tablename> tablename. SQL
Restore table: mysqlbinmysql-h (ip)-uroot-p (password) databasename tablename <tablename. SQL (delete the original table before the operation)

ADD column: alter table t2 ADD c int unsigned not null AUTO_INCREMENT, add index (c );
ALTER column: alter table t2 MODIFY a tinyint not null, CHANGE B c CHAR (20 );
Delete COLUMN: alter table t2 drop column c;

Backup database: mysql/bin/mysqldump-h (ip)-uroot-p (password) databasename> database. SQL
Recover database: mysql/bin/mysql-h (ip)-uroot-p (password) databasename <database. SQL
Copy database: mysql/bin/mysqldump -- all-databases> all-databases. SQL
Fix the database: mysqlcheck-A-o-uroot-p54safer

Text data import: load data local infile/"file name/" into table name;

Data import and export: mysql/bin/mysqlimport database tables.txtbitsCN.com

The above is my personal experience sharing _ mysql content for commonly used SQL statements for MySQL table creation. For more information, see PHP Chinese network (www.php1.cn )!

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.