--创建表空间
CREATE TABLESPACE BZ_DATA
DATAFILE'D:\oracle\product\10.2.0\oradata\PRISON\BZ_DATA01.DBF'SIZE 50M;
--创建用户
CREATE USER bzprison
IDENTIFIED BY bzprison
DEFAULT TABLESPACE BZ_DATA;
--授予权限
GRANT dba TO bzprison;
GRANT CONNECT TO bzprison;
GRANT RESOURCE TO bzprison;
--删除用户
DROP USER test CASCADE
--删除表空间
DROP TABLESPACE TEST_LIFT_HEALTH INCLUDING CONTENTSAND DATAFILES
//取消授权
revoke connect,resource from test;
//授予权限
grant connect,resource to test;
select username,default_tablespace fromdba_users;
select username,default_tablespace fromuser_users;
alter user jlyz default tablespace jlyz_test;
select*fromrole_sys_privs;
删除表的某一行
ALTER TABLE alonerewardinfo DROP COLUMNzfids;
查询表中某一列在所有表中被引用的记录
select b.table_name,b.column_name from user_constraints a
inner join user_cons_columns b
on a.constraint_name =b.constraint_name
where a.r_constraint_name='SYS_C0018059'
查看数据库默认的密码管理方式有效期
SELECT * FROM dba_profiles WHERE profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';
ALTER PROFILEDEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED ;
Oracle用户解锁
alter user sw account unlock
oracle导入导出
导入: impjlyz/123456789 file=E:\jlyz.dmp log=E:\jlyz.logfromuser=jlyz touser=jlyz
导出: expjlyz/123456789 file=E:\jlyz.dmp log=E:\log-.log
--1、查看表空间的名称及大小
SELECTt.tablespace_name,round(SUM(bytes / (1024 * 1024)),0) ts_size
FROMdba_tablespaces t,dba_data_files d
WHEREt.tablespace_name = d.tablespace_name
GROUPBY t.tablespace_name;
SELECTtablespace_name,
file_id,
file_name,
round(bytes /(1024 * 1024),0) total_space
FROMdba_data_files
ORDERBY tablespace_name;
--修改表空间大小
alterdatabasedatafile'D:\ORACLDATA\JLYZ_TEST.DBF'resize10240m
--查看表空间使用情况
SELECTUPPER(F.TABLESPACE_NAME)"表空间名",
D.TOT_GROOTTE_MB "表空间大小(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') || '%' "使用比",
F.TOTAL_BYTES "空闲空间(M)",
F.MAX_BYTES "最大块(M)"
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BYTES) / (1024 * 1024),2) TOTAL_BYTES,
ROUND(MAX(BYTES) / (1024 * 1024),2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUPBY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
ROUND(SUM(DD.BYTES) / (1024 * 1024),2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUPBY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDERBY1;
原文链接:https://www.f2er.com/oracle/211639.html