Create Table and Insert table command

CREATE TABLE Command Syntax

The screen shot above shows the use of Create Table and Insert table command Syntax in Oracle 10g. Oracle create table command, SQL create table command and mysql create table command has the same syntax. The same create table syntax is applicable for mysql create table syntax. While using the Create Command Syntax, requires that the column list to be enclosed within parentheses. A table can contain maximum of 1000 columns. To create a data table, the name, datatype, and appropriate width are listed for the first column before the next column is defined. CREATE TABLE command also allowes default value to be assigned to a column. Remember that Oracle 10g SQL commands are not case sensitive.

Create Table and Insert Table Command

CREATE TABLE [schema] tablename (column_name datatype [DEFAULT VALUE],
[column_name datatype [DEFAULT VALUE], ....);

To create a Table with same structure as the existing table with out data, subquery is used with a wrong condition as shown below;

CREATE TABLE [schema] tablename1 AS (SELECT * from tablename WHERE 2 < 1);

Create table with an existing table structure

INSERT COMMAND Syntax

Rows can be added to a new or existing table using the insert command. Oracle and SQL Insert Command have the same Syntax. The insert command syntax is shown below. Command following INSERT INTO is the name of the table into which the rows will be entered. The table name is followed by the names of the columns that will contain the data. If the data enterd in the VALUES clause is in the same order(and all the columns) as the columns in the table, column names can be omitted in the INSERT INTO clause.

INSERT INTO tablename [(column_name, ...)] values (datavalue1, ...);