标签:color rac miss tab pop 列表 删除语句 art account
数据处理是指使用sql的DDL语句,对表中的数据进行增删改查。
插入操作
INSERT INTO table [(column [, column...])] VALUES (value [, value...]);
向表中插入空值
隐式方式:在列名表中省略该字段
INSERT INTO departments (department_id, department_name ) VALUES (30, ‘Purchasing‘);
显示方式:在values子句中执行null值
INSERT INTO departments VALUES (100, ‘Finance‘, NULL, NULL);
插入指定的值
--记录当前系统的时间和日期 INSERT INTO employees (employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, manager_id, department_id) VALUES (113, ‘Louis‘, ‘Popp‘, ‘LPOPP‘, ‘515.124.4567‘, SYSDATE, ‘AC_ACCOUNT‘, 6900, NULL, 205, 100);
从其他表中拷贝
--不必书写 VALUES 子句。 --子查询中的值列表应与 INSERT 子句中的列名对应 INSERT INTO emp2 SELECT * FROM employees WHERE department_id = 90; INSERT INTO sales_reps(id, name, salary, commission_pct) SELECT employee_id, last_name, salary, commission_pct FROM employees WHERE job_id LIKE ‘%REP%‘;
更新数据
UPDATE table SET column = value [, column = value, ...] [WHERE condition];
在update中使用子查询
--更新 114号员工的工作和工资使其与205号员工 相同 UPDATE employees SET job_id = (SELECT job_id FROM employees WHERE employee_id = 205), salary = (SELECT salary FROM employees WHERE employee_id = 205) WHERE employee_id = 114;
删除语句
DELETE FROM table [WHERE condition];
在delete中使用子查询
--从emp1表中删除dept1部门名称中含Public字符的部门id DELETE FROM emp1 WHERE department_id = (SELECT department_id FROM dept1 WHERE department_name LIKE ‘%Public%‘);
数据库事物
标签:color rac miss tab pop 列表 删除语句 art account
原文地址:https://www.cnblogs.com/hjwq/p/9543918.html