当前位置:网站首页>Mysql database basic operation -ddl | dark horse programmer
Mysql database basic operation -ddl | dark horse programmer
2022-07-04 19:33:00 【Dark horse programmer official】
MySQL Strong performance , It is one of the most widely used databases at present , With MySQL For learning the prototype, it is also convenient to master other databases later , Now let's give you Give a comprehensive explanation MySQL8.0 New features , From zero foundation to high-level one-stop learning , Combined with actual cases, we can gain something !
▼ MySQL8.0 introduction - Advanced learning notes :( Summary )
- The first 1 speak :SQL Overview and database system introduction | Black horse programmer
- The first 2 speak :MySQL brief introduction 、 Detailed installation steps and use | Black horse programmer
- The first 3 speak :MySQL Common graphics management tools | Black horse programmer
1、DDL explain
DDL(Data Definition Language), Data definition language , The language section includes the following :
- Common operations on Database
- Common operations on table structure
- Modify table structure
2、 Common operations on Database
Common operations on table structure - Create table
- Create a table format
Creating a table is to build an empty table , Specify the name of this table , This table has several columns , What is the name of each column , And the type of data stored in each column .
- data type
Data type refers to specifying the data type for the fields in the table when creating the table , Only if the data meets the type requirements can it be stored , The principle of using data types is : Enough is enough. , Try to use a small range of , Not the big one , This can save more storage space .
- value type
- Date and time type
- String type
3、 Common operations on table structure — Other operating
- Modify the table to add columns
Grammar format
alter table Table name add Name type ( length ) [ constraint ];
Example :
# by student Add a new field to the table as : Is don't dept The type is varchar(20)
ALTER TABLE student ADD `dept` VARCHAR(20);
- Change column name and type
Grammar format
alter table Table name change Old column names New column names type ( length ) constraint ;
Example
# by student Tabular dept Replace field with department varchar(30)
ALTER TABLE student change `dept` department VARCHAR(30);
- Modify table delete column
Grammar format
alter table Table name drop Name ;
Example
# Delete student In the table department This column
ALTER TABLE student DROP department;
- Modify the name of the table
Grammar format
rename table Table name to The new name of the table ;
Example
# Will table student Change its name to stu
rename table `student` to stu;
边栏推荐
- Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading
- Detailed explanation of issues related to SSL certificate renewal
- PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
- BI技巧丨权限轴
- PolyFit软件介绍
- 整理混乱的头文件,我用include what you use
- “只跑一趟”,小区装维任务主动推荐探索
- Hough Transform 霍夫变换原理
- Leetcode fizzbuzz C # answer
- Shell 编程核心技术《三》
猜你喜欢
随机推荐
Wireshark网络抓包
在线文本行固定长度填充工具
sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
876. 链表的中间结点
From automation to digital twins, what can Tupo do?
性能优化之关键渲染路径
Build your own website (15)
YOLOv5s-ShuffleNetV2
Is Guoyuan futures a regular platform? Is it safe to open an account in Guoyuan futures?
长城证券开户安全吗 买股票怎么开户
LeetCode第300场周赛(20220703)
Oracle with as ora-00903: invalid table name multi report error
An example of multi module collaboration based on NCF
Shell programming core technology "I"
每日一题(2022-07-02)——最低加油次数
[发布] 一个测试 WebService 和数据库连接的工具 - DBTest v1.0
The kth largest element in the array
How test engineers "attack the city" (Part I)
测试工程师如何“攻城”(上)
国元期货是正规平台吗?在国元期货开户安全吗?