DML_数据操纵语言
DML语法:
/** insert 添加数据* insert into tableName values('所有数据')* insert into tableName(部分列名 - 必须包含所有非空列) values('部分列数据')*/insert into course values('C01', 'JavaSE', 100);insert into course values('C02', 'JavaSE', '');insert into course(courseno, coursename) values('C03', 'Oracle');--insert into course(courseno) values('C04'); -- wrong-- char固定长度insert into school values('S8372222', '中国大学');insert into school values('S8372223', '中国三美大学');insert into faculty values('01', '计算机系', 'S8372223');insert into faculty values('02', '土木工程系', 'S8372223');insert into faculty values('03', '计算机系', 'S8372222');insert into faculty values('04', '土木工程系', 'S8372222');insert into major values('M0001', '软件工程', '01');insert into major values('M0002', '网络工程', '01');insert into major values('M0003', '建筑', '02');insert into major values('M0004', '建筑美学', '02');insert into major values('M0005', '软件工程', '03');insert into major values('M0006', '网络工程', '03');insert into major values('M0007', '建筑', '04');insert into major values('M0008', '建筑美学', '04');insert into studentcard values('S87232', '中国大学', '张思思', '11级软件04班');-- insert添加 FK引入PK的值 有值直接使用 无值先insert数据再插入insert into student values('S0001', '张思思', '', null, null, '无锡', '', 'M0008', 'S87232');insert into studentcard values('S87233', '中国大学', '张珊珊', '11级软件04班');insert into student values('S0002', '张珊珊', '女', 20, null, '北京', '68', 'M0005', 'S87233');
update 注意点:update tableName set 列名 = value, ... where ...
- update tableName set 列名 = value, ... where ...
-- 部分数据更新 where条件update student set age = 20;-- 某一条 PK UKselect * from student; -- PK UKupdate student set name = '张三散', sex = '男' where stuNo = 'S9999';select * from course;update course set hour = 200 where courseno = 'C05';用户登录update users set password = '123456' where userName = 'admin';update users set info = 'newInfo' where userName = 'admin';中国大学 - 中国社会大学update school set schoolName = '中国社会大学' where schoolname = '中国大学';-- 某几条数据 FK-- 教学部 所有员工 奖金+200update employee set bonus = bonus + 200where deptNo = (select deptNo from dept where deptName = '教学部');-- 软件工程 专业学生 总+10update student set score = score + 10where majorno in (select majorNo from major where name = '软件工程');-- 计算机部 学生总分 + 5update student set score = score + 5where unionno = (select unionno from studentunion where unionname = '计算机部');-- 所有员工工资 + 500update employee set salary = salary + 500;
delete from tableName where ...-- 删除所有数据delete from course;-- 删除某一条数据 PK UKselect * from course;delete from course where courseno = 'C05';某员工辞职delete from employee where empNo = 'empNo';select * from student;delete from student where stuNo = 'S9008';某商品下架-- 中国大学 计算机系 撤销-- 删除数据 数据FK被引用--学生update student set majorno = 'M0007'where majorno in (select majorno from majorwhere facultyno =(select facultyno from facultywhere fname = '计算机系' and schoolcode= (select schoolcode from schoolwhere schoolname = '中国大学')));--专业delete from major where facultyno = (select facultyno from facultywhere fname = '计算机系' and schoolcode= (select schoolcode from schoolwhere schoolname = '中国大学'));--院系delete from faculty where fname = '计算机系'and schoolcode = (select schoolcode from schoolwhere schoolname = '中国大学');-- 同时删除课程C01 JavaSE 100 开设有问题delete from studentcourse where courseno = 'C01';delete from course where courseno = 'C01';BBS论坛帖子 - 回复 帖子内容有严重问题delete from reply where postId = '0001';delete from post where postId = '0001';-- 更新 再删除-- 大学毕业 学生证失效update student set cardno = null;delete from studentcard;
DML_数据操纵语言的更多相关文章
- DML(数据操纵语言)
1.概念(C) 数据操纵语言 DML (Data Manipulation Langua)是SQL语言的一个分类,用于对表的内容或者说数据进行增.删.改.查等操作. 通过以下几个关键字实现: SELE ...
- 数据库原理及应用-SQL数据操纵语言(Data Manipulation Language)和嵌入式SQL&存储过程
2018-02-19 18:03:54 一.数据操纵语言(Data Manipulation Language) 数据操纵语言是指插入,删除和更新语言. 二.视图(View) 数据库三级模式,两级映射 ...
- (让你提前知道软件开发33):数据操纵语言(DML)
文章2部分 数据库SQL语言 数据操纵语言(DML) 数据操纵语言(Data Manipulation Language,DML)包含insert.delete和update语句,用于增.删.改数据. ...
- MySQL之数据操纵语言(DML)
数据操纵语言(DML) 数据操纵语(Data Manipulation Language),简称DML. DML主要有四个常用功能. 增 删 改 查 insert delete update sele ...
- 30442数据操纵语言DML
5.5 SQL的数据操纵功能 5.5.1 数据插入 使用CREATE语句创建的数据表还只是一个“空壳”,表中没有任何数据.利用SQL语言提供的INSERT语句可以完成向数据表插入数据的任务. INSE ...
- DML 数据操纵语言
1.INSERT(插入)语言结构 INSERT INTO table(表名)(要插入的列名) VALUES(要插入的具体值): table:要插入数据的表的表名 column[,column]:表中要 ...
- oracle数据操纵语言(DML)data manipulation language
数据库操纵语言(DML)用于查询和操纵模式对象中的数据,它不隐式地提交当前事务. SELECTINSERTUPDATEDELETECALLEXPLAIN PLANLOCK TABLEMERGE使用算术 ...
- SQL语言学习-数据操纵语言
一般而言,数据库中数据的生命周期包括数据插入以及更新.数据删除3个阶段.首先需要用户或者系统将数据插入表.然后,对数据的使用,包括数据的检索以及数据的更新.最后,如果数据已经没有使用价值,则将数据删除 ...
- DML语言(数据操纵语言)
#DML语言/*数据操作语言:插入:insert修改:update删除:delete */ #一.插入语句#方式一:经典的插入/*语法:insert into 表名(列名,...) values(值1 ...
随机推荐
- WIN8重见开始菜单
从win7进入win8感觉不适应,做为一个程序开发人员,更觉得不爽,因此想着如何恢复开始菜单,查了很多文章终于找到方法 首先,在桌面版Windows 8启动资源管理器,单击工具栏上的“查看”选项卡后, ...
- 细说linux挂载——mount,及其他……
http://forum.ubuntu.org.cn/viewtopic.php?t=257333
- Eclipse常用快捷键集合
一.通用快捷键 [ALT+/] 此快捷键为用户编辑的神级好帮手,能为用户提供内容的辅助,不要为记不全方法和属性名称犯愁下 [Ctrl+T] 搜索当前接口的实现类 [Ctrl+O] 显示类中方法和 ...
- JSON 日期格式问题 /Date(1325696521000)/
json返回的日期格式/Date(1325696521000)/,怎么办? Controller返回的是JsonResult对象就会导致出现这样的格式: /Date(1325696521000)/ p ...
- DataTables warning (table id = 'myTable'): Requested unknown parameter '0' from the data source for row 0
第一种方式:不用在js里设置列Html: <table id="myTable"> <thead> <tr> <th>Title-1 ...
- Captcha生成及使用
@Controller @RequestMapping("/PictureCheckCode") public class ServletController { @Request ...
- linux开机启动配置
vim /etc/rc.d/rc.local 把命令写在这里
- CF A and B and Chess
A and B and Chess time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 设计包含min函数的栈
stack<pair<int, int>> sta; void push(int x) { int min_i; if(sta.empty()) { min_i = x; } ...
- PHP面向对象:类型提示
PHP是弱类型语言,向方法传递参数时候也不太区分类型.这样的使用会引起很多的问题,PHP开发者认为,这些问题应该是由代码书写者在书写代码时进行检验以避免. 没有类型提示很危险 下面的代码可能会出现问题 ...