当前位置:网站首页>数据库黑马笔记DDL
数据库黑马笔记DDL
2022-07-13 17:55:00 【springxing星】
每日一句:
刀在石上磨,刀越来越快,石越来越薄。
数据库:
DDL:操作数据库,数据库表等
DML:对表中的数据进行增删改
DQL:对表中的数据进行查询
DCL:对数据库进行权限管理
DDL---操作数据库(全部大写)
①查询:show databases;
②创建:create database 数据库名称;
创建数据库(判断如果不存在则创建):create database if not exists 数据库名称;
③删除数据库:drop database 数据库名称;
删除数据库(判断如果存在久删除):create database if exists 数据库名称;
④使用数据库:
查看当前使用的数据库:select database();
使用数据库:use 数据库名称;
数据类型(①数值 ②日期 ③字符串)
主要用的多的:
①int:大整数值
例: age int,
②double:双精度浮点数值
例:score double(总长度,小数点后保留的位数)
③date 日期值
例:birthday date
④char 字长字符串 表示固定长度的字符串,没有满足长度就会默认用空格填充
优点是:存储性能高,缺点是浪费空间
varchar 变长字符串
优点是节约空间,缺点是存储性能低
DDL---操作表
①查询表
(1)查询当前数据库下的所有表名称(要先use到当前数据库)
show tables;
(2)查询表结构(看具体一个表)
desc 表名称;
②创建表
create table 表名称(
字段名1 数据类型1,
字段名2 数据类型2,
.......
字段名n 数据类型n
);
③删除表:drop table 表名;
判断删除表是否存在:drop table if exists 表名;
④修改表
(1)修改表名:alter table 表名 rename to 新表名;
(2)添加一列: alter table 表名 add 列名 数据类型;
(3)修改数据类型: alter table 表名 modify 列名 新数据类型;
(4)修改列名和数据类型:alter table 表名 change 列名 新列名 新数据类型;
(5)删除列:alter table 表名 drop 列名;
边栏推荐
- stm32学习(入门)
- Embedded software development stm32f407 racing lantern standard library version
- SQL basics 1
- Chapter II use of syn6288 speech synthesis module
- [Go语言入门] 10 Go语言Map详解
- Matlab warning: name does not exist or is not a directory
- ROS communication mechanism
- Holiday study plan from June 24, 2022 to August 26, 2022
- 寶塔面板在同一服務器下創建多個端口部署項目(輕量應用服務器一鍵部署網站、博客、GltLab完整版)
- 梯度下降法的向量化
猜你喜欢

史上最快上手Redis(附加连接云服务器上的Redis)
![[Go语言入门] 08 Go语言数组](/img/f6/6e113d9090a0c58a68b2e379e64500.png)
[Go语言入门] 08 Go语言数组

Embedded software development stm32f407 buzzer standard library version

Promise --- synchronize? Asynchronous?

Holiday study plan from June 24, 2022 to August 26, 2022

Getting started with spark
![[Multisim] problems that must be paid attention to when using ne5532p series operational amplifier simulation](/img/16/496c26d87407cc8e67182f209fe70b.png)
[Multisim] problems that must be paid attention to when using ne5532p series operational amplifier simulation

Pyopencv basic operation guide

ArkUI路由跳转概览

树莓派系统镜像的下载和烧录
随机推荐
寶塔面板在同一服務器下創建多個端口部署項目(輕量應用服務器一鍵部署網站、博客、GltLab完整版)
Swagger快速入门(接口文档)
Keil5 shortcut key
How to make electronic signature transparent
Train yolov3 on colab (I)
Blue Bridge Cup embedded Hal library Tim_ BASE
[go language introduction] 13 go language interface details
史上最快上手Redis(附加连接云服务器上的Redis)
Notice on the completion of Internet of things
[introduction to go language] 04 go language operator
01kNN_ Regression
Comment utiliser l'oscilloscope virtuel dans Keil 5 pour la simulation logicielle
[Go语言入门] 14 Go语言goroutine和通道详解
01-kNN
Use MessageBox to realize window confession applet (with source code)
vscode插件安装介绍
Obsidian third-party plug-in failed to load
RAC 心跳异常(ipReamsfails)的处理记录和分析
记录:VsCode通过ssh连接阿里云
vant Weapp组件库中 自定义修改van-button 按钮宽高大小