代码改变世界

mysql操作系统使用

2024-04-18 17:11  加个小鸡腿  阅读(1)  评论(0编辑  收藏  举报

数据库基本增删改查操作

https://blog.csdn.net/weixin_50964512/article/details/124645212

 

1.show databases; //显示当前已有的数据库
2.create database test2; //创建新的数据库
3.use test1; //使用test1数据库,接下来的操作基于该数据库
4.exit; // 退出sql

//数据表增删改查
select * from stu where name='he' and age=10; //查找
insert into stu values('su',9,'0','002'); //新增
delete * from stu where name='he' and sex='1'; //删除
update stu set name='ao' where name='ming'; //修改


//表的创建与删除
create table teacher(name char(8),age int,sex char(5),tel char(11)); //建表
drop table teacher; //删除表

//表的查看
show tables; //显示所有表
show columns from stu; //显示表中所有列
select * from stu; //显示表中所有数据

//表列的增删
alter table stu add score int; //增加列
update stu set score=98 where name='su'; //补充新增列数据
alter table stu drop column phono; //删除列