Home> Database> SQL> body text

What are the commonly used SQL statements?

silencement
Release: 2019-06-10 16:38:32
Original
5314 people have browsed it

What are the commonly used SQL statements?

Commonly used sql statements

1. Database related

Check all databases

show databases
Copy after login

Create database

create database db1
Copy after login

View database

show create database db1
Copy after login

Create database and specify character set

create database db1 character set utf8/gbk
Copy after login

Delete database

drop database db1
Copy after login

Use database

use db1
Copy after login

Table related

Create table

create table t1(id int,name varchar(10))
Copy after login

View all tables

show tables
Copy after login

View single table attributes

show create table t1
Copy after login

View table fields

desc t1
Copy after login

Create a table and specify the engine and character set

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

Modify the table

Modify the table name

rename table t1 to t2
Copy after login

Modify the table attributes

alter table t1 engine=myisam/innodb charset=utf8/gbk
Copy after login

Add table field

alter table t1 add age int first/after xxx
Copy after login

Delete table field

alter table t1 drop age
Copy after login

Modify table field name and type

alter table t1 change age newAge int
Copy after login

Modify table type and location

alter table t1 modify age int first/after xx
Copy after login

Delete Table

drop table t1
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!