Friday, 8 June 2018

CREATE TABLE in Oracle SQL Simple version

CREATE TABLE in Oracle SQL Simple version


Simple table creation in Oracle SQL

[Note: in the syntax below, the contents of angular brackets along with angular brackets to be replaced with user defined words. Refer example below]

Syntax:
CREATE TABLE <tablename> (
<column name1> <datatype>,
<column name 2> <datatype>,
<column name 3> < datatype>,
<column name n> < datatype>
);


  • This DDL statement creates a table with n attributes. This is the simplest of table creation.
  • Some of the basic data types are CHAR, VARCHAR, DATE, and NUMBER.

Example:
CREATE TABLE Furnitures (
Furniture_ID CHAR(5),
Furniture_Name VARCHAR(25),
Manufacturer VARCHAR(25),
Quantity NUMBER(5)
);


  • This statement will create the table FURNITURES with the following attributes;
    • FURNITURE_ID - character attribute stores alpha-numeric characters,
    • FURNITURE_NAME - variable length character attribute stores alpha-numeric characters,
    • MANUFACTURER - variable length character attribute stores alpha-numeric characters and
    • QUANTITY - number attribute stores numbers only.
  • Each record that will be stored in this table will occupy maximum of 60 bytes (Furniture_id 5 bytes + Furniture_name 25 bytes + Manufacturer 25 bytes + Quantity 5 bytes = 60 bytes).
  • The details regarding the names of the table and its attributes, types of the attributes and size of the attributes all will be stored in the data dictionary. [Note: for MySQL the data dictionary is called Information schema and for Oracle database it is Oracle metadata]
  • This statement will not include any additional constraints other than data type and size.

****************



 
 



No comments:

Post a Comment

Find candidate key and normalize the relation into 2nf and 3nf

Find candidate key and normalize the relation into 2nf and 3nf Question: A relation R is defined as follows. R = (name, stre...