当前位置:网站首页>SQL related knowledge - DDL
SQL related knowledge - DDL
2022-06-26 04:05:00 【Code Xiaoyou】
SQL:Structured Query Language: Structured query language
SQL General grammar :
1.SQL Grammar can be written in one or more lines , It ends with a semicolon
2. You can use spaces and indents to enhance the readability of statements
3.MySQL Database sql Statement is case insensitive , It is recommended to use uppercase
4.3 Species notes
* Single-line comments :-- The comment or # The comment (-- Put a space after it ,# No requirement )
* Multiline comment :/* notes */
SQL classification :
1)DDL(Data Definition Language) Data definition language Used to define database objects : database , surface , Column, etc. . keyword :create,drop,alter etc.
2)DML(Data Manipulation Language) Data operation language It is used to add, delete and modify the data in the database . keyword :insert,delete,update etc.
3)DQL(Data Query Language) Data query language Used to query the records of tables in the database ( data ). keyword :select,where etc.
4)DCL(Data Control Language) Data control language It is used to define the access rights and security level of the database , And Create user . keyword :GRANT,REVOKE etc.
DDL: Operating the database , surface
1. Operating the database :CRUD
1.1 C(Create): establish
* Create database :
create database Database name ;
* Create database , Judgment does not exist , To create a
create database if not exists Database name ;
* Create database , And specify the character set
create database Database name character set Character set name ;
1.2 R(Retrieve): Inquire about
* Query all database names ;
show databases;
* Query the character set of a database : Query the creation statement of a database ;
show database Database name ;
1.3 U(Updata): modify
* Modify the character set of the database
alter database Database name character set Character set ;
1.4 D(Delect): Delete
* Delete database
drop database Database name ;
* Determine that the database exists , Exist and delete
drop database if exists Database name ;
1.5 Using a database
* Query the currently used database name
select database();
* Using a database
use Database name ;
2. Operation table
1.1 C(Create): establish
* Create table grammar
create table Table name (
Name 1 data type 1,
Name 2 data type 2,
....
Name n data type n
);
* Copy table
create table Table name like Assigned table name ;
practice : Create a student table
create table Student( num int, name varchar(20), age int, score double(5,1), # Retain 5 Significant digits , Decimal places reserved 1 position birthday date, insert_time timestamp );
(timestamp: This is a data type , If you don't assign a value to this field , Or assign the value to NULL, The current system time is used by default , To automatically assign )1.2 R(Retrieve): Inquire about
* Query all table names in a database
show tables;
* Query table structure
desc Table name ;
1.3 U(Updata): modify
* Modify the name of the tablealter table Table name rename to New table name ;
* Modify the character set of the table
alter table Table name character set Character set ;
* Add a column
alter table Table name add Name data type ;
* Change column name type
alter table Table name change Name New column names New data types ;
alter table Table name modify Name New data types ;
* Delete column
alter table Table name drop Name ;
1.4 D(Delect): Delete
* Delete table
drop table The name of the table ;
* The judgment table exists , Exist and delete
drop table if exists The name of the table ;
边栏推荐
- Link monitoring pinpoint
- ipvs之ipvs0网卡
- How do wechat applets delay? Timing? Execute a piece of code after? (kengji)
- EF core Basics
- 763. 划分字母区间
- R语言与机器学习
- How much do you make by writing a technical book? To tell you the truth, 2million is easy!
- Alibaba cloud function computing service one click to build Z-blog personal blog
- Lua grammar explanation
- ABP framework Practice Series (III) - domain layer in depth
猜你喜欢

钉钉开放平台-小程序开发实战(钉钉小程序服务器端)
![[MySQL] MySQL export database](/img/e3/1aa31760dc5447b7c3c0d942644116.jpg)
[MySQL] MySQL export database

Sorting out the examination sites of the 13th Blue Bridge Cup single chip microcomputer objective questions

ABP framework Practice Series (II) - Introduction to domain layer

【QT】对话框dialog

Getting started with flask

matplotlib多条折线图,点散图

【掘金运营套路揭露】真心被掘金的套路....

Tencent Interviewer: How did binder get its system services?

开源!ViTAE模型再刷世界第一:COCO人体姿态估计新模型取得最高精度81.1AP
随机推荐
Ten important basic principles of software debugging and testing
Quanergy欢迎Lori Sundberg出任首席人力资源官
Chrome page recording and playback function
ABP framework Practice Series (II) - Introduction to domain layer
After four years of outsourcing, people are directly abandoned...
線程同步之讀寫鎖
高性能算力中心 — RoCE — Overview
[MySQL] MySQL export database
【掘金运营套路揭露】真心被掘金的套路....
What if the serial port fails to open when the SCM uses stc-isp to download software?
Matplotlib multi line chart, dot scatter chart
Detr3d multi 2D picture 3D detection framework
How do wechat applets delay? Timing? Execute a piece of code after? (kengji)
mysql自带的性能测试工具mysqlslap执行压力测试
bubble sort
763. 划分字母区间
Ieda suddenly cannot find compact middle packages
而是互联网开始有了新的进化,开始以一种全新的状态出现
IEDA 突然找不到了compact middle packages
捕获数据包(Wireshark)
