当前位置:网站首页>MySQL operation database
MySQL operation database
2022-06-26 06:57:00 【My talented girlfriend】
Create table
- Create data table
create table (if not exists) Table name (
Field , data type constraint condition
---
[ Table constraints ]
)
create table t_goods(
id INT,
t_cate varchar(30),
t_remake varchar(100)
);
- See the table
show tables

- Specify primary key PRIMARY_KEY
Single primary key
create table t_goods(
id INT PRIMARY_KEY,
t_cate varchar(30),
t_remake varchar(100)
);
Single primary key
create table t_goods(
id INT ,
t_cate varchar(30),
t_remake varchar(100),
PRIMARY_KEY(id, t_cate)
);
- Foreign keys
create table t_goods(
id INT ,
t_cate varchar(30),
t_remake varchar(100),
constraint Foreign key name foreign key( Field ) references surface ( Field )
);
- Non empty field
NOT NULL
- The default value is
default
- Auto increment
auto_increment - Specify the storage engine
create table t_goods(
id INT ,
t_cate varchar(30),
t_remake varchar(100)
) engine=InnoDB default charset set utf8mb4 collate utf8mb4_0900_ai_ci;
See the table
describe Correspondence indicates that the corresponding table information can be viewed , You can also use show create table + Table name View the corresponding table structure .
describe --

Modify data sheet
- Modify data table name
alter table A RENAME to B
- Add fields
alter table A add COLUMN Column constraints First/after Field
- Modify field name
alter table Table name CHANGE Field The new fields New field properties
- Change the data type of the field
alter table Table name modify Field Field properties Field location
- Delete field
alter table Table name drop Field
- Modify the engine
alter table Table name ENGINE= Engine name
- Delete foreign key
alter table Table name drop foreign key --
Delete data table
drop table if exists Table name
A temporary table
One more temporary table is created TEMPORARY that will do
create TEMPORARY table if not exists Table name
边栏推荐
- [image enhancement] image defogging based on artificial multiple exposure fusion amef with matlab code
- 寶塔服務器搭建及數據庫遠程連接
- Interviewer: what is the difference between a test plan and a test plan?
- unity之EasyAR使用
- 分析 NFT 项目的 5 个指标
- Shell编程-用户信息管理
- 面试官:测试计划和测试方案有什么区别?
- Distribution operation of D
- Easyar use of unity
- Usage of zip (*arg)
猜你喜欢

MySQL delete in without index

C# Nuget离线缓存包安装

MySQL 数据库的小白安装与登录

【路径规划】基于改进人工势场实现机器人路径规划附matlab代码

Kotlin compose state recovery remembersaveable and remember

PyTorch搭建CNN-LSTM混合模型实现多变量多步长时间序列预测(负荷预测)

“试用期避免被辞退“ 指南攻略

Live broadcast Preview - fire safety instructor training "cloud class" is about to start!

Pagoda server setup and database remote connection

Marketing skills: compared with the advantages of the product, it is more effective to show the use effect to customers
随机推荐
【图像检测】基于形态学实现图像目标尺寸测量系统附matlab代码
Load balancer does not have available server for client: userservice problem solving
The four cores of the browser: Trident, gecko, WebKit, blink
Numpy learning challenge level 4 - numpy array attribute
高德地图使用自定义地图无效问题
[feature extraction] feature selection of target recognition information based on sparse PCA with Matlab source code
数据湖架构之Hudi编译篇
How to open an account in flush? Is it safe to open an account online?
Jasminum plug-in of Zotero document management tool
Global and Chinese silicon carbide monocrystal furnace market survey and future production and marketing demand analysis report 2022-2027
Screen sharing recommendations
Load balancer does not have available server for client: userService问题解决
Guide to "avoid dismissal during probation period"
【元胞自动机】基于元胞自动机实现高速公路收费站交通流问题附matlab代码
[004] [stm32] MDK project configuration and commissioning
Open source demo| you draw and I guess -- make your life more interesting
Go language learning notes 1.1
Development trends and prospects of acrylamide crystallization market in the world and China 2022-2027
【图像分割】基于最大主曲率实现视网膜眼底图像中的血管提取附matlab代码
Installation and login of MySQL database