e 行限定条件;
? ? ? ? ? ? 限定条件 如 : name那一列为Kay的 全部删除
? ? ? ? delete from emp where name = 'Kay';
?
? ? //删除表的数据
?
? ? ? ? truncate table 表名; ? ?//相当于删除表和数据然后重建表.
?
gai :?
//改 :
?
? ? //更改表名字 :?
? ? ? ??
? ? ? ? rename 旧表名 to 新表名;
?
? ? //切换当前用户 :?
?
? ? ? ? connect 用户名/密码@网络服务器(orcl);
?
? ? //更改字段(列)的类型或者名字 :?
?
? ? ? ? alter table 表名 modify (属性 类型);
? ? ? ? ? ? 如 : alter table student modify (sex number(1));
?
? ? //更改列上的值 :?
?
? ? ? ? update 表名 set 列名=列值改变量(+-*/), 字段2,字段3, where 行限定条件;
? ? ? ? ? ? 如 : ?update 表名 set 列名='值' where id='B0002'(限定条件,id为B0002的 都会把前面指定的属性的值更改);
?
? ? ? ? ? ? 1 ?update 表名 set (job,sal,comm/*列名*/)= (select job,sal,comm from/*查看三个列*/ emp where ename='clock'/*ename为'clock'*/) where ename ="scott"/*enamel为'Scott'的*/;//
?
? ? ? ? ? ? 1 --> update 表名 set (job,sal,comm)= (select job,sal,comm from emp where ename='clock') where ename ="scott";//先查ename为'clock'的(区分大小写),获取job,sal,comm,对应的值,再把这些值更改(赋值)到 ename为'scott' 对应的job,sal,comm的列值中
?
cha :?
//查 :
?
? ? //查看当前登陆用户 :?
? ? ? ??
? ? ? ? show user;
?
? ? //查看当前用户下所有的表单 :
?
? ? ? ? select * from user_tables;
?
? ? //查看你能管理的所有用户 :?
? ??
? ? ? ? select * from all_users;?
?
?
? ? ? ? select * from dba_users;//前提是 你登陆的是sys或system号(用户);
?
?
? ? ? ? select 表名 from dba_tables;//数据库所有表,包括系统表,前提是 你登陆的是sys或system号(用户);
?
? ? //查看表头 :?
?
? ? ? ? desc 表名;//查看表头(也就是列)
where_and :?
? ? //筛选数据,多选, 查询空值 (后面只能用null 这是一个语句)
?
? ? ? ? select * from 表名 where 列(属性) is not null;//不为空的
? ? ? ? select * from 表名 where 列(属性) is ?null;//为空的
? ? ? ? //查看某列的属性为空(不为空)的所有数据
?
where_and_or :?
? ? ? ? or : 或者 或
? ? ? ? >,>=,<,<=,= : 大于,大于等于,小于,小于等于,等于;
? ? select * from 表 where (列 >/*>/=(大于或等于或小于)*/值 or 列 = 值) and 列 like 'j%';//?
? ? ? ? 如 : select * from emp where (id>20 or age = 19)and name like 'j%';//查看emp表中 id列的值大于20或age列的值为19的 并且 name列的值以j开头的所有的行的属性?
?
? ? //指定查询 :?
?
? ? ? ? select 列限定(就是列) from 表限定(就是表) where 行限定(就是一行中某一个属性); ? ?//数据限定条件区分大小写,java限定大小写,select什么就输出什么
? ? ? ? 1 select id,name from emp where job = 'CLERK';//查看 job(列)为'CLERK'的哪一行(或多行)的id值和name值
?
? ? ? ? 2 select * from 表 where 列(列限定/表头) < 7800 and 列>2000;//(*就代表输出所有列的属性) 输出 某表中 某列上的值小于7800 且 某列的值大于2000 的所有列的属性
?
? ? //查询特定列 :?
?
? ? ? ? select 列1,列2,列3... from 表 where 行限定;(行限定 : 就是某一列上的值 )
? ? ? ? 如 :
? ? ? ? ? ? select id,name from emp where sex = '男';//查看性别为'男'的 id和name属性
?
distinct :?
? ? //单列查询 : (去除重复)
?
? ? ? ? select distinct 列限定 from 表名 where 行限定(z只能单行查询)
? ??
like :?
?
? ? //匹配字符查询 : (就是筛选)
?
? ? ? ? % : 匹配多个字符 有两个意思 1 可以匹配任意位字符
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2 可以匹配每位上面的任意字符
? ? ? ? _ : 匹配一个字符
?
? ? ? ?1 select * from 表名 where 限定列 like ''%k%';//查看某个表中某个列的属性值,包含k的所有的行的属性
?
? ? ? ?2 ?select * from 表名 where 限定列 like '__k%';//两个下划线(代表两位) 查看某个表的某个列的值, 值的第三位是k的所有的行的属性
?
in :?
?
? ? //枚举查询
?
? ? ? ? select * from 表 where 列 in(值(1),值(2),值(3)...);//输出某表中 某列的值为 1 或者 2 或者 3 的所有的行的属性
? ? ? ? select * from emp id in(22,42,66);//输出emp表中 id 列的值为22或42或66的所有的行的属性
?
? ? in_and :?
? ? ? ? >,>=,<,<=,= : 大于,大于等于,小于,小于等于,等于;
? ? ? ? select * from 表 where 列 in(值(1),值(2),值(3)) and 列 >/=(大于或小于或等于) 值;
? ? ? ? 如 : select * from emp where id in(22,33,44) and age >19;//查看emp表中 id列的值为22或33或44 并且 age(年龄)列的值 大于19的 所有的行的属性?
?
? ? //对查看到值进行运算 :?
? ? ? ? ? ??
? ? ? ? ? ? +*-/ : 运算查看的值(查是查 算是算 不是一回事,并不会改变表单里面的值,只是更改了输出方式)//但是 该列的数据类型必须是数字(number类型)
? ? ? ? ? ? select 列+20 '年终奖' , name from 表名;
? ? ? ? ? ? select 列+(加/减/乘/除)20(加减乘