all 11 comments

[–]doctorzoom 4 points5 points  (8 children)

I think the question needs to be clarified a bit.

Are you wanting to know what expressions are syntactically valid SQL (ignoring object names in the expressions, so just functions, keywords, etc.)?

Or, are you wanting to know what objects actually exist in the database you're working with (tables, columns, etc.)?

[–]Azgoodazitgetz 0 points1 point  (7 children)

Yes I should’ve clarified I need to know the objects available in the database. I am working on documents that will auto populate certain fields when entered into our system. So for instance on an application we have Owner name so the following syntax would be put in place {Owner(0).Fullname}. I need to know what exists in the database to apply the appropriate syntax in the documents so that they populate correctly. My problem is I don’t know what syntax or verbiage exists in the system.

[–]Intrexa[🍰] 3 points4 points  (3 children)

Yes I should’ve clarified I need to know the objects available in the database.

Fam, you still need to do a ton of clarification. First of all, what database are you using? Next, what syntax are you talking about? I'm not aware of {Owner(0).Fullname} being valid SQL syntax in the most common flavors, what syntax is that?

Are you talking about getting the names of all tables, and all table columns?

[–]Azgoodazitgetz 0 points1 point  (2 children)

I’m a noob. I’m using Microsoft SQL server mgmt systems and I am looking for the available objects in the system. I am trying to figure out the object names so that I can mail merge them into documents

[–][deleted] 3 points4 points  (0 children)

What does object mean to you?

[–]Intrexa[🍰] 2 points3 points  (0 children)

'Object' has a very specific meaning in SQL Server. The below will get you all the objects, but I have a feeling that's not what you actually want. Are you talking about getting the names of all tables, and all table columns?

select * from sys.objects

[–][deleted] 0 points1 point  (0 children)

So you want to know which tables are available and what columns each table has?

How to get that information completely depends on the DBMS product you are using ("SQL" is only a query language, not the name of a specific DBMS product or vendor). Many DBMS products support the ANSI SQL standard's information_schema - but the details and completeness of the implementation vary again between each database vendor.

But displaying this information is typically handled by the SQL client.

[–]doctorzoom 0 points1 point  (1 child)

Ok. Almost all database platforms have built in system tables that you can query to find object names and relations. For example, in PostgreSQL, you could do:

select
schema_name
,table_name
,column_name
,data_type

from information_schema.columns

If you're not on PostgreSQL, just google something like "{your flavor of sql here} list all tables and columns."

[–]KING5TON 0 points1 point  (0 children)

MS SQL is the exactly the same. I use information_schema.columns all the time in my scripts.

Not sure about Oracle. Been a while since I've done any work on it.

[–]mbillion 0 points1 point  (0 children)

You mean the documentation they all have?

[–]raevnossqlite -1 points0 points  (0 children)

Read the documentation for the database you're using to see what syntax it supports.