-- 创建表空间
create tablespace tbs_qy86
datafile 'E:\tablespace\qy86.dbf'--该表空间默认使用的文件
size 100m
autoextend on next 10m maxsize unlimited -- 100m用完,自动增长十兆,最大无上限
create tablespace tbs_qy86b
datafile 'E:\tablespace\qy86b.dbf'--该表空间默认使用的文件
size 100m
autoextend on next 10m maxsize unlimited -- 100m用完,自动增长十兆,最大无上限
--删除表结构
drop tablespace tbs_qy86b including contents and datafiles;
-- 创建用户
create user user_qy86
identified by admin --设置密码
default tablespace tbs_qy86 -- 默认使用表空间
--更新用户
-- 更新锁定状态
alter user user_qy86 account lock; --锁定该用户
alter user user_qy86 account unlock;
-- 用户授权
-- connect 链接权限 有登录,部分DML
-- resource 全部DML和部分DDL权限
-- dba 和system权限一样,可以对其他用户进行添加删除
--赋权
grant connect,resource to user_qy86 --给用户赋予链接权限和可以DML操作
grant resource to user_qy86
-- 取消权限
revoke connect,resource from user_qy86
--跟新用户密码
alter user user_qy86 identified by admin
-------------------------------------------------------------
-- oracle 函数
-- concat
select concat(concat('Hello','World') ,'!!')from dual;
select '你好'||'很好'||'!!!' from dual
select concat('aas','asdf'||'asdf') from dual;
-- initcap首字母大写
select initcap('hello world') from dual
select initcap(concat('job','-'||ename))as je,job,ename from emp
-- upper lower
select upper('asd') from dual; --全变大写
select lower('ASD') from dual;
-- instr (相当于 indexof()) 第一次出现的位置,从1开始,不存在为0
select instr('asdfa','a') from dual
select instr('asdfa','a',3) from dual --从3开始之后出现a的位置
-- substr 截取字符串
select substr('asdfasd',2,4) from dual
select substr('26332632633',3) from dual
-- 'fa,ddd,fa'
select substr('fa,ddd,fa',
instr('fa,ddd,fa',',',1,1)+1,
instr('fa,ddd,fa',',',1,2)-(instr('fa,ddd,fa',',',1,1)+1)
)from dual
-- rpad lpad 补齐
select rpad('aa',5,'名aa')from dual
select lpad('aa',5,'mign')from dual
-- dbms_random.value随机数
select trunc((dbms_random.value*1000),0)from dual
select 'order'||lpad(trunc(dbms_random.value*1000),8,0)from dual
select 'order'||lpad(trunc(seq_tb_b.nextval),8,0)from dual
-- ltrim rtrim 去空格
select rtrim(' a a')from dual
select length(' ')from dual
select length(' asdf '),length(trim(' 'from ' asdf ')),trim(' 'from ' asdf ')from dual
-- replace 替换
select replace('asdfasfd','a','o')from dual