当前位置:网站首页>Basic operations and basic data types of MySQL database
Basic operations and basic data types of MySQL database
2022-06-25 18:26:00 【Zebra and running】
Catalog
1. Operation of database
(1) Inquire about , Show
show databases;
(2) establish
- Create directly ( If the database already exists , Report errors )
create database Database name character set utf8mb4;( Pay attention to setting the coding format when creating the database , Prevent Chinese miscoding )
- If not created (if Database does not exist establish )
create database if not exists Database name character set utf8mb4;
(3) Delete database
- Direct deletion ( If it doesn't exist, report it wrong ):
drop database Database name ;
- If you have talent, delete it
drop database if exists Database name ;
(4) Use
( appear No database selected error , Enter first / Using a database , To operate on the table )
use Database name ;
2. Common data types
(1). The number class type

- BIT Generally used to express java Inside boolean type
- DECIMAL Inside M Indicates the specified length , Including integer and decimal places
(2). String type

- VARCHAR The corresponding is us java Used in String String of type
- TEXT Used to store, for example, an article 、 Blog 、 Long text data such as websites
(3). The date type

- If your time is to include a time zone , To use TIMESTAMP
Java Inside Date and Timestamp Use

3. The operation of the table
(1). View table structure
grammar :
desc Table name
(2). Create table
grammar :
CREATE TABLE table_name (
field1 datatype,
field2 datatype,
field3 datatype
);
Be careful :
0. Naming rules exam_result, such All lowercase underline delimited naming format
1. Ahead field Is the field name , The following is the data type of the field
2. At the end of each field is a ” , ” separate , however There is no comma after the last field
3. The last brace should end with a semicolon
4. have access to comment Add field description . similar java Notes inside , Be careful comment Put before comma
5. Syntax error may be caused by Chinese symbols Caused by the

(3). Delete table
grammar :
DROP [TEMPORARY] TABLE [IF EXISTS] tbl_name [, tbl_name] ...
eg:

4. summary

Show tables: View all tables
边栏推荐
- connect to address IP: No route to host
- QT using SQLite database
- Install spark + run Scala related projects with commands + crontab scheduled execution
- Detailed explanation of route add command
- IET出席2022世界科技社团发展与治理论坛 为构建国际科技共同体献言献策
- SQL Server real time backup library requirements
- 【深入理解TcaplusDB技术】Tmonitor后台一键安装
- Matlab中图形对象属性gca使用
- 什么是算子?
- Handling method of qstring containing "\u0000" in QT
猜你喜欢
随机推荐
New typereference usage fastjson[easy to understand]
Android Internet of things application development (smart Park) - picture preview interface
LeetCode力扣(剑指offer 26-30)26. 树的子结构 27. 二叉树的镜像 28. 对称的二叉树 29. 顺时针打印矩阵 30. 包含min函数的栈
03 runtime data area overview and threads
C# asp,net core框架传值方式和session使用
Deep learning network model
Part 5:vs2017 build qt5.9.9 development environment
QT中QString包含“\u0000“的处理方式
JVM understanding
【flutter 页面跳转后退如何刷新?】
Optimization of lazyagg query rewriting in parsing data warehouse
What is an operator?
OSError: Unable to open file (truncated file: eof = 254803968, sblock->base_addr = 0, stored_eof = 2
.NET Worker Service 添加 Serilog 日志记录
【深入理解TcaplusDB技术】TcaplusDB运维单据
Class 02 loader subsystem
[how do I refresh the shuttle page after jumping back?]
Dell R530内置热备盘状态变化说明
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc
安装spark + 用命令运行scala相关项目 + crontab定时执行









