SQL::TableInfo Class
Description
Functions for inspecting information about tables.
Discussion
The SQL::TableInfo object returns information about a database table. It can be useful when importing data from or exporting data to back-end tables. The easiest way to get a SQL::TableInfo object is to use the SQL::Connection::GetTableInfo() method. The following code was run in the Interactive window.
dim conn as SQL::Connection dim ti as SQL::TableInfo ' Define the connection string and open the connection. ? conn.open("{A5API=Access,FileName='C:\Program Files\a5v8\MDBFiles\Alphasports.mdb',UserName='Admin'}") = .T. ' Get the TableInfo ? conn.GetTableInfo(ti, "customer") = .T.
Note that the SQL::TableInfo object is passed as an argument, along with the name of the table to investigate.
Properties and methods of the SQL::TableInfo object are listed below.
Properties
- XMLCharacter
The schema in XML format.
- TableTypeSQL::TableType
An enumerated type describing the table type.
- TableTypeNameCharacter
This is the displayable name of the enumeration value in TypeName.
? tt.TableType = -1 ? tt.TableTypeName = "Invalid" tt.tabletype = View ? tt.TableType = 1 ? tt.TableTypeName = "View"
- CatalogCharacter
Catalog property
- SchemaCharacter
Schema property
- OwnerCharacter
The database user or group that owns the table.
- TableNameCharacter
TableName property
- UniqueNameCharacter
A concatenation of the owner (if any) and name properties.
- NameCharacter
The unique name of the table. The table must be unique for the owner, but need 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.
- AliasCharacter
Alias property
- UpdateableLogical
True (.T.) if the table is updatable.
- CanUpdateInTransactionLogical
If a table has a large text or binary column and the database can not cache updates for multiple rows, this value will be false.
- SizeToFitLogical
When set to true, . DBFRowSyntax will return lengths adjusted based on the actual data. Notes:
Call .UpdateStatistics() before getting the DBFRowSyntax. If the longest column is zero length, the default length is 15. SizeToFit will limit the size of inserted or updated fields on imported or linked tables to the maximum size of the previous values.- SelectRowLimitNumeric
Defaults to -1 (no limit). This property is used when generating select statements to limit the number of rows retrieved.
- SelectRowStartingOffsetNumeric
SelectRowStartingOffset property
- LastKnownRowCountNumeric
Set by calling .UpdateStatistics().
- DBFRowSyntaxCharacter
The DBFRowSyntax property shows how to define a DBF table with the same columns and data as the source database.
? ti.Name = "customer" ? ti.Updateable = .T. ? ti.NativeSyntax = "Access" ? ti.DBFRowSyntax = CUSTOMER_ID,N,10,0 FIRSTNAME,C,20,0 LASTNAME,C,20,0 COMPANY,C,32,0 PHONE,C,20,0 FAX,C,20,0 BILL_ADDRESS1,C,40,0 BILL_ADDRESS2,C,40,0 BILL_CITY,C,20,0 BILL_STATE_REGION,C,20,0 BILL_POSTAL_CODE,C,10,0 BILL_COUNTRY,C,20,0 SHIP_ADDRESS1,C,40,0 SHIP_ADDRESS2,C,40,0 SHIP_CITY,C,20,0 SHIP_STATE_REGION,C,20,0 SHIP_POSTAL_CODE,C,10,0 SHIP_COUNTRY,C,20,0 SHIP_SAME,L,1,0 EMAIL,C,60,0
- PrimaryKeyExpressionCharacter
The subscript value to use when referencing the Index property to access the primary key index. If there is no primary key defined, this property will have a value of -1. If the value is an integer greater than or equal to 1, the primary key may be accessed using the syntax IndexPrimaryKeySubscript.
- PrimaryKeySubscriptNumeric
PrimaryKeySubscript property
- IdentityColumnSubscriptNumeric
Returns the index of the column which is auto-increment or identity (-1 if none).
- QueryAliasCharacter
This is an advanced property used to get more information about a column.
The QueryAlias property is only populated when a query object ( SQL::Query, SQL::Statement, etc.) is validated. After calling SQL::Query::Validate, the query object has a SQL::ResultSet object (no data, just definitions). The TableInfo property of the SQL::ResultSet is an array of SQL::TableInfo objects that describe the tables in the FROM clause (this is used by the query genie to map select list columns to the source table definition to get more information about the actual column.
dim q as sql::query dim c as sql::connection ?c.open("{a5api=access,filename=c:\northwind.mdb,user=admin}") = .T. ?q.parse("select * from customers cust") = .T. ?q.validate(c) = .T. ?q.resultset.tableinfo1.queryalias = "cust"
- ColumnSQL::IndexColumnInfo[]
An array of index column ( SQL::IndexColumnInfo ) definitions.
- IndexSQL::IndexInfo[]
An array of index ( SQL::IndexInfo ) definitions.
- IdentitySequenceNameCharacter
IdentitySequenceName property
- ActiveLinkDBFRowSyntaxCharacter
ActiveLinkDBFRowSyntax property
Methods
- AddColumn Method
Add a Column.
- AddIndex Method
Add a Index.
- Clear Method
Reset the contents of the TableInfo as if it had just been declared.
- Clone Method
Create a copy of an object instance.
- ColumnIsInPrimaryKey Method
Checks if a specified column is part of a table's primary key.
- ColumnNumber Method
Get the index of a Column from the name.
- DeleteColumn Method
Delete a Column.
- DeleteIndex Method
Delete a Index.
- IndexNumber Method
Get the index of a Index from the name.
- InsertColumn Method
Insert a new Column.
- InsertIndex Method
Insert a new Index.
- ListColumns Method
Create a list of the table columns (optionally including types).
- MoveColumn Method
Move a block of Column items.
- MoveIndex Method
Move a block of Index items.
- ParseTableName Method
Parse a dot separated table name and return the components. Use brackets [] to wrap names with dots in them.
- UpdateStatistics Method
Gather statistical information about the actual table.
See Also