oracle資料庫操作

2021-05-23 14:42:02 字數 2122 閱讀 7287

1、oracle安裝目錄,配置目錄

通過環境變數查詢

set | grep oracle

網路配置在 $oracle_home/network/admin/tnsnames.ora

2、oracle資料庫

select * from v$database;

3、oracle表

4、oracle 工具

linux下命令臺工具: sqlplus

windows下:sql*plus

5、刪除表:

delete from 表名 where 條件                       ——按條件刪除表中的記錄

delete from 表名                                         ——刪除表

delete 並不直接從資料庫中刪除,而只是把記錄標記為unused。要提交事務後,才能真正刪除。

truncate table 表名                                     ——刪除表;直接從資料庫中刪除,不可恢復。

delete、truncate 只刪除資料不刪除表的結構(定義)。

drop table 表名                                           ——刪除表;直接從資料庫中刪除,刪除一張表(表中的資料結構,屬性以及索引也會被刪除):

6、刪除資料庫

drop database 資料庫名                          ——刪除資料庫

7、建立索引

利用建立索引可以快速高效地定位到現存表中的記錄行上。我們可以在一張表上建立乙個針對單個或多個的欄目索引,並且每個索引可以有它自己的名稱。使用者並不會看見這些索引,它們僅僅讓查詢速度變快而已。

注意:一旦表中含有索引那麼它的資料更新速度就會減慢,這是因為裡面的索引也需要同步更新。因此最好只給那些搜尋時經常會用到的欄目加上索引。

唯一的索引

要建立乙個唯一的索引前提條件是它所包括資料值中沒有出現重複的。

create unique index index_name on table_name (column_name)

"column_name"指定的就是那個你想要讓其成為索引的欄目名

簡易的索引

給乙個表建立索引而沒有加上unique關鍵字,那麼它所包含的資料值是可以出現重複的。

create index index_name on table_name (column_name)

"column_name"指定的就是那個你想要讓其成為索引的欄目名

舉例這個舉例中將會建立乙個簡易的索引,命名為"personindex",並針對person表中的lastname欄目值進行建立:

create index personindexon person (lastname)

如果你想要讓欄目中的資料降序排列,那麼你可以在欄目名的後面加上乙個保留字desc:

create index personindexon person (lastname desc)

如果你要索引多個欄目那可以將欄目名稱放在括號內,並用逗號加以區分:

create index personindexon person (lastname, firstname)

8、刪除索引

你可以將現有的索引通過drop index語句進行取消操作。

syntax for microsoft sqljet (and microsoft access):

在microsoft sqljet (和 microsoft access)中的語法是這樣的:

drop index index_name on table_name

ms sql server的語法是這樣:

drop index table_name.index_name

ibm db2和oracle的語法為:

drop index index_name

mysql則是這樣:

alter table table_name drop index index_name

Oracle資料庫操作。

物件導向告一段落,重新撿起來sql server的知識,幸好資料庫語言都差不多,讓我重新學習oracle的時候並沒有想象中的費勁,只需要複習起來舊知識,再融合oracle特有的語法就足矣。廢話不多說,進入正題,此文章按照網上的資料 個人理解編寫,盡量做到通俗易懂,以便日後忘了能夠見文知意。注 sql...

oracle資料庫操作

1 建表空間 create tablespace ccpbs datafile home oracle bossdata ora data ccpbs index01.dbf size 100m reuse default storage initial 5000k next 5000k pctin...

Oracle資料庫操作

執行匯入命令 匯入時需要用準備工作中建立的新使用者,如 使用者名稱abc,密碼abc imp 使用者名稱 密碼 file dmp 檔案路徑 log 輸出日誌路徑 full y ignore y imp abc abc file home oracle iom.dmp log home oracle ...