Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Anywhere 11 - table size

I am trying to get the table size for each table from a database using SQL Anywhere 11.

I just found out sp_spaceused has been deprecated

Any help with this would be greatly appreciated! :)

like image 747
tray Avatar asked Apr 05 '12 20:04

tray


People also ask

What is SQL Anywhere 16?

SQL Anywhere 16 overview SQL Anywhere is a comprehensive package that provides technologies for data management and enterprise data exchange, enabling the rapid development of database-powered applications for server, desktop, mobile, and remote office environments.

Is SQL Anywhere Sybase?

SAP SQL Anywhere is a proprietary relational database management system (RDBMS) product from SAP. SQL Anywhere was known as Sybase SQL Anywhere prior to the acquisition of Sybase by SAP.


2 Answers

Possibly the system view SYSTAB can be a good-enough alternative. It can give you the number of rows in the table, and it can give you how many pages the table uses. (In the sample below, I'm multiplying the number of pages by the DB's page size to get a total byte size.)

SELECT
    count,                      -- number of rows in the table
    (table_page_count * DB_PROPERTY('PageSize')) tablesize  
                                -- total size, in bytes
FROM SYSTAB
WHERE table_name = 'mytable';   -- or whatever limitations you want on 
                                -- the scope of the query

Hope this helps.

like image 177
Dan K Avatar answered Oct 08 '22 18:10

Dan K


You can use this script at Sql Server to find the largest table in Database and row count

SELECT sc.name +'.'+ ta.name TableName
,SUM(pa.rows) RowCnt
FROM sys.tables ta
INNER JOIN sys.partitions pa
ON pa.OBJECT_ID = ta.OBJECT_ID
INNER JOIN sys.schemas sc
ON ta.schema_id = sc.schema_id
WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0)
GROUP BY sc.name,ta.name
ORDER BY SUM(pa.rows) DESC  
like image 33
ImportantSoftware Avatar answered Oct 08 '22 20:10

ImportantSoftware