常用SQL語句

2021-08-25 15:37:34 字數 1868 閱讀 2919

1.連線結果集:

select wmsys.wm_concat(column_name) from (select * from user_tab_cols where table_name='table_name' and hidden_column='no' order by segment_column_id)

2.查詢表名:

select * from user_tables

3.查詢欄位名(不包含oracle隱藏字段):

select * from user_tab_columns

4.查詢欄位名(包含oracle隱藏字段):

select * from user_tab_cols

5.建立表空間

create tablespace tablespace datafile 

'e:\oracle\product\10.2.0\oradata\sid\tablespace.ora' size 512m autoextend on

logging

online

permanent

extent management local autoallocate

blocksize 8k

segment space management auto;

6.建立使用者

create user username

identified by values 'pwd'

default tablespace tablespace

temporary tablespace temp

profile default

account unlock;

-- 3 roles for username

grant dba to username with admin option;

grant connect to username with admin option;

grant resource to username with admin option;

alter user username default role all;

-- 1 system privilege for username

grant unlimited tablespace to username with admin option;

grant select any table to username with admin option;

7.exp匯出

exp system/system@sid file=d:\dmp.dmp owner=(username)

8.imp匯入

imp system/system@sid file=dmp.dmp log=imp.log fromuser=(username,username1) touser=(username,username1)

9.一張表插入另外一張表 結構 不限

insert into tablea(fielda,fieldb) select fieldc,fieldd from tableb where fielde=?

10.檢視oracle版本,64位有明確字元

select * from v$version

sql常用sql語句

1 查詢某個庫中所有的表名字 select name from sysobjects where xtype u and name dtproperties order by name 2 得到資料庫中所有使用者檢視 select name from sysobjects where xtype v...

常用sql語句

t sql語句複製表的方法 我在sql server 2000中有現個資料庫datahr及demo,它們的結構是一樣,其它有乙個表名為 gbitem.現在我想將demo資料庫的表名 gbitem的全部內容複製到datahr資料庫的表名為 gbitem中。請問此t sql語句應該怎麼寫?謝謝高人指點!...

常用SQL語句

查詢 sp who 中的結果值。因為儲存過程不能查詢,先轉為臨時表再查詢。declare tb table spid varchar 100 ecid varchar 100 status varchar 100 loginame varchar 100 hostname varchar 100 b...