注意:&是sqlplus工具提供的占位符,如果是字符串或日期型要加'符,数值型无需加'符
--使用&占位符,动态输入值,&可以运用在任何一个DML语句中,在values子句中使用,例如:'&ename'和&sal
insert into emp values(&empno,'&ename','&job',&mgr,&hiredate,&sal,&comm,&xxxxxxxx);
--使用&占位符,动态输入值,&可以运用在任何一个DML语句中,在from子句中使用
select * from &table;
--使用&占位符,动态输入值,&可以运用在任何一个DML语句中,在select子句中使用
select empno,ename,&colname from emp;
--使用&占位符,动态输入值,&可以运用在任何一个DML语句中,在where子句中使用
select * from emp where sal > &money;
--使用&占位符,动态输入值,&可以运用在任何一个DML语句中,在group by 和 having子句中使用
select deptno,avg(sal) from emp group by &deptno having avg(sal) > &money;
--依据xxx_emp表结构,创建emp表的结构,但不会插入数据
create table emp as select * from xxx_emp where 1<>1;
--创建emp表,复制xxx_emp表中的结构,同时复制xxx_emp表的所有数据
create table emp as select * from xxx_emp where 1=1;
--将emp截断,再自动创建emp表,truncate table 表名
truncate table emp;
drop table 和 truncate table 和 delete from 区别
drop table
1)属于DDL
2)不可回滚
3)不可带where
4)表内容和结构删除
5)删除速度快
truncate table
1)属于DDL
2)不可回滚
3)不可带where
4)表内容删除
5)删除速度快
delete from
1)属于DML
2)可回滚
3)可带where
4)表结构在,符合条件的表内容删除
5)删除速度慢,需要逐行删除