1.oracle查詢所有當前資料庫的表語句:
select 'drop table '||table_name||';' as sqlscript from user_tables;
2.sql查詢所有當前資料庫的表語句:
//查詢使用者下所有資料庫
select name from master..sysdatabases order by name
//查詢某資料庫下所有表
select 'drop tbale'+' '+ name from sysobjects where xtype='u' order by name
//查詢表結構資訊
select (case when a.colorder=1 then d.name else null end) 表名,
a.colorder 字段序號,a.name 欄位名,
(case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end) 標識,
(case when (select count(*) from sysobjects
where (name in (select name from sysindexes
where (id = a.id) and (indid in
(select indid from sysindexkeys
where (id = a.id) and (colid in
(select colid from syscolumns where (id = a.id) and (name = a.name)))))))
and (xtype = 'pk'))>0 then '√' else '' end) 主鍵,b.name 型別,a.length 占用位元組數,
columnproperty(a.id,a.name,'precision') as 長度,
isnull(columnproperty(a.id,a.name,'scale'),0) as 小數字數,(case when a.isnullable=1 then '√'else '' end) 允許空,
isnull(e.text,'') 預設值,isnull(g.[value], ' ') as [說明]
from syscolumns a
left join systypes b on a.xtype=b.xusertype
inner join sysobjects d on a.id=d.id and d.xtype='u' and d.name<>'dtproperties'
left join syscomments e on a.cdefault=e.id
left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_id
left join sys.extended_properties f on d.id=f.class and f.minor_id=0
where b.name is not null
--where d.name='要查詢的表' --如果只查詢指定表,加上此條件
order by a.id,a.colorder
3.有關資料庫分離的一些小知識點
(1)資料庫分離之前先檢查分離資料庫的大小、屬性、快取設定及存放位置;
(2)資料庫分離時如果連線數大於0,需要清空連線數;
(3)資料庫分離後就可以進行複製、貼上;
(4)分離後的資料庫如果用需要附加後才能使用;
MYSQL查詢優化 資料型別與效率
這一部分提供了如何選擇資料型別來幫助提高查詢執行速度的一些指導 如果出現資料表崩潰的情況,那麼資料行長度固定的表更容易重新構造。使用固定長度資料行的時候,每個記錄的開始位置都可以被檢測到,因為這些位置都是固定記錄長度的倍數,但是使用可變長度資料行的時候就不一定了。這不是與查詢處理的效能相關的問題,但...
MYSQL查詢優化 資料型別與效率
這一部分提供了如何選擇資料型別來幫助提高查詢執行速度的一些指導 說,這一點尤其突出,因為在那些情況下,效能更容易受到磁碟碎片的影響。在使用可變長度的資料行的時候,由於記錄長度不同,在多次執行刪除和更新操作之後,資料表的碎片要多一些。你必須使用optimize table來定期維護其效能。固定長度的資...
mysql查詢型別轉換 mysql查詢型別轉換
歡迎進入linux社群論壇,與200萬技術人員互動交流 進入 在mysql查詢時最好不要發生型別轉換,如把varchar轉換成int mysql explain select from user where name 1 g 如果你確定name欄位是整型就不要把它轉化成字串,不加單引號 歡迎進入li...