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?
LVL 1
fangtanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dk99Commented:
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
0
fangtanAuthor Commented:
I tried it. It didn't work.  This is the error I am getting:

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

fang
0
fangtanAuthor Commented:
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
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

david_levineCommented:
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
0
dk99Commented:
Hi Fangtan,

You check your typing first. I don't think you will get any other answer to your question. To view the name of the user tables and triggers, that is the good way to get this. If this does not work, must be something wrong in typing. Try to write the query exactly what I had written.  If you want to see all the fields of a table, then sp_hep table_name is the easiest way to view the table structure. It is obivious if you write command sp_help only, you will see all the objects name ( system & user tables, procedures,triggers,views ).

Good Luck.
DK99
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fangtanAuthor Commented:
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.
0
fangtanAuthor Commented:
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.
0
david_levineCommented:
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.
0
fangtanAuthor Commented:
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.
0
fangtanAuthor Commented:
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
0
dk99Commented:
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...
0
DarebearCommented:
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.


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.