7

In sql server 2012 i'm using

USE myDatabase;
GO
SELECT  *
FROM    sys.objects
WHERE   type = 'U';

Is it possible to do the same in syBase ?

CM2K
  • 833
  • 3
  • 18
  • 38

3 Answers3

15

In order to get a list of all tables in the current database, you can filter the sysobjects table by type = ā€˜U’ e.g.:

select convert(varchar(30),o.name) AS table_name
from sysobjects o
where type = 'U'
order by table_name

Further Reference

Here is an example of getting all table names in MSSQL or SQL Server database:

USE test; //SELECT DATABASE
SELECT table_name FROM information_schema.tables WHERE table_type = 'base table'

or you can use sys.tables to get all table names from selected database as shown in following SQL query

USE test; //SELECT DATABASE
SELECT * FROM sys.tables

That's all on how to find all table names from database in SQL Server.

Anantha Raju C
  • 1,780
  • 12
  • 25
  • 35
  • NB: Be careful with the Varchar size - I copied and pasted the above and found some of my table names were truncated so ensure you adjust as necessary. – Danny Aug 14 '20 at 11:04
1

For SQL Anywhere 16, this query works fine.

select * from sys.SYSTABLE

It gives a list of the table_names along with the information like table id, table page count, etc.

4b0
  • 21,981
  • 30
  • 95
  • 142
0

In order to list all the tables and rows count, the following query can be used.

select convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count
from sysobjects o
where type = 'U'
order by table_name

In order get a list of tables which has the table name like, use the following query.

Here table_name has to be replaced with your desired name.

select convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count
from sysobjects o
where type = 'U' and o.name like '%table_name%'
order by table_name
4b0
  • 21,981
  • 30
  • 95
  • 142
Nivin John
  • 173
  • 1
  • 11