黑马程序员技术交流社区

标题: 数据库操作 [打印本页]

作者: 小新2    时间: 2018-3-15 20:10
标题: 数据库操作
1创建表
create table 表名(字段名 类型 约束,字段名 类型 约束...)

例:创建学生表,字段要求如下:
姓名(长度为10), 年龄
create table students(name varchar(10),age int unsigned)

2删除表
格式一:drop table 表名
格式二:drop table if exists 表名

例:删除学生表
drop table students或drop table if exists students

3简单查询
select * from 表名
例:查询所有学生数据
select * from students

4添加数据
例:插入一个学生,设置所有字段的信息
insert into students values(0,'亚瑟',22,177.56)

5修改
例:修改id为5的学生数据,姓名改为 狄仁杰,年龄改为 20
update students set name='狄仁杰',age=20 where id=5

作者: hmhm123    时间: 2018-4-24 22:50
赞一个
作者: 萌萌哒狗贼叔叔    时间: 2018-6-3 09:06

赞一个sadas;ldj;adsjsa;fjas;




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2