当前位置:网站首页>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 ;
边栏推荐
- go time包:秒、毫秒、纳秒时间戳输出
- Quanergy欢迎Lori Sundberg出任首席人力资源官
- ipvs之ipvs0网卡
- 1.基础关
- Optimization - multi objective planning
- How much do you make by writing a technical book? To tell you the truth, 2million is easy!
- The style of the mall can also change a lot. DIY can learn about it
- Detailed explanation of globalkey of flutter
- Spark - 一文搞懂 parquet
- What preparation should I make before learning SCM?
猜你喜欢

User control custom DependencyProperty

Camera-CreateCaptureSession

力扣 515. 在每个树行中找最大值

钉钉开放平台-小程序开发实战(钉钉小程序客户端)

【MySQL】 MySQL 导出数据库

外包干了四年,人直接废了。。。
![Which is the best embedded visual programming software? (introduction, evaluation and selection of visual programming platform) [scratch, mind+, mixly]](/img/9c/7af92e6ef907b443d974275614e51a.jpg)
Which is the best embedded visual programming software? (introduction, evaluation and selection of visual programming platform) [scratch, mind+, mixly]

第 4 篇:绘制四边形

Ten important basic principles of software debugging and testing

Restful API interface design standards and specifications
随机推荐
Yolov5 improvements: replace the backbone
Quanergy welcomes Lori sundberg as chief human resources officer
判断两个集合的相同值 ||不同值
軟件調試測試的十大重要基本准則
1.基础关
Conditional variables for thread synchronization
钉钉开放平台-小程序开发实战(钉钉小程序服务器端)
Chrome page recording and playback function
How to solve the problem that iterative semi supervised training is difficult to implement in ASR training? RTC dev Meetup
MySQL common statements
Optimization - multi objective planning
Part 4: drawing quadrilateral
Camera-CreateCaptureSession
软件调试测试的十大重要基本准则
Verrouillage de lecture et d'écriture pour la synchronisation des fils
Question brushing record day01
線程同步之讀寫鎖
Analysis of the principle of obxwidget
力扣 515. 在每个树行中找最大值
【Flink】Flink源码分析——批处理模式JobGraph的创建
