Home | Concepts | API | Samples |
Concepts > Schema Objects > Tables | |
Managing Tables | |
Creating DBMS tables ArcSDE provides a DBMS independent mechanism for creating tables. The SE_table_create function takes a table name and a list of column types as input. The column types are defined independently of DBMS, using the following ArcSDE data types: SE_SMALLINT_TYPE The ArcSDE data types are mapped to DBMS types differently for each DBMS. See the ArcGIS Server or ArcGIS Desktop help topic About data types for the exact values. When you are defining a column, you need to define the size and, optionally, number of decimal digits. For integer, date, and small integer columns, the size and decimal digits are zero. For float and double columns, the size and decimal digits represent the column definition. For string (character) and BLOB columns, the size represents the column definition and the decimal digits equals zero. You need to remember to add 1 to the size for the null terminator for string type columns. You can define DBMS-specific column types using SQL expressions executed through SE_stream_prepare_sql. There are no assurances that tables created with SE_stream_prepare_sql are transportable between different database management systems. In this example, you create a three column table named cities. The table
contains the following columns: num_cols = 3; This next example creates the same table using an SQL statement and the SE_stream_prepare_sql function. Keep in mind that this approach may not be transportable across multiple DBMS platforms. sprintf (sql_stmt, "create table cities (%s, %s, %s)", Describing DBMS tables In order to obtain the column definitions of a business table, the SE_table_describe() function can be used. This functions takes the connection, table name, pointer to SE_COLUMN_DEF structure, and number of columns as input and populates the SE_COLUMN_DEF structure with column definitions. SE_COLUMN_DEF *pcoldef=NULL; Deleting DBMS tables DBMS tables can be deleted in a DBMS-independent fashion through the SE_table_delete function. When a table is spatially enabled, SE_table_delete deletes the business table, the feature table, the spatial index tables, and entries in the LAYERS table. rc = SE_table_delete (Connection, "Cities"); You can also delete tables with an SQL expression, using SE_stream_prepare_sql.
Do not use this approach to delete spatially enabled tables, because the support
tables (feature, index) and LAYERS entry are left behind. This example deletes a nonspatial table called taxes. rc = SE_stream_prepare_sql (Stream, "drop table taxes"); Indexing a column You can add and drop an index on a column with SE_table_create_index and SE_table_delete_index. Indexes can be ascending, descending, or unique. The following example adds an index to the cities table created earlier. The table has three columns: city_name, area, and population. This example creates an ascending index on the city_name column.
/* Create an ascending index called name_index on the city_name column */ This next example creates the same column index using an SQL statement and the SE_stream_prepare_sql function. Keep in mind that this approach may not be transportable across multiple DBMS platforms.
sprintf (sql_stmt, "create index name_index on cities (city_name ASC)"); |
feedback |
privacy |
legal |