当前位置:网站首页>数据库操作基础语句
数据库操作基础语句
2022-07-27 09:59:00 【项羽-韩】
书接上回,在了解了部署、链接mysql之后,想要编写代码,需要事先了解数据库操作的基础语句,下面开始:
mysql -u xiaochun -p
输入密码,登陆;
show databases;
显示所有数据库,没有【spring】数据库的话,创建一个;
use spring;
使用【spring】数据库;
mysql> create table user(id integer primary key auto_increment,
-> name varchar(60) not null,
-> age integer(3),
-> sex varchar(1));
创建表,并初始化字段;
show tables;
查看该库下,所有的表;
alter table user rename to student;
修改表名【user】为【student】;
desc student;
查看表结构;
drop table user;
insert into student values(1,'xiaoming',18,'1');
添加数据;
insert into student(id,name,age,sex) values(2,'xiaozhang',16,'2');
添加数据;
insert into student(id,name,age,sex) values(null,'xiaozhang',16,'2');
添加数据,当id传入null时,主键自增;
select * from student;
查看数据;
select name,age from student where sex='2' and age<19 order by name;
条件查询排序;
删除名为【user】的表;
附上一张外网查询的截图:

准备工作完毕,下一章介绍 springboot 。
边栏推荐
猜你喜欢

Practice and exploration of overseas site Seata of ant group

并发之线程状态转换

SE(Squeeze and Excitation)模块的理解以及代码实现

数据分析如何解决商业问题?这里有份超详细攻略

Anaconda安装(非常详细)

女粉想要找男朋友,竟是为了...

直播倒计时 3 天|SOFAChannel#29 基于 P2P 的文件和镜像加速系统 Dragonfly

Switch port mirroring Configuration Guide

There is no CUDA option in vs2019+cuda11.1 new project

Food safety | is sugar free really sugar free? These truths need to be known
随机推荐
Cannot start after installing MySQL 5.7.27 in CentOS 7? (Language bash)
WGAN、WGAN-GP、BigGAN
Open3d library installation, CONDA common instructions, importing open3d times this error solving environment: failed with initial frozen solve Retrying w
Snowflake vs. Databricks谁更胜一筹?2022年最新战报
Simple use of tflite
Matlab绘制不同阻尼下的系统响应
samba服务器
Leetcode.565. array nesting____ Violent dfs- > pruning dfs- > in situ modification
使用 LSM-Tree 思想基于.NET 6.0 C# 写个 KV 数据库(案例版)
视觉SLAM十四讲笔记(一):第一讲+第二讲
Shell integrated application cases, archiving files, sending messages
Concurrent Park and unpark description
并发之park与unpark说明
matlab-绘制分叉与混沌分支图
hdu5288(OO’s Sequence)
Matlab底层源代码实现图像的中值滤波(用于消除图像上一些杂点)
Food safety | the more you eat junk food, the more you want to eat it? Please keep this common food calorimeter
Example of ICP registration for PCL
线代004
How to create a.Net image with diagnostic tools