create tablespace aaa logging datafile 'D:\oracle10\product\10.2.0\oradata\orcl\aaa.dbf' size 1024m autoextend on next 50m maxsize 20480m extent management local注:创建表空间:aaa
create user aaa identified by aaa default tablespace aaa注:创建用户aaa,密码为aaa,表空间为aaa
grant dba,resource,connect to aaa grant select any table to aaa注:授权分为角色授权和功能授权,上一句将dba,resouce,connect三个角色授权给用户aaa,下一句将select any table功能授权给用户aaa
exp aaa/aaa@orcl file=d:/aaa.dump owner=aaa注:将用户aaa用例导出,文件名为aaa.dump
imp aaa/aaa@orcl file=d:/aaa.dump fromuser=aaa touser=aaa注:将aaa.dump文件导入到用户名为aaa用户下
create table test(id varchar2(32),name varchar2(128))
drop table test
rename test to test1
alter table test modify ID VARCHAR2(322) alter table test rename column ID to IDs alter table test add (age varchar2(32)) alter table test drop(id)
注:修改字段类型,修改字段名称,添加字段,删除字段
select account_id,wmsys.wm_concat(address) from c_customer_address group by account_id注将统一账号的多个住址合并显示
insert into test1(id,name) select id,name from test2
exp aaa/aaa@orcl file=d:/1.dump tables=(test)
imp aaa/aaa@orcl file=d:/1.dump tables=(test)
select case a.state when '1' then '试用' when '2' then '转正' else '离职' end "state" from user a
select decode(a.state,'1','试用','2','转正','离职') "state" from user a
select row_number() over(partition by u.department order by u.staff_id) rn, u.staff_id, u.department from sc_login_user u注:将数据按department分组后,按staff_id从小到大排序
select t.staff_id, rownum from (select u.staff_id from sc_login_user u order by u.staff_id) t
select * from (select u.*, rownum rn from (select l.staff_id, l.department from sc_login_user l) u where rownum > 0) where rn < 11
select round(1.2) from dual