Sybase: различия между версиями
Материал из noname.com.ua
Перейти к навигацииПерейти к поискуSirmax (обсуждение | вклад) (Новая: =Sybase= ==Поленые ф-и== Информация по базе <PRE> sp_helpdb db_name </PRE> Создать "утройство" (файл или утройство для да...) |
Sirmax (обсуждение | вклад) |
||
Строка 18: | Строка 18: | ||
<PRE> |
<PRE> |
||
ALTER database cmm_db on cmm_db_data_2 = "5000M" |
ALTER database cmm_db on cmm_db_data_2 = "5000M" |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | |||
+ | ==Размеры таблиц== |
||
+ | <PRE> |
||
+ | |||
+ | CREATE PROCEDURE dbo.CalcFreeSpace |
||
+ | AS |
||
+ | BEGIN |
||
+ | DECLARE @CurrentTableName NVARCHAR(100) |
||
+ | |||
+ | CREATE TABLE #TableList |
||
+ | (TableName NVARCHAR(100) |
||
+ | , RowsCount INT |
||
+ | , KBReserved VARCHAR(15) |
||
+ | , KBData VARCHAR(15) |
||
+ | , KBIndex VARCHAR(15) |
||
+ | , KBUnused VARCHAR(15) |
||
+ | ) |
||
+ | |||
+ | -- Run a cursor through all of the tables |
||
+ | DECLARE result_cursor CURSOR FOR |
||
+ | SELECT name FROM dbo.sysobjects WHERE type = 'U' |
||
+ | |||
+ | OPEN result_cursor |
||
+ | FETCH NEXT FROM result_cursor INTO @CurrentTableName |
||
+ | WHILE @@FETCH_STATUS = 0 |
||
+ | BEGIN |
||
+ | exec sp_spaceused @CurrentTableName |
||
+ | FETCH NEXT FROM result_cursor INTO @CurrentTableName |
||
+ | END |
||
+ | --end loop |
||
+ | |||
+ | --clean up |
||
+ | CLOSE result_cursor |
||
+ | DEALLOCATE result_cursor |
||
+ | |||
+ | --UPDATE #TableList |
||
+ | -- SET KBReserved = REPLACE(KBReserved, ' KB', '') |
||
+ | -- , KBData = REPLACE(KBData, ' KB', '') |
||
+ | -- , KBIndex = REPLACE(KBIndex, ' KB', '') |
||
+ | -- , KBUnused = REPLACE(KBUnused, ' KB', '') |
||
+ | |||
+ | /* Adaptive Server has expanded all '*' elements in the following statement */ |
||
+ | SELECT |
||
+ | #TableList.TableName, #TableList.RowsCount, #TableList.KBReserved, #TableList.KBData, #TableList.KBIndex, #TableList.KBUnused |
||
+ | FROM |
||
+ | #TableList |
||
+ | ORDER BY TableName |
||
+ | DROP TABLE #TableList |
||
+ | END |
||
</PRE> |
</PRE> |
Версия 14:02, 21 января 2011
Sybase
Поленые ф-и
Информация по базе
sp_helpdb db_name
Создать "утройство" (файл или утройство для данных)
disk init name = "cmm_db_data_2", physname = "/sybase_devices/cmm_db_data_2.dat", size = "5000M"
Добавить это устройство к базе.
ALTER database cmm_db on cmm_db_data_2 = "5000M"
Размеры таблиц
CREATE PROCEDURE dbo.CalcFreeSpace AS BEGIN DECLARE @CurrentTableName NVARCHAR(100) CREATE TABLE #TableList (TableName NVARCHAR(100) , RowsCount INT , KBReserved VARCHAR(15) , KBData VARCHAR(15) , KBIndex VARCHAR(15) , KBUnused VARCHAR(15) ) -- Run a cursor through all of the tables DECLARE result_cursor CURSOR FOR SELECT name FROM dbo.sysobjects WHERE type = 'U' OPEN result_cursor FETCH NEXT FROM result_cursor INTO @CurrentTableName WHILE @@FETCH_STATUS = 0 BEGIN exec sp_spaceused @CurrentTableName FETCH NEXT FROM result_cursor INTO @CurrentTableName END --end loop --clean up CLOSE result_cursor DEALLOCATE result_cursor --UPDATE #TableList -- SET KBReserved = REPLACE(KBReserved, ' KB', '') -- , KBData = REPLACE(KBData, ' KB', '') -- , KBIndex = REPLACE(KBIndex, ' KB', '') -- , KBUnused = REPLACE(KBUnused, ' KB', '') /* Adaptive Server has expanded all '*' elements in the following statement */ SELECT #TableList.TableName, #TableList.RowsCount, #TableList.KBReserved, #TableList.KBData, #TableList.KBIndex, #TableList.KBUnused FROM #TableList ORDER BY TableName DROP TABLE #TableList END