1. Oracle中有哪些DML操作
Oracle DML(資料庫操作語言)如下:
一、添加數據:
語法:insert into 表名(列名…) values(值…);
實例代碼如下:
2. oracle 查看有哪些資料庫的命令
查看那些庫的話必須用dba許可權登錄。登陸後可以通過下面的方法來查看。
一、查看有哪些庫,你的庫理解不準確,應該准確來說是表空間,可以通過下面的命令來實現
SELECT Total.name "Tablespace Name",
Free_space, (total_space-Free_space) Used_space, total_space
FROM
(select tablespace_name, sum(bytes/1024/1024) Free_Space
from sys.dba_free_space
group by tablespace_name
) Free,
(select b.name, sum(bytes/1024/1024) TOTAL_SPACE
from sys.v_$datafile a, sys.v_$tablespace B
where a.ts# = b.ts#
group by b.name
) Total
WHERE Free.Tablespace_name = Total.name
二、查看有哪些表。
select table_name from dba_tables where owner='A';
3. 誰能告訴我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;
4. Oracle常見的命令
太多了, 下面的只是一小部分oracle常用命令(我的筆記)
oracle里常用命令第一章:日誌管理 1.forcing log switches
sql> alter system switch logfile;
2.forcing checkpoints
sql> alter system checkpoint;
3.adding online redo log groups
sql> alter database add logfile [group 4]
sql> ('/disk3/log4a.rdo','/disk4/log4b.rdo') size 1m;
4.adding online redo log members
sql> alter database add logfile member
sql> '/disk3/log1b.rdo' to group 1,
sql> '/disk4/log2b.rdo' to group 2;
5.changes the name of the online redo logfile
sql> alter database rename file 'c:/oracle/oradata/oradb/redo01.log'
sql> to 'c:/oracle/oradata/redo01.log';
6.drop online redo log groups
sql> alter database drop logfile group 3;
7.drop online redo log members
sql> alter database drop logfile member 'c:/oracle/oradata/redo01.log';
8.clearing online redo log files
sql> alter database clear [unarchived] logfile 'c:/oracle/log2a.rdo';
9.using logminer analyzing redo logfiles
a. in the init.ora specify utl_file_dir = ' '
b. sql> execute dbms_logmnr_d.build('oradb.ora','c:\oracle\oradb\log');
c. sql> execute dbms_logmnr_add_logfile('c:\oracle\oradata\oradb\redo01.log',
sql> dbms_logmnr.new);
d. sql> execute dbms_logmnr.add_logfile('c:\oracle\oradata\oradb\redo02.log',
sql> dbms_logmnr.addfile);
e. sql> execute dbms_logmnr.start_logmnr(dictfilename=>'c:\oracle\oradb\log\oradb.ora');
f. sql> select * from v$logmnr_contents(v$logmnr_dictionary,v$logmnr_parameters
sql> v$logmnr_logs);
g. sql> execute dbms_logmnr.end_logmnr; 第二章:表空間管理
1.create tablespaces
sql> create tablespace tablespace_name datafile 'c:\oracle\oradata\file1.dbf' size 100m,
sql> 'c:\oracle\oradata\file2.dbf' size 100m minimum extent 550k [logging/nologging]
sql> default storage (initial 500k next 500k maxextents 500 pctinccease 0)
sql> [online/offline] [permanent/temporary] [extent_management_clause]
2.locally managed tablespace
sql> create tablespace user_data datafile 'c:\oracle\oradata\user_data01.dbf'
sql> size 500m extent management local uniform size 10m;
3.temporary tablespace
sql> create temporary tablespace temp tempfile 'c:\oracle\oradata\temp01.dbf'
sql> size 500m extent management local uniform size 10m;
4.change the storage setting
sql> alter tablespace app_data minimum extent 2m;
sql> alter tablespace app_data default storage(initial 2m next 2m maxextents 999);
5.taking tablespace offline or online
sql> alter tablespace app_data offline;
sql> alter tablespace app_data online;
6.read_only tablespace
sql> alter tablespace app_data read only|write;
7.droping tablespace
sql> drop tablespace app_data including contents;
8.enableing automatic extension of data files
sql> alter tablespace app_data add datafile 'c:\oracle\oradata\app_data01.dbf' size 200m
sql> autoextend on next 10m maxsize 500m;
9.change the size fo data files manually
sql> alter database datafile 'c:\oracle\oradata\app_data.dbf' resize 200m;
10.Moving data files: alter tablespace
sql> alter tablespace app_data rename datafile 'c:\oracle\oradata\app_data.dbf'
sql> to 'c:\oracle\app_data.dbf';
11.moving data files:alter database
sql> alter database rename file 'c:\oracle\oradata\app_data.dbf'
sql> to 'c:\oracle\app_data.dbf'; 第三章:表 1.create a table
sql> create table table_name (column datatype,column datatype]....)
sql> tablespace tablespace_name [pctfree integer] [pctused integer]
sql> [initrans integer] [maxtrans integer]
sql> storage(initial 200k next 200k pctincrease 0 maxextents 50)
sql> [logging|nologging] [cache|nocache]
2. an existing table
sql> create table table_name [logging|nologging] as subquery
3.create temporary table
sql> create global temporary table xay_temp as select * from xay;
on commit preserve rows/on commit delete rows
4.pctfree = (average row size - initial row size) *100 /average row size
pctused = 100-pctfree- (average row size*100/available data space)
5.change storage and block utilization parameter
sql> alter table table_name pctfree=30 pctused=50 storage(next 500k
sql> minextents 2 maxextents 100);
6.manually allocating extents
sql> alter table table_name allocate extent(size 500k datafile 'c:/oracle/data.dbf');
7.move tablespace
sql> alter table employee move tablespace users;
8.deallocate of unused space
sql> alter table table_name deallocate unused [keep integer]
9.truncate a table
sql> truncate table table_name;
10.drop a table
sql> drop table table_name [cascade constraints];
11.drop a column
sql> alter table table_name drop column comments cascade constraints checkpoint 1000;
alter table table_name drop columns continue;
12.mark a column as unused
sql> alter table table_name set unused column comments cascade constraints;
alter table table_name drop unused columns checkpoint 1000;
alter table orders drop columns continue checkpoint 1000
data_dictionary : dba_unused_col_tabs 第四章:索引 1.creating function-based indexes
sql> create index summit.item_quantity on summit.item(quantity-quantity_shipped);
2.create a B-tree index
sql> create [unique] index index_name on table_name(column,.. asc/desc) tablespace
sql> tablespace_name [pctfree integer] [initrans integer] [maxtrans integer]
sql> [logging | nologging] [nosort] storage(initial 200k next 200k pctincrease 0
sql> maxextents 50);
3.pctfree(index)=(maximum number of rows-initial number of rows)*100/maximum number of rows
4.creating reverse key indexes
sql> create unique index xay_id on xay(a) reverse pctfree 30 storage(initial 200k
sql> next 200k pctincrease 0 maxextents 50) tablespace indx;
5.create bitmap index
sql> create bitmap index xay_id on xay(a) pctfree 30 storage( initial 200k next 200k
sql> pctincrease 0 maxextents 50) tablespace indx;
6.change storage parameter of index
sql> alter index xay_id storage (next 400k maxextents 100);
7.allocating index space
sql> alter index xay_id allocate extent(size 200k datafile 'c:/oracle/index.dbf');
8.alter index xay_id deallocate unused;
5. 啟動oracle資料庫命令
(1)startup(用sys用戶或者其他擁有啟動資料庫許可權的用戶登錄資料庫軟體,然後執行該命令即可,如果存在多個實例,請在啟動前確認SID),資料庫有三個狀態nomount,mount,和open,默認開啟到open,如果開啟到另外兩個狀態,那麼可以通過alter命令改變狀態。
(2)如果是rac中啟停資料庫節點,那麼有專門的命令srvcrl(這個僅僅是命令的操作符,後面有參數的,參數我就不寫了,具體可以查一下,網上很多與偶內容的),另外還有crscrl(啟停crs服務的命令,同樣也是操作符,後面有參數的,這里也不寫了,自己查一下就可以了)
(3)啟動資料庫還有一個命令就是啟動監聽,lsnrctl命令(後面同樣有參數,能啟動停止,也能查詢監聽狀態,這個監聽的基本命令)
6. oracle啟動命令是什麼
啟動的階段和啟動的命令如下:
1、nomount:alter database open,此階段需要參數文件支持;
2、mount:alter database mount,此階段需要控制文件支持;
3、open :alter database open,此階段資料庫會驗證所有的數據文件和redo。
4、也可以一條命令直接起庫:startup
具體方法/步驟:
打開命令行窗口界面,可以同時按住「ctrl+R」鍵,在彈出來的運行窗口中輸入cmd。
7. oracle常用的快捷鍵
1、Alt+F1、Ctrl+Esc:
打開 "Applications"(應用程序)菜單。
2、Alt+F2、Meta+R:
顯示 "Run Applications"(運行應用程序)對話框。有關如何運行應用程序的更多信息,請參見運行應用程序。
3、Print Screen:
獲取整個桌面的屏幕抓圖。有關獲取屏幕抓圖的更多信息,請參見獲取屏幕抓圖。
4、Alt+Print Screen:
獲取當前聚焦窗口的屏幕抓圖。
5、Ctrl+Alt+方向鍵:
按指定方向切換工作區。有關使用多個工作區的更多信息,請參見工作區概述。
6、Ctrl+Alt+D:
最小化所有窗口並將焦點賦予桌面。
7、Alt+Tab:
在窗口間切換。將顯示一個窗口列表,您可以從中進行選擇。釋放鍵可選擇一個窗口。您可以按 Shift 鍵按相反的順序循環查看窗口。
8、Alt+ Esc:
在窗口間切換。釋放鍵可選擇一個窗口。使用 Shift 鍵可按相反的順序循環查看窗口。
9、Ctrl+Alt+Tab:
在面板和桌面之間切換焦點。將顯示一個項目列表,您可以從中選擇項目。釋放鍵可選擇一個項目。您可以按 Shift 鍵按相反的順序循環查看項目。
(7)oracle基本命令大全擴展閱讀
應用程序快捷鍵——
Ctrl+N:創建新文檔或窗口。
Ctrl+X:剪切所選的文本或區域並將其放在剪貼板中。
Ctrl+C:將所選的文本或區域復制到剪貼板中。
Ctrl+V:粘貼剪貼板的內容。
Ctrl+Z:取消上次操作。
Ctrl+S:將當前文檔保存到磁碟上。
F1:裝入應用程序的聯機幫助文檔。
8. Oracle常用的命令如何查看錶的結構
以下的文章主要是介紹Oracle常用的命令中如何查看錶的結構.EDITDATA 表名;修改表欄位:Alter table 表名 modify(欄位名 類型 約束);alter table test modify (addd varchar2(10) null); alter table 表名 add(欄位名 類型 約束);alter table test add(age varchar2(5)); 1.登陸系統用戶在Oracle常用命令中查看錶結構sqlplus 然後輸入系統用戶名和密碼登陸別的用戶conn 用戶名/密碼;2.創建表空間create tablespace 空間名 datafile 'c:\空間名' size 15M --表空間的存放路徑,初始值為15M autoExtend on next 10M --空間的自動增長的值是10M permanent online; --永久使用 3.創建用戶create user shi --創建用戶名為shi identified by scj --創建密碼為scj default tablespace 表空間名 --默認表空間名 temporary tablespace temp --臨時表空間為temp profile default --受profile文件的限制 quota unlimited on 表空間名; --在表空間下面建表不受限制 4.創建角色create role 角色名 identified by 密碼;5.給角色授權grant create session to 角色名;--給角色授予創建會話的許可權grant 角色名 to 用戶名; --把角色授予用戶6.給用戶授予許可權grant connect,resource to shi;--給shi用戶授予所有許可權 Grant dba to shi;-給shi 用戶授予DBA許可權 grant create table to shi; --給shi用戶授予創建表的許可權 7.select table_name from user_tables; 察看當前用戶下的所有表8.select tablespace_name from user_tablespaces; 察看當前用戶下的 表空間9.select username from dba_users;察看所有用戶名稱命令 必須用sys as sysdba登陸10.創建表create table 表名( id int not null, name varchar2(20) not null )tablespace 表空間名 --所屬的表空間 storage ( initial 64K --表的初始值 minextents 1 --最小擴展值 maxextents unlimited --最大擴展值 ); 11.為usrs表添加主鍵和索引alter table users add constraint pk primary key (ID); 12.為已經創建users表添加外鍵alter table users add constraint fk_roleid foreign key (roleid) references role(role_id) on delete cascad; --下邊寫主表的列 on delete cascad是創建級聯 13.把兩個列連接起來select concat(name,id) from 表名; --把name和id連接起來14.截取字元串select column(name,'李') from 表名;把name中的『李』去掉15.運行事務之前必須寫set serveroutput on; 打開輸入輸出(不寫的話,列印不出信息)16.while的應用declare --聲明部分 ccc number:=1; --復職 a number:=0; begin --事務的開始 while ccc<=100 loop --循環 if((ccc mod 3)=0) then --條件 dbms_output.put_line(ccc||','); --列印顯示 aa:=a+ccc; end if; --結束if cc:=ccc+1; end loop; --結束循環 dbms_output.put_line(a); end; --結束事務 / 17.select into 的用法 --只能處理一行結果集declare name varchar(30); begin select username into name from users where id=2; dbms_output.put_line('姓名為:'||name); end; / 上述的相關內容就是對Oracle常用命令中查看錶結構的描述,希望會給你帶來一些幫助在此方面。
9. oracle資料庫 常見的數據定義命令有哪些,數據操作命令有哪些
我還有個文本文檔,如果你想要,請留下您的QQ,我發給您。
SQLPLUS常用的命令:
edit;(打開緩存中的命令記事本)
/(執行緩存中的命令)
conn連接
sys/system/sysdba
scott/hr
創建用戶:
必須以管理員或超級用戶的身份登錄,才可以創建
以sys用戶登錄
sys/as sysdba
以system登錄
system@str
password
創建用戶:
create user myuser identified by myuser;
授予連接的許可權
grant connect to myuser;
grant resource to myuser;
刪除用戶
drop user myuser;
物理結構
資料庫:日誌文件,數據文件,控制文件
表空間-----數據文件
myuser:table
create user user01
identified by user01
default tablespace users
temporary tablespace temp;
--創建表空間
create tablespace myts datafile 'd:/stu/a.data' size 50M;
--許可權
--系統許可權 create any table
--對象許可權 select on scott.emp
--角色 (一組許可權的集合 )
--connect(連接),resource
create role myrole;
grant connect,resource to myrole;
grant myrole to user01;
--修改口令
alter user user01 identified by aaa111;
--修改用戶的鎖定狀態
alter user scott account unlock;
--修改表空間
alter user user01 default/temporary tablespace myts;
--解除許可權
revoke myrole from user01;
--刪除用戶
drop user user01;
10. 查詢oracle資料庫所有用戶的sqlplus命令是什麼
命令是select * from dba_users,設置方法為:
1、在資料庫的開始菜單中,輸入cmd後回車,也就是調用Windows的命令行管理器。