当前位置:网站首页>SQL learning notes (02) - database table operation
SQL learning notes (02) - database table operation
2022-07-01 09:25:00 【Yuxuan godlike】
The contents of the catalog
One 、Mysql Database operation
- Create database
Format :create database Database name ;
create database student;
- Delete database
Format :drop database Database name ;
drop database student;
- Look directly at the existing database :
show databases;
Two 、Mysql Data type in
1. Integer and decimal
Integer types :int
Decimal type :decimal Format :decimal( Total length , Decimal places )
decimal(5,2) The total length of data required to be transmitted is 5 position , The decimal places are 2 position
2. Date and time type
datetime YYYY-MM-DD HH:MM:SS
date YYYY-MM-DD
3. String type
char( Length of string ) Fixed length
varchar( Length of string ) Lengthening
for example :
full name char(10) tom–> Occupy 3 Characters And then there were 7 The space of characters will not be released , The system will fill with blanks
full name varchar(10) tom–> Occupy 3 Characters And then there were 7 Characters were released
3、 ... and 、 Create and delete tables
Create table syntax format
create table Table name (
Name 1 data type ,
Name 2 data type ,
Name 3 data type
);
Comments in the database
Single-line comments :-- Content of notes
Multiline comment :/* Content of notes */
Switch database
Format :use Database name
Open the table : Check whether there is data stored in the table
Design table : View table structure
Delete table
Delete single table :drop table Table name ;
Delete multiple tables :drop table Table name 1, Table name 2;
Four 、 Modify table structure
Add columns
alter table Table name add Column name data type ;
Delete column
alter table Table name drop Name ;
Change the data type of the column
alter table Table name modify Name New data types ;
Change column names
alter table Table name change Old column names New column names data type ;
Display table structure
desc Table name ;
Check constraints check( Limit the range of values in the column )
create table Table name (
Name 1 data type check( constraint condition )
);
give an example : In the table id The value range is 5-20
create table students(
id int check(id>5 and id<20)
);
边栏推荐
猜你喜欢
Preparing for the Blue Bridge Cup -- bit operation
Imitation of Baidu search results top navigation bar effect
MapReduce programming basics
dsPIC30F6014a LCD 方块显示
How to solve the problem of fixed assets management and inventory?
Design and manufacture of simple digital display electronic scale
MySQL optimization
Error org apache. catalina. core. StandardContext. FilterStart start filter exception
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
队列的实现和应用
随机推荐
Network counting 01 physical layer
Can diffusion models be regarded as an autoencoder?
[ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
Log4j log framework
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
Serialization, listening, custom annotation
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
Latex插入的eps图片模糊解决方法
MapReduce programming basics
JS variable lifting
OSPF - virtual link details (including configuration commands)
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云和Arduino的化学环境系统检测,支持钉钉机器人告警
Imitation of Baidu search results top navigation bar effect
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()
Preparing for the Blue Bridge Cup -- bit operation
Analysis and solution of JS this loss
SQL学习笔记(02)——数据库表操作
Exception handling of classes in C #
dsPIC30F6014a LCD 方块显示