Home  >  Article  >  Database  >  What are the commonly used SQL statements?

What are the commonly used SQL statements?

silencement
silencementOriginal
2019-06-10 16:38:325352browse

What are the commonly used SQL statements?

Commonly used sql statements

1. Database related

Check all databases

 show databases

Create database

create database db1

View database

show create database db1

Create database and specify character set

create database db1 character set utf8/gbk

Delete database

drop database db1

Use database

use db1

Table related

Create table

 create table t1(id int,name varchar(10))

View all tables

show tables

View single table attributes

show create table t1

View table fields

desc t1

Create a table and specify the engine and character set

create table t1(id int,name varchar(10)) engine=myisam/innodb charset=utf8/gbk

Modify the table

Modify the table name

rename table t1 to t2

Modify the table attributes

alter table t1 engine=myisam/innodb charset=utf8/gbk

Add table field

alter table t1 add age int first/after xxx

Delete table field

alter table t1 drop age

Modify table field name and type

alter table t1 change age newAge int

Modify table type and location

alter table t1 modify age int first/after xx

Delete Table

drop table t1

The above is the detailed content of What are the commonly used SQL statements?. 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
Previous article:what is jsonNext article:what is json