SQLTablePrimaryKeys[conn,table]
returns information about the columns comprising the primary key of table.
Details and Options
Examples
Basic Examples
See Also
Tech Notes
Related Guides
DatabaseLink`
DatabaseLink`
SQLTablePrimaryKeys
SQLTablePrimaryKeys[conn,table]
returns information about the columns comprising the primary key of table.
Details and Options
- To use SQLTablePrimaryKeys, you first need to load DatabaseLink using Needs["DatabaseLink`"].
- The following options can be given:
-
"Catalog" None database catalog to use "Schema" None database schema to use "ShowColumnHeadings" False whether to return headings with the results
Examples
Basic Examples (1)
Needs["DatabaseLink`"]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.
conn = OpenSQLConnection["demo"];Create a table with a primary key:
SQLCreateTable[conn, SQLTable["PEOPLE"], {SQLColumn["id", "DataTypeName" -> "Integer", "PrimaryKey" -> True], SQLColumn["Name", "DataTypeName" -> "VARCHAR", "DataLength" -> 255],
SQLColumn["Age", "DataTypeName" -> "Integer"]
}]Fetch primary key information for this table:
SQLTablePrimaryKeys[conn, "PEOPLE", "ShowColumnHeadings" -> True]//TableFormSQLDropTable[conn, "PEOPLE"]CloseSQLConnection[conn];