DatabaseLink`
DatabaseLink`

SQLColumnNames

SQLColumnNames[conn]

returns a list of {table,name} pairs for each column in an SQL connection.

SQLColumnNames[conn,table]

returns a list of the columns in table.

SQLColumnNames[conn,SQLTable[table]]

returns a list of the columns in table.

SQLColumnNames[conn,{table,column}]

returns a list of the columns in table matching column.

SQLColumnNames[conn,SQLColumn[{table,column}]]

returns a list of the columns in table matching column.

SQLColumnNames[conn,SQLColumn[column]]

returns a list of the columns in any table matching column.

Details

  • To use SQLColumnNames, you first need to load DatabaseLink using Needs["DatabaseLink`"].
  • Table and column specifications may include SQL wildcards.
  • The following options can be given:
  • "Catalog"Nonedatabase catalog to use
    "Schema"Nonedatabase schema to use

Examples

Basic Examples  (1)

If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the "DatabaseLink`DatabaseExamples`" package, as described in Using the Example Databases.

Open a connection:

Get {table,column} pairs from tables whose names start with "SA":

Get {table,column} pairs from a particular table:

Here is another way:

Get {table,column} pairs for columns whose names begin with "V" in any table:

Equivalently:

Here is another way:

Extract just the column names: