Performing Data Definition Language Statements


The SQL Data Definition Language (DDL) statements are used to create database users, tables, and many other types of database structures that make up a database. DDL consists of statements such as CREATE , ALTER , DROP , TRUNCATE , and RENAME . DDL statements may be performed in JDBC using the execute() method of the Statement class. In the following example, the CREATE TABLE statement is used to create a table named addresses , which may be used to store customer addresses:

 myStatement.execute("CREATE TABLE addresses (" +  " address_id INTEGER CONSTRAINT addresses_pk PRIMARY KEY," +  " customer_id INTEGER CONSTRAINT addresses_fk_customers " +  " REFERENCES customers(customer_id)," +  " street VARCHAR2(20) NOT NULL," +  " city VARCHAR2(20) NOT NULL," +  " state CHAR(2) NOT NULL" +  ")"); 
Note  

Performing a DDL statement results in an implicit commit being issued. Therefore, if you ve performed uncommitted DML statements prior to issuing a DDL statement, those DML statements will also be committed.




Oracle Database 10g SQL
Oracle Database 10g SQL (Osborne ORACLE Press Series)
ISBN: 0072229810
EAN: 2147483647
Year: 2004
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net