CREATE Table Example
CREATE Table Example
Following is an example, which creates a CUSTOMERS table with ID as primary key and NOT NULL are the constraints showing that these fields can not be NULL while creating records in this table:SQL> CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
PRIMARY KEY (ID)
);
You can verify if your table has been created successfully by using DESC command as follows:
SQL> DESC CUSTOMERS;
Field | Type | Null | Key | Default | Extra
--------+---------------+------+-----+---------+------
ID | int(11) | NO | PRI | |
NAME | varchar(20) | NO | | |
AGE | int(11) | NO | | |
ADDRESS | char(25) | YES | | NULL |
Read more.
Login in to like
Login in to comment