Link to home
Start Free TrialLog in
Avatar of fangtan
fangtan

asked on

How to get all tables?

I am inserting " CREATE TABLE " and " CREATE TRIGGER " into Sybase using WISQL32.  After I finish, I want to view all my tables and triggers there.  What is the command to do this in Sybase?
Avatar of dk99
dk99

You need to use the following commands :

1. To view all your tables :

 use database name
go
select name from sysobjects where type = "U"
go

2. To view the names of all your triggers :

use database name
go
select name from sysobjects where type = "TR"
go

Note : database name is the database in which you created the tables and triggers. other wise it shows from your default database.
If you want to see all details of your tables and triggers you can use * ( wild character) instead of name ( i,e select * from sysobjects where type = "U" or type = "TR" )

This will work for you.

Thanks
DK99
Avatar of fangtan

ASKER

I tried it. It didn't work.  This is the error I am getting:

com.sybase.jdbc.SybSQLException: Invalid column name "U". Cancelling...

fang
Avatar of fangtan

ASKER

I tried to use sp_help.  But the disadvantage is that I have to provide the table name.  
For example: sp_help Course.  
If I only use sp_help withough any argument, I will not see the fields of the table.

fang
If this is giving you an error, somethings the matter:

select name from sysobjects where type = "U"


I use this all the time and it works. Did you type this in? Did you copy/paste and something went wrong?

David
ASKER CERTIFIED SOLUTION
Avatar of dk99
dk99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fangtan

ASKER

I don't have name for my database.  I typed
use go select * from sysobjects where type = "U" go

I got incorrect syntax near go.
Avatar of fangtan

ASKER

I don't have name for my database.  I typed
use go select * from sysobjects where type = "U" go

I got incorrect syntax near go.
Don't use "go". and don't type "use" without a database name following it. Just type the select statement, whithout a go at the end and execute it.
Avatar of fangtan

ASKER

I don't have name for my database.  I typed
use go select * from sysobjects where type = "U" go

I got incorrect syntax near go.
Avatar of fangtan

ASKER

I also tried
select * from sysobjects where type = "U"

but that is the first error message I got: invalid column name "U".  

By the way, since I am away from school, I am using Isql applet from deparment's website to access sybase.  I don't know if that matters.

fang
If you do not know the database name where you created the tables and triggers then try the following steps :

1. Connect to sybase server through your isql applet. Use the command
 select db_name(). This will say your current default database.

2. You can use the commands what  I had written to you.
     select name from sysobjects where type = "U"
 and execute the query.
3. If you are not getting  your table names, that means your tables are created in some other databases. you can use the command sp_helpdb
to see what are the databases available in your server. Or you can use the query  ( select name from master..sysdatabases) to see the name of the databases.
4. After getting the name of databases, use the database name one by one and verify with the command  ( select name from sysobjects where type = "U") to find your objects.

Hope this will work for you this time.

Thanks...
Use single quotes.

select name from sysobjects where type = 'U'


I also cut and paste
select name from sysobjects where type = "U"

and got the following error

Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'U'.

Using single quotes returned the table names I needed.