use xuexiao;
create table studentInfo(
name varchar(10),
sex char,
age int,
address varchar(20)
);
show tables;
-- 插入操作
-- 值需要按照字端的顺序一一对应,如果插入的值顺序和创建表顺序相同,则字段可以省略
insert into studentInfo(`name` , sex , age ,address) values ("里斯",'男',19,'河南许昌');
insert into studentInfo(sex,address,age,name) values("女",'山东菏泽曹县',28,"笨比");
insert into studentInfo values ("宋江",'男',50,'菏泽曹县');
select * from studentInfo;
-- 修改已创建的表字段默认值
alter table studentInfo change sex sex char default'男';
insert into studentInfo(`name` , sex , age ,address) values ("潘金莲",'女',19,'山东菏泽');
insert into studentInfo(sex,address,age,name) values("女",'山东菏泽曹县',28,"王婆");
insert into studentInfo values ("西门庆",'男',50,'菏泽曹县'); -- 有默认值 如果省略字段,则值需要全写
select * from studentInfo;
create table studentInfo2(
id int auto_increment primary key,
name varchar(10),
sex char,
age int,
address varchar(20)
);
show tables;
insert into studentInfo2(id,`name` , sex , age ,address) values (1,"牛逼",'男',666,'山东菏泽曹县');
insert into studentInfo2(`name` , sex , age ,address) values ("牛逼",'男',666,'山东菏泽曹县');
insert into studentInfo2(id,`name` , sex , age ,address) values (3,"牛逼2",'男',666,'山东菏泽曹县');
insert into studentInfo2(id,`name` , sex , age ,address) values (2,"牛逼3",'男',666,'山东菏泽曹县');
insert into studentInfo2(`name` , sex , age ,address) values ("窝里宝贝",'男',666,'山东菏泽曹县'),
("李逵",'男',30,'山东'),
("宋江",'男',30,'山东郓城'),
("吴用",'男',30,'山东石碣村'),
("鲁智深",'男',30,'山东五台山'),
("公孙胜",'男',30,'山东梁山');
desc studentInfo2;
select * from studentInfo2;
select * from studentInfo;
insert into studentInfo(`name` , sex , age ,address) values ("窝里宝贝",'男',666,'山东菏泽曹县'),
("李逵",'男',30,'山东'),
("宋江",'男',30,'山东郓城'),
("吴用",'男',30,'山东石碣村'),
("鲁智深",'男',30,'山东五台山'),
("公孙胜",'男',30,'山东梁山');
```sql
insert into studentInfo2 values (10,"窝里宝贝",'牛逼',666,'山东菏泽曹县'),
(11,"李逵",'男',30,'山东'),
(12,"宋江",'男',30,'山东郓城'),
(13,"吴用",'男',30,'山东石碣村'),
(14,"鲁智深",'男',30,'山东五台山'),
(15,"公孙胜",'男',30,'山东梁山');
select * from studentInfo2;
-- 修改
-- 修改指定的数据
update studentInfo set name = "潘金莲" where name = "笨比";
-- 没有写条件,则修改全部的数据
update studentInfo set name = "潘金莲";
-- 删除 delete from table where ...
delete from studentInfo2 where name = "牛逼2"; -- 删除符合条件的数据
delete from studentInfo; -- 删除所有数据
-- 销毁数据 不留下日志 ,速度快,无法恢复
truncate table studentInfo2;
```
MySQL:数据库表格内容
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 数据库的元信息: 首先介绍一下数据库的元信息(元数据): 元数据(Metadata)是关于数据的数据。 元数据是描...
- 1. 将excel表格转换成csv格式 将excel表格以csv格式导出,在导出时格式选择CSV UTF-8(逗号...
- 问题描述 其实在之前的开发维护过程中就已经碰到过了这个问题,明明没有人为的drop删除操作,可是某张表却在数据库中...
- 在开发中经常会将现成的execel表格导入到数据库里,否则一个个字段插入填写,太浪费时间,效率很低。本文主要是讲如...