first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
28
数据库/oracle/oracle创建数据库
Normal file
28
数据库/oracle/oracle创建数据库
Normal file
|
@ -0,0 +1,28 @@
|
|||
<<<<<<< HEAD
|
||||
|
||||
创建数据库文件
|
||||
CREATE TABLESPACE insurance LOGGING DATAFILE '/data/database/orcl/insurance.dbf' SIZE 100M AUTOEXTEND ON NEXT 32M MAXSIZE 500M EXTENT MANAGEMENT LOCAL;
|
||||
|
||||
创建数据库临时文件
|
||||
create temporary TABLESPACE insurance_temp tempfile '/data/database/orcl/insurance_temp.dbf' SIZE 100M AUTOEXTEND ON NEXT 32M MAXSIZE 500M EXTENT MANAGEMENT LOCAL;
|
||||
|
||||
创建用户与上述两个文件形成映射关系
|
||||
CREATE USER insurance IDENTIFIED BY "Insur@nce#20" DEFAULT TABLESPACE insurance TEMPORARY TABLESPACE insurance_temp;
|
||||
|
||||
添加用户权限
|
||||
grant connect,resource,dba to insurance;
|
||||
=======
|
||||
|
||||
创建数据库文件
|
||||
CREATE TABLESPACE insurance LOGGING DATAFILE '/data/database/orcl/insurance.dbf' SIZE 100M AUTOEXTEND ON NEXT 32M MAXSIZE 500M EXTENT MANAGEMENT LOCAL;
|
||||
|
||||
创建数据库临时文件
|
||||
create temporary TABLESPACE insurance_temp tempfile '/data/database/orcl/insurance_temp.dbf' SIZE 100M AUTOEXTEND ON NEXT 32M MAXSIZE 500M EXTENT MANAGEMENT LOCAL;
|
||||
|
||||
创建用户与上述两个文件形成映射关系
|
||||
CREATE USER insurance IDENTIFIED BY "Insur@nce#20" DEFAULT TABLESPACE insurance TEMPORARY TABLESPACE insurance_temp;
|
||||
|
||||
添加用户权限
|
||||
grant connect,resource,dba to insurance;
|
||||
>>>>>>> 28bec05... 20200611
|
||||
grant create session to insurance;
|
57
数据库/oracle/oracle启动与登陆.txt
Normal file
57
数据库/oracle/oracle启动与登陆.txt
Normal file
|
@ -0,0 +1,57 @@
|
|||
1.进入到sqlplus启动实例
|
||||
[oracle@redhat ~]$ su - oracle --“切换到oracle用户”
|
||||
Password:
|
||||
[oracle@redhat ~]$ lsnrctl start --“打开监听”
|
||||
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:06:40
|
||||
Copyright (c) 1991, 2005, Oracle. All rights reserved.
|
||||
Starting /home/oracle/product/10g/bin/tnslsnr: please wait...
|
||||
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
|
||||
System parameter file is /home/oracle/product/10g/network/admin/listener.ora
|
||||
Log messages written to /home/oracle/product/10g/network/log/listener.log
|
||||
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
|
||||
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
|
||||
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
|
||||
STATUS of the LISTENER
|
||||
------------------------
|
||||
Alias LISTENER
|
||||
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
|
||||
Start Date 14-OCT-2009 19:06:40
|
||||
Uptime 0 days 0 hr. 0 min. 0 sec
|
||||
Trace Level off
|
||||
Security ON: Local OS Authentication
|
||||
SNMP OFF
|
||||
Listener Parameter File /home/oracle/product/10g/network/admin/listener.ora
|
||||
Listener Log File /home/oracle/product/10g/network/log/listener.log
|
||||
Listening Endpoints Summary...
|
||||
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
|
||||
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
|
||||
Services Summary...
|
||||
Service "PLSExtProc" has 1 instance(s).
|
||||
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
|
||||
The command completed successfully
|
||||
[oracle@redhat ~]$ sqlplus /nolog --“进入到sqlplus”
|
||||
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Oct 14 19:06:45 2009
|
||||
Copyright (c) 1982, 2005, Oracle. All rights reserved.
|
||||
SQL> conn /as sysdba --“连接到sysdba”
|
||||
Connected to an idle instance.
|
||||
SQL> startup --“启动数据库实例”
|
||||
ORACLE instance started.
|
||||
Total System Global Area 285212672 bytes
|
||||
Fixed Size 1218968 bytes
|
||||
Variable Size 88082024 bytes
|
||||
Database Buffers 188743680 bytes
|
||||
Redo Buffers 7168000 bytes
|
||||
Database mounted.
|
||||
Database opened.
|
||||
SQL> shutdown immediate --“关闭数据库实例”
|
||||
Database closed.
|
||||
Database dismounted.
|
||||
ORACLE instance shut down.
|
||||
SQL> exit
|
||||
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
|
||||
With the Partitioning, OLAP and Data Mining options
|
||||
[oracle@redhat ~]$ lsnrctl stop --“关闭监听”
|
||||
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:08:06
|
||||
Copyright (c) 1991, 2005, Oracle. All rights reserved.
|
||||
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
|
||||
The command completed successfully
|
12
数据库/oracle/oracle基本操作.md
Normal file
12
数据库/oracle/oracle基本操作.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
### 添加select权限
|
||||
```
|
||||
grant select on USER1.TABLE to USER2;
|
||||
```
|
||||
### 添加创建同义词权限
|
||||
```
|
||||
grant create synonym to USER2;
|
||||
```
|
||||
### 创建同义词
|
||||
```
|
||||
create or replace synonym TABLE for USER1.TABLE;
|
||||
```
|
1
数据库/oracle/oracle导出数据.txt
Normal file
1
数据库/oracle/oracle导出数据.txt
Normal file
|
@ -0,0 +1 @@
|
|||
exp user/pwd@dbname file=d:text.dmp owner=(user)
|
BIN
数据库/oracle/oracle数据库数据导入导出步骤(入门) - CSDN博客.pdf
Normal file
BIN
数据库/oracle/oracle数据库数据导入导出步骤(入门) - CSDN博客.pdf
Normal file
Binary file not shown.
86
数据库/oracle/oracle表空间扩容.md
Normal file
86
数据库/oracle/oracle表空间扩容.md
Normal file
|
@ -0,0 +1,86 @@
|
|||
```sql
|
||||
# 查询表空间
|
||||
SELECT TABLESPACE_NAME "表空间",
|
||||
To_char(Round(BYTES / 1024, 2), '99990.00')
|
||||
|| '' "实有",
|
||||
To_char(Round(FREE / 1024, 2), '99990.00')
|
||||
|| 'G' "现有",
|
||||
To_char(Round(( BYTES - FREE ) / 1024, 2), '99990.00')
|
||||
|| 'G' "使用",
|
||||
To_char(Round(10000 * USED / BYTES) / 100, '99990.00')
|
||||
|| '%' "比例"
|
||||
FROM (SELECT A.TABLESPACE_NAME TABLESPACE_NAME,
|
||||
Floor(A.BYTES / ( 1024 * 1024 )) BYTES,
|
||||
Floor(B.FREE / ( 1024 * 1024 )) FREE,
|
||||
Floor(( A.BYTES - B.FREE ) / ( 1024 * 1024 )) USED
|
||||
FROM (SELECT TABLESPACE_NAME TABLESPACE_NAME,
|
||||
Sum(BYTES) BYTES
|
||||
FROM DBA_DATA_FILES
|
||||
GROUP BY TABLESPACE_NAME) A,
|
||||
(SELECT TABLESPACE_NAME TABLESPACE_NAME,
|
||||
Sum(BYTES) FREE
|
||||
FROM DBA_FREE_SPACE
|
||||
GROUP BY TABLESPACE_NAME) B
|
||||
WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME)
|
||||
--WHERE TABLESPACE_NAME LIKE 'CDR%' --这一句用于指定表空间名称
|
||||
ORDER BY Floor(10000 * USED / BYTES) DESC;
|
||||
```
|
||||
```
|
||||
set linesize 140 pagesize 10000
|
||||
col "Status" for a10
|
||||
col "Name" for a25
|
||||
col "Type" for a10
|
||||
col "Extent" for a15
|
||||
col "Size(M)" for a15
|
||||
col "Used(M)" for a15
|
||||
col "Used(%)" for a20
|
||||
col "Maxused(%)" for a20
|
||||
SELECT d.status "Status", d.tablespace_name "Name", d.contents "Type", d.extent_management "Extent",
|
||||
TO_CHAR(NVL(a.bytes / 1024 / 1024, 0),'99,999,990') "Size(M)",
|
||||
TO_CHAR(NVL(a.bytes - NVL(f.bytes, 0), 0)/1024/1024,'999,999,999') "Used(M)",
|
||||
TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0), '900.00') "Used(%)",
|
||||
TO_CHAR(100-((a.maxbytes - a.bytes + f.bytes) / a.maxbytes * 100), '900.00') "Maxused(%)"
|
||||
FROM sys.dba_tablespaces d,
|
||||
(select tablespace_name, sum(bytes) bytes,sum(decode(autoextensible, 'YES',maxbytes,'NO', bytes)) maxbytes from dba_data_files group by tablespace_name) a,
|
||||
(select tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) f
|
||||
WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+) AND NOT
|
||||
(d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY')
|
||||
UNION ALL
|
||||
SELECT d.status "Status", d.tablespace_name "Name", d.contents "Type", d.extent_management "Extent",
|
||||
TO_CHAR(NVL(a.bytes / 1024 / 1024, 0),'99,999,999') "Size(M)",
|
||||
TO_CHAR(NVL(t.bytes,0)/1024/1024,'999,999,999') "Used(M)",
|
||||
TO_CHAR(NVL(t.bytes / a.bytes * 100, 0), '990.00') "Used(%)" ,
|
||||
TO_CHAR(NVL(t.bytes / a.maxbytes * 100, 0), '990.00') "Maxused(%)"
|
||||
FROM sys.dba_tablespaces d,
|
||||
(select tablespace_name, sum(bytes) bytes,sum(decode(autoextensible, 'YES',maxbytes,'NO', bytes)) maxbytes from dba_temp_files group by tablespace_name) a,
|
||||
(select tablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool group by tablespace_name) t
|
||||
WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = t.tablespace_name(+) AND
|
||||
d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY'
|
||||
ORDER BY 7;
|
||||
```
|
||||
```sql
|
||||
# 查询表空间文件及目录
|
||||
select
|
||||
b.file_name 物理文件名,
|
||||
b.tablespace_name 表空间,
|
||||
b.bytes/1024/1024 大小M,
|
||||
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 已使用M,
|
||||
substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) 利用率
|
||||
from dba_free_space a,dba_data_files b
|
||||
where a.file_id=b.file_id
|
||||
group by b.tablespace_name,b.file_name,b.bytes
|
||||
order by b.tablespace_name;
|
||||
```
|
||||
```
|
||||
select tablespace_name,file_id,bytes/1024/1024,file_name from dba_data_files order by file_id;
|
||||
```
|
||||
|
||||
```sql
|
||||
# 增加表空间文件
|
||||
ALTER TABLESPACE [表空间名称] ADD DATAFILE '数据文件路径' SIZE 8G;
|
||||
```
|
||||
|
||||
```sql
|
||||
# 查询归档日志空间使用情况
|
||||
select to_char(next_time, 'yyyy-mm-dd') hourtime, round(sum(blocks * block_size) / 1024 / 1024 / 1024) archlog_GB from v$archived_log where dest_id = 1 and next_time > sysdate - 15 group by to_char(next_time, 'yyyy-mm-dd') order by to_char(next_time, 'yyyy-mm-dd');
|
||||
```
|
12
数据库/oracle/oracle锁表问题.md
Normal file
12
数据库/oracle/oracle锁表问题.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
## 查询被锁定的表
|
||||
```
|
||||
select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;
|
||||
```
|
||||
## 查询发生锁定表的会话及序列号
|
||||
```
|
||||
select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
|
||||
```
|
||||
## 结束产生锁表的会话
|
||||
```
|
||||
alter system kill session 'SID,SERIAL#';
|
||||
```
|
21
数据库/oracle/查询资源所属用户.md
Normal file
21
数据库/oracle/查询资源所属用户.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
## 查询表所属用户
|
||||
```
|
||||
SELECT * FROM DBA_TABLES WHERE TABLE_NAME='表名';
|
||||
```
|
||||
```
|
||||
SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE='TABLE' and OBJECT_NAME='表名'
|
||||
```
|
||||
```
|
||||
select owner from dba_tables where table_name=upper('表名');
|
||||
```
|
||||
## 查询视图所属用户
|
||||
```
|
||||
SELECT * FROM ALL_VIEWS WHERE VIEW_NAME='视图名';
|
||||
```
|
||||
```
|
||||
SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE='VIEW' and OBJECT_NAME='视图名'
|
||||
```
|
||||
## 查询存储过程所属用户
|
||||
```
|
||||
SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE='PROCEDURE' and OBJECT_NAME='存储过程名'
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue