当前位置:网站首页>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 ;
边栏推荐
- QPS的概念和实现
- 三元损失英文版
- Yolov5 improvements: replace the backbone
- Three level menu applet
- 816. fuzzy coordinates
- EF core Basics
- 169. most elements
- 2020 summary: industrial software development under Internet thinking
- Restful API interface design standards and specifications
- What if the serial port fails to open when the SCM uses stc-isp to download software?
猜你喜欢
[LOJ 6718] nine suns' weakened version (cyclic convolution, arbitrary modulus NTT)
How much do you make by writing a technical book? To tell you the truth, 2million is easy!
Verrouillage de lecture et d'écriture pour la synchronisation des fils
【QT】对话框dialog
Judge the same value of two sets 𞓜 different values
Capture packets (Wireshark)
Flask入门
高性能算力中心 — RoCE — Overview
线程同步之互斥量(互斥锁)
【QT】资源文件导入
随机推荐
神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习
I/o virtualization technology - UIO framework
钉钉开放平台-小程序开发实战(钉钉小程序客户端)
Sorting out the knowledge points of the renderview renderobject parentdata of the shuttle
169. most elements
chrome页面录制,重放功能
面了个字节拿25k出来的测试,算是真正见识到了基础的天花板
如何解决 Iterative 半监督训练 在 ASR 训练中难以落地的问题丨RTC Dev Meetup
go语言泛型在IDE中语法报错
ABP framework Practice Series (III) - domain layer in depth
Analysis of the principle of obxwidget
Oracle技术分享 oracle 19.14升级19.15
[LOJ 6718] nine suns' weakened version (cyclic convolution, arbitrary modulus NTT)
What preparations should be made to develop an app from scratch
Lua语法讲解
763. 划分字母区间
matplotlib多条折线图,点散图
The stc-isp burning program for 51 single chip microcomputer always shows that "the target single chip microcomputer is being detected..." the cold start board does not respond
2020 summary: industrial software development under Internet thinking
WPF 值转换