当前位置:网站首页>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 notesMultiline 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)
);
边栏推荐
- The jar package embedded with SQLite database is deployed by changing directories on the same machine, and the newly added database records are gone
- How to solve the problem of fixed assets management and inventory?
- 计网01-物理层
- How to effectively align team cognition
- Preparing for the Blue Bridge Cup -- bit operation
- 【pytorch】transforms. Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
- Introduction to mt7628k eCos development
- The fixed assets management system enables enterprises to dynamically master assets
- MySQL optimization
- ESP8266 FreeRTOS开发环境搭建
猜你喜欢

How to solve the problem of fixed assets management and inventory?

Jetson nano installs tensorflow GPU and problem solving

JS prototype chain

Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)

2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder

【检测技术课案】简易数显电子秤的设计与制作

Learning practice: comprehensive application of cycle and branch structure (II)

3D打印Arduino 四轴飞行器

Phishing identification app

樹結構---二叉樹2非遞歸遍曆
随机推荐
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
MT7628K eCos开发入门
韦东山板子编译内核问题解决
树结构---二叉树2非递归遍历
PR training notes
MapReduce编程基础
Log4j log framework
I use flask to write the website "one"
Understand shallow replication and deep replication through code examples
Principle and application of single chip microcomputer timer, serial communication and interrupt system
Implementation and application of queue
Installation and use of NoSQL database
[interview brush 101] linked list
Redis -- lattice connects to redis cluster
Learning practice: comprehensive application of cycle and branch structure (II)
ES6 decoupling top-level objects from windows
ES6 const essence and completely immutable implementation (object.free)
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
An overview of the design of royalties and service fees of mainstream NFT market platforms
SQL学习笔记(04)——数据更新、查询操作