Icon Creating, Altering, or Dropping Database Objects

Database objects are objects that are stored in an ElevateDB database catalog, which is represented by the special system-created Information schema in every ElevateDB database. Creating, altering, or dropping database objects can be accomplished by using the TEDBDatabase Execute method to execute the desired DDL statement against the target database. This method is always set to execute any passed SQL statement from the context of the target database, which makes it ideal for use in creating, altering, or dropping database objects such as tables, indexes, triggers, views, functions, and procedures with a minimal amount of work.

The following example shows how to create a table called "Customer" using the CREATE TABLE DDL (Data Definition Language) statement:

// This example uses a database component that
// has already been created and opened
// called MyDatabase

with MyDatabase do
   Execute('CREATE TABLE "Customer" '+
           '('+
           '"ID" INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1), '+
           '"Name" VARCHAR(30) COLLATE "ANSI_CI", '+
           '"Address1" VARCHAR(40) COLLATE "ANSI_CI", '+
           '"Address2" VARCHAR(40) COLLATE "ANSI_CI", '+
           '"City" VARCHAR(30) COLLATE "ANSI_CI", '+
           '"State" CHAR(2) COLLATE "ANSI_CI", '+
           '"Zip" CHAR(10) COLLATE "ANSI_CI", '+
           '"CreatedOn" TIMESTAMP DEFAULT CURRENT_TIMESTAMP, '+
           'CONSTRAINT "ID_PrimaryKey" PRIMARY KEY ("ID"), '+
           'CONSTRAINT "ID_Check" CHECK (ID IS NOT NULL), '+
           'CONSTRAINT "Name_Check" CHECK (Name IS NOT NULL)'+
           ')');

Database Object DDL Statements
The following DDL statements can be used to manipulate the various database objects available in a database catalog:

   • CREATE TABLE
   • ALTER TABLE
   • DROP TABLE
   • RENAME TABLE
   • CREATE INDEX
   • CREATE TEXT INDEX
   • ALTER INDEX
   • DROP INDEX
   • RENAME INDEX
   • CREATE TRIGGER
   • ALTER TRIGGER
   • DROP TRIGGER
   • RENAME TRIGGER
   • CREATE VIEW
   • ALTER VIEW
   • DROP VIEW
   • RENAME VIEW
   • CREATE FUNCTION
   • ALTER FUNCTION
   • DROP FUNCTION
   • RENAME FUNCTION
   • CREATE PROCEDURE
   • ALTER PROCEDURE
   • DROP PROCEDURE
   • RENAME PROCEDURE

Please see the User Security topic for more information on the required privileges to execute the above DDL statements.

Information Keep in mind that Linux has a case-sensitive file system when specifying path names in any SQL.
Image