当前位置:网站首页>MySQL数据库基础
MySQL数据库基础
2022-06-26 02:41:00 【相知-】
文章目录
MySQL数据库基础
1.操作数据库
1.1显示当前所有数据库
show databases

1.2创建数据库
create database 库名

1.3 使用数据库
use 数据库

1.4 删除数据库
drop database 库名

2.常用数据类型
2.1数值类型
分为整型和浮点型
| 数据类型 | 大小 | 说明 | 对应java中的类型 |
|---|---|---|---|
| bit[(M)] | M指定位数默认为一 | 二进制,M范围从1到64,存储范围是0到2^M-1 | 常用Boolean对应bit,此时默认为1位,即只能存0或1 |
| tinyint | 1字节 | Byte | |
| smallint | 2字节 | Short | |
| int | 4字节 | Integer | |
| bigint | 8字节 | Long | |
| float(M,D) | 4字节 | 单精度,M表示长度,D指定最小位数.会发生精度丢失 | Float |
| double(M,D) | 8字节 | Double | |
| decimal(M,D) | M/D最大值+2 | 双精度,M指定长度,D表示小数点位数。精确数值 | BigDecimal |
| numeric(M,D) | M/D最大值+2 | 和decimal一样 | BigDecimal |
2.2字符串类型
| 数据类型 | 大小 | 说明 | 对应java中的类型 |
|---|---|---|---|
| varchar(size) | 0-65535字节 | 可变长字符串 | String |
| text | 0-65535字节 | 长文本数据 | String |
| mediumtext | 0-16 777 215字节 | 中等长文本数据 | String |
| blob | 0-65535字节 | 二进制形式的长文本数据 | byte[] |
2.3日期类型
| 数据类型 | 大小 | 说明 | 对应java中的类型 |
|---|---|---|---|
| datetime | 8字节 | 范围从1000到9999年,不会进行时区的检索及转换。 | java.util.Date java.sql.Timestamp |
| timestamp | 4字节 | 范围从1970到2038年,自动检索当前时区并进行转换。 | java.util.Date java.sql.Timestamp |
3.表的操作
使用表时得先选中数据库
ues database 库名
3.1 查看所有表
show tables
3.2 查看表结构
desc 表名
3.3 创建表
create table 表名(内置属性名称 数据存储方式 , 内置属性名称 数据存储方式. . . . . .)
3.4 删除表
drop table 表名
注意点!!!
上述提到的删除操作一定要谨慎使用!!!
因为一旦删除,无法恢复,除非提前备份!!!
边栏推荐
- arduino字符串转16进制数 大彩串口屏用。
- R 语言降维的 PCA 与自动编码器
- Matlab| short term load forecasting of power system based on BP neural network
- Additional: brief description of hikaricp connection pool; (I didn't go deep into it, but I had a basic understanding of hikaricp connection pool)
- 文献阅读---优化RNA-seq研究以研究除草剂耐药性(综述)
- Utonmos adheres to the principle of "collection and copyright" to help the high-quality development of traditional culture
- 工业机器人之“慧眼”——机器视觉
- What can Arthas do for you?
- P2483-[template]k short circuit /[sdoi2010] Magic pig college [chairman tree, pile]
- 如何在 ggplot2 中删除网格线(附示例)
猜你喜欢

2021-08-04

Multi surveyor Gongshu Xiao sir_ The solution of using websocket error reporting under working directory

如何提词条

Overview of orb-slam3 paper

在UE内添加控制台工程(Programs)

How to prompt

Classic quotations from "human nature you must not know"

【解决】CMake was unable to find a build program corresponding to “Unix Makefiles“.

Vulhub replicate an ActiveMQ

Redis configuration and optimization of NoSQL
随机推荐
Dreamcamera2 record key prompt sound into video during video recording
Oracle连接问题以及解决方案
How to add a table to a drawing in ggplot2
Interpreting Oracle
Learn Tai Chi Maker - mqtt (IV) server connection operation
Notes on the 3rd harmonyos training in the studio
How to add a regression equation to a plot in R
R language Markov chain Monte Carlo: practical introduction
学习太极创客 — MQTT(五)发布、订阅和取消订阅
UTONMOS:以数字藏品助力华夏文化传承和数字科技发展
数据库查询语句SQL中like、%、-的区别
关于#sql#的问题:SQL问题--账号多地登录的SQL代码
Redis configuration and optimization of NoSQL
ORB-SLAM系列论文翻译笔记
Golang--channel and select
Oracle练习
文献阅读---优化RNA-seq研究以研究除草剂耐药性(综述)
解析少儿编程的多元评价体系
stm32Cubemx:看门狗------独立看门狗和窗口看门狗
使用IDEA画结构图



