Home  >  Article  >  Database  >  mysql sql statement to create table

mysql sql statement to create table

藏色散人
藏色散人Original
2019-10-22 10:01:5111142browse

mysql sql statement to create table

mysql sql statement to create a table

mysql commonly used sql statement to create a table:

Connection: mysql -h host address -u username -p user password (Note: u and root do not need to add spaces, the same applies to others)

Disconnect: exit (Enter)

Create authorization: grant select on database.* to username@login host identified by \"password\"

Modify password: mysqladmin -u username -p old password password new password

Delete authorization: revoke select,insert,update,delete om *.* from test2@localhost;

Recommended: "mysql tutorial"

Display database :show databases;

Show data tables: show tables;

Show table structure: describe table name;

Create database: create database library name;

Delete library: drop database library name;

Use library (selected library): use library name;

Create table: create table table name (field setting list);

Delete table: drop table table name;

Modify table: 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 operation)

Add columns: ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,ADD INDEX (c);

Modify columns: ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);

Delete columns: ALTER TABLE t2 DROP COLUMN c;

Backup database: mysql\bin\ mysqldump -h(ip) -uroot -p(password) databasename > database.sql

Restore database: mysql\bin\mysql -h(ip) -uroot -p(password) databasename < database. sql

Copy database: mysql\bin\mysqldump --all-databases > all-databases.sql

Repair database: mysqlcheck -A -o -uroot -p54safer

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

Data import and export: mysql\bin\mysqlimport database tables.txt

The above is the detailed content of mysql sql statement to create table. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn