關於Oracle使用總結

2021-09-29 15:28:41 字數 869 閱讀 2337

select a into b from table_name;

--必須只存在一條記錄

--必須能夠查到值,如果查不到記錄則報錯,nodatafount

''a'' 表示 'a'
select

*from a_pay_flow a where a.cons_no =

&a and rownum =1;

select

*from a_pay_flow a where a.cons_no =

&a and rownum =1;

--執行會提示輸入 變數

--&是oracle裡的替代變數。如果有乙個&a,在sqlplus執行的時候,會提示你輸入乙個a對應的值。

--然後a值會替代到sql裡面,這裡是替代,不是引數繫結,所以可以替換sql中的靜態部分,比如欄位名

v_sql :=

'select * from table(:1)'

|| cons

open out_det for v_sql using table_name;

--:1 可以是任何型別的變數,只做佔位符的替換

--cons 一定是字串型別的變數

Oracle使用總結

1.查詢oracle表空間的使用情況 select b.file id 檔案id,b.tablespace name 表空間,b.file name 物理檔名,b.bytes 總位元組數,b.bytes sum nvl a.bytes,0 已使用,sum nvl a.bytes,0 剩餘,sum n...

Oracle使用總結一

一 修改表名要修改索引以及主鍵 alter table afa auth function rename to back afa auth function 修改表名 alter table back afa auth function rename constraint pk afa auth f...

oracle語句使用總結

例子,sql表 表名為armyinfo 1 查詢語句 語法 select 列名 from 表名 where 條件從句 例如 1 查詢表顯示 select from armyinfo 2 查詢表裡的name,age顯示 select a.name,a.age from armyinfo a 3 查詢c...