--查看所有用户
select * from dba_users d order by d.username
--查看所有表空间
select tablespace_name from user_tablespaces;
--查看用户下所有的表
select * from user_tables;
--查询当前用户的表空间名称
select default_tablespace from dba_users where username='jeesite'
--删除用户
drop user jeesite cascade
--删除表空间
DROP TABLESPACE JEESITE_DATA INCLUDING CONTENTS AND DATAFILES;
--建立表空间
create tablespace jeesite_data
logging
datafile 'C:\APP\ADMINISTRATOR\ORADATA\ORCL\JEESITE_DATA.DBF'
size 1024m
autoextend on
next 1024m
extent management local;
--建立用户、授权
create user jeesite
identified by jeesite
quota unlimited on users;
grant connect,resource,create session,select any table,
create any view,create any table,create any index,
drop any table,drop any view,drop any index
to jeesite;
-- 提示 oracle.jdbc.xa.OracleXAResource.recover 错误需要授权:
grant select on sys.dba_pending_transactions to jeesite;
grant select on sys.pending_trans$ to jeesite;
grant select on sys.dba_2pc_pending to jeesite;
grant execute on sys.dbms_system to jeesite;
--修改用户默认表空间
alter database default tablespace jeesite_data
--1、查看表空间的名称及大小
SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size
FROM dba_tablespaces t, dba_data_files d
WHERE t.tablespace_name = d.tablespace_name
GROUP BY t.tablespace_name;
--2、查看表空间物理文件的名称及大小
SELECT tablespace_name,
file_id,
file_name,
round(bytes / (1024 * 1024), 0) total_space
FROM dba_data_files
ORDER BY tablespace_name;
--6、查看表空间的使用情况
SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name
FROM dba_free_space
GROUP BY tablespace_name;
SELECT a.tablespace_name,
a.bytes total,
b.bytes used,
c.bytes free,
(b.bytes * 100) / a.bytes "% USED ",
(c.bytes * 100) / a.bytes "% FREE "
FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
WHERE a.tablespace_name = b.tablespace_name
AND a.tablespace_name = c.tablespace_name;
--导入数据日期格式错误(原因是中文环境)
SELECT * FROM v$parameter WHERE name = 'nls_date_language';
ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN';
最近常用的Oracle的SQL
猜你喜欢
转载自blog.csdn.net/qq_37725560/article/details/91490802
今日推荐
周排行