SQL Anywhere: Mostrar Tablas y Campos de la Base de Datos
/*
SysTab: Tabla que muestra las tablas de sistema, tablas de la base de datos, vistas en la Base de Datos.
SYSTAB system view
Each row of the SYSTAB system view describes one table or view in the database. Additional
information for views can be found in the SYSVIEW system view. The underlying system table for
this view is ISYSTAB.
The SYSTAB view is a SQL Anywhere system view. See "SYSTAB system view" in SQL Anywhere Server – SQL Reference.
SysObject: Describe un objeto de la Base de Datos.
SYSOBJECT system view
Each row in the SYSOBJECT system view describes a database object. The underlying system table for this view is ISYSOBJECT.
The SYSOBJECT view is a SQL Anywhere system view. See "SYSOBJECT system view" in SQL Anywhere Server – SQL Reference.
*/
Select T. Table_ID as ID, T.Table_Name as Tabla, T.Count as Registros,
Count(*) as Columnas, U.User_Name as Usuario,
list(C.Column_name) AS Campos
From (SysObject as O
join SysTab as T on O.Object_ID = T.Object_ID
join SysColumn as C on C.Table_ID = T.Table_ID)
join SysUser as U
--SysColumn as C on (C.Table_ID = T.Table_ID)
Where U.User_Name = 'DBA' or
U.User_Name = 'DBO' -- Tablas del sistema
Group by T.Table_ID, T.Table_Name, T.Count, U.User_Name
Order By 2
El de arriba funciona, basado en el de abajo.
That's easy:
select table_name, count
from systable
where primary_root<>0 and creator=1
order by 1
or how about adding the column counts and names?
select t.table_name, t.count rows, count(*) cols,
list(c.column_name order by c.column_id) col_list
from systable t
left outer join syscolumn c on c.table_id=t.table_id
where t.primary_root<>0 and t.creator=1
group by t.table_name, t.count
order by 1
Hope this helps...
Further information: systable and syscolumn are, since SQL Anywhere 10, only legacy-backwards-compatibility views and Sybase suggests using newer system tables instead... Since I am using version 9 and 11, I stick with these.
TAMBIEN ESTO
select table_name from sys.systab where table_type_str = 'BASE'
DOCUMENTACION OFICIAL
http://dcx.sap.com/1200/fr/dbusage/showingsysobjects.html
http://dcx.sybase.com/1201/en/dbadmin/lookinguptablesprocs-isql.html
http://dcx.sybase.com/1101/en/dbusage_en11/first-order-formatting.html
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.sqlanywhere.12.0.1/dbreference/select-statement.html
https://sqlanywhere-forum.sap.com/questions/14713/is-the-limit-statement-supported-in-a-query