oracle數據庫時常用的操作命令

 

http://www.hacker.com.cn/article/list.asp?id=3830
oracle數據庫時常用的操作命令

最近遇到一個使用了oracle數據庫的服務器,在狂學oracle+請教高手後終於搞到了網站後臺管理界面的所有用戶密碼,我發現oracle操作起來真是太麻煩,爲了兄弟們以後少走些彎路,我把入侵當中必需的命令整理出來,一個星期的心血,版權所有,轉載請註明作者.
1、su – oracle 不是必需,適合於沒有DBA密碼時使用,可以不用密碼來進入sqlplus界面。
2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i;
3、SQL>connect / as sysdba ;(as sysoper)或
connect internal/oracle AS SYSDBA ;(scott/tiger)
conn sys/change_on_install as sysdba;
4、SQL>startup; 啓動數據庫實例
5、 查看當前的所有數據庫: select * from v$database;
select name from v$database;
desc v$databases; 查看數據庫結構字段
7、怎樣查看哪些用戶擁有SYSDBA、SYSOPER權限:
SQL>select * from V_$PWFILE_USERS;
Show user;查看當前數據庫連接用戶
8、進入test數據庫:database test;
9、查看所有的數據庫實例:select * from v$instance;
如:ora9i
10、查看當前庫的所有數據表:
SQL> select TABLE_NAME from all_tables;
select * from all_tables;
SQL> select table_name from all_tables where table_name like ‘u’;
TABLE_NAME———————————————default_auditing_options
11、查看錶結構:desc all_tables;
12、顯示CQI.T_BBS_XUSER的所有字段結構:
desc CQI.T_BBS_XUSER;
13、獲得CQI.T_BBS_XUSER表中的記錄:
select * from CQI.T_BBS_XUSER;
14、增加數據庫用戶:(test11/test)
create user test11 identified by test default tablespace users Temporary TABLESPACE Temp;
15、用戶授權:
grant connect,resource,dba to test11;
grant sysdba to test11;
commit;
16、更改數據庫用戶的密碼:(將sys與system的密碼改爲test.)
alter user sys indentified by test;
alter user system indentified by test;
原作者: 腳本小子
 
 
 
===================================================================================================================================
 
 
在嚮導下 建立數據庫
sqlplus下-- 用system用戶登錄
sqlplus system/oracle@orcl-- 創建表空間
create tablespace longs datafile'D:\long.dbf' size 100M autoextendon;
--創建用戶hll 密碼hll
createuser hll identifiedby hll default tablespace longs;
--授權
grant dbato hll;
-- 退出用hll用戶登錄
sqlplushll/hll@orcl
創建表。請按上面的步驟操作。
注意Oracle的一些基本概念。
表空間:是一個邏輯的概念,是屬於所有用戶共享的。表:是屬於創建他的用戶的。
--查看錶空間select* from dba_tablespaces ;
--查看用戶下的表:select* from user_tables;
--查字段數:selectcount(1)from user_tab_colswhere table_name= 'HELP'selectcount(*)from help;selectcount(1)from help;
--修改表的某一列名字altertable test renamecolumn DEPTto DEPT_OLD;
 --往表中增加新的一列altertable tb3 add AGE number;select* from v$database;
--看數據庫名稱select* from v$instance;
--看數據庫名稱
select namefrom v$database;select instance_namefrom v$instance;
select namefrom v$controlfile;D:\oracle\product\10.2.0\oradata
=====================================================
備份導出:D:\oracle\product\10.2.0\db_1\BIN>exp hll/hll@orclfile=C:\hll.dmp;
導入D:\oracle\product\10.2.0\db_1\BIN>imp hll1/hll1@orclfile= C:\hll.dmp;
報異常Import: Release 10.2.0.1.0- Productionon 星期五 12月 910:20:312011Copyright (c)1982,2005, Oracle.All rights reserved.
連接到: Oracle Database 10g Enterprise Edition Release10.2.0.1.0- ProductionWith the Partitioning, OLAPand Data Mining options
經由常規路徑由 EXPORT:V10.02.01
創建的導出文件警告: 這些對象由 HLL 導出, 而不是當前用戶已經完成 ZHS16GBK 字符集和 AL16UTF16NCHAR 字符集中的導入IMP-00031: 必須指定FULL=Y 或提供 FROMUSER/TOUSER 或 TABLES 參數IMP-00000: 未成功終止導入oracle dmp 要求是低版本導出,高版本導入導入語句 dmp後要有 分號。
D:\oracle\product\10.2.0\db_1\BIN>imp hll/hll@orclfile= C:\hll.dmp;full=y;
==========================================================
Plsql下tools下導入.dmp文件, Import Tables 導出成.dmp
 Export tables 導進.sql文件
 
Tools
Import Tables
SQL Inserts下
http://blog.sina.com.cn/s/blog_5892bb180100vjo2.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章