SQL::Schema Object
Description
SQL::Schema Object properties and methods.
A SQL::Schema object (a database description) is a container for one or more SQL::TableInfo objects (table descriptions).
Discussion
This example creates an array containing five SQL::TableInfo objects.
dim ti as SQL::TableInfo dim arr[5] as P arr[1] = ti for i = 2 to 5 arr[i] = ti.clone() next i
Example
This example interactive window session shows how to use the sql::schema object and the tablesReferencing and tablesReferencedBy methods of the sql::schema object. The connection string is pointing to a SQL Server version of Northwind.
dim cn as sql::connection ?cn.open("::Name::nw") = .T. dim s as sql::Schema ?cn.GetSchema(s) = .T. ?s.TableNumber("customers") = 2 dim tiCustomer as sql::TableInfo tiCustomers = s.table[2] r1 = s.TablesReferencedBy(tiCustomers) ?r1.table.count = 0 r2 = s.TablesReferencing(tiCustomers) ?r2.table.Count = 1 ?r2.table1.name = "Orders" dim tiOrders as sql::TableInfo ?s.tableNumber("orders") = 5 tiOrders = s.table[5] r3 = s.TablesReferencedBy(tiOrders) ?r3.Table.count = 3 ?r3.table[1].name = "Customers" ?r3.table[2].name = "Employees" ?r3.table[3].name = "Shippers" r4 = s.TablesReferencing(tiOrders) ?r4.Table.count = 1 ?r4.table[1].name = "Order Details"
Properties
- XMLCharacter
The schema in XML format.
- NameCharacter
The unique name of the table. Note: The table must be unique for the owner, but may not be globally unique.
- NativeAPICharacter
The name of the API active when this object was created.
- NativeSyntaxCharacter
The name of the syntax at the time the object was created.
- CommentCharacter
The comment stored for the table (if the database supports it).
- OwnerCharacter
The SQL database user or group that owns the table.
- CatalogCharacter
String Catalog property
- SchemaCharacter
String Schema property
- TableSQL::TableInfo[]
An array of table ( SQL::TableInfo ) definitions.
- TableInDependencyOrderSQL::TableInfo[]
An array of table ( SQL::TableInfo ) definitions ordered from the top of the dependency hierarchy.
- CallResultSQL::CallResult
CallResult property
Methods
- AddTable Method
Add a Table.
- Clear Method
The Clear() method clears out the schema as if it had just been created.
- Clone Method
The SQL::Schema.Clone() method makes a copy of a SQL::Schema object and its properties.
- ListTables Method
The ListTables() method returns a list of tables in the current cache for the current database.
- ListTablesWithTypes Method
Return a list of tables for the current database suffixed with (<type>).
- TableNumber Method
Get the index of a Table from the name.
- TablesReferencedBy Method
Generate a collection of tables referenced by this table.
- TablesReferencing Method
Generate a collection of tables that reference this table.
- UpdateStatistics Method
Gather statistical information about the actual tables in the schema.
See Also