select * from tab where tabtype='TABLE';显示当前用户下的所有表。
select count(*) from table;显示此表的数据行数;
spool c:\tony.txt;日记路径
spool off;关闭记录后可以看到日记文件里的内容。
alter table stu add(classid number(2));添加字段
alter table stu modify(xm varchar2(12));修改字段的长度
alter table stu drop column sal;
drop table stu;
rename student to stu;
alter table student drop column sal; alter table stu add(salary number(7,2));
insert into stu values('A001','张三','男','01-5月-05',10);
insert into stu(xh,xm,sex) values ('A003','JOHN','女');
insert into student(xh,xm,sex,birthday) values ('A004','MARTIN','男',null);
修改
update
update stu set sex='女' where xh='A001';
update student set sex='男',birthday='1980-04-01'where xh='A001';
update student set classid=20 where birthday is null;
delete from stu;drop table student;delete from stu where xh='A001';
truncate table stu;删除表中的所有记录,表结构还在不写日记无法找回记录
select * from stu;
select * from student where classid like '1%';
select * from student where xh like '%A%';
select * from student where xh like 'A%';
select * from student where xh like '%A';
select * from student where xh = 'A%';
select * from student order by birthday;
select * from student order by birthday desc,xh asc; --按birthday 降序 按xh升序(asc/默认)
select * from student where sex='女' or birthday='1999-02-01';
select * from student where sex='女' and birthday='1999-02-01';
select * from student where salary > 20 and xh <> 'B002'; (!=)
oracle
函数的学习
单行函数 返回值只有一个
分组函数 返回值是多条记录
group by
sum
avg
select sysdate from dual;dual哑元素 没有表需要查询的时候
select xm||'-----'||classid from stu;
select 1+1 from dual;
select job,next_date,next_sec,failures,broken from user_jobs;
show parameter job_queue_processes;
alter system set job_queue_processes=5;
select owner,object_name from dba_objects where object_type='DATABASE LINK';
select * from dual@gis3; 判断是否创建
select object_name,object_type
from user_objects
order by object_type; --用户所拥有的对象
select object_name,object_type
from user_objects
WHERE object_type='TABLE'; --用户所拥有的表
另外一种方法
select table_name from user_tables;
select object_name,object_type
from user_objects
WHERE object_type='INDEX'; --用户所拥有的索引
INSERT INTO Store_Information (store_name, Sales, Date)
SELECT store_name, Sales, Date
FROM Sales_Information
WHERE to_char(date,'yyyy')=1998;
exp/imp help=y 显示exp/imp命令下的参数
imp tony/gisinfo file=tony.dmp log=loga show=y full=y
if--then--end if的使用if v_test=1 then begin ..... end; end if;
while--loop--end loop的使用if v_test=1 then begin ........end;end if;
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|