While creating the table we need to follow below rules:
- The user should have CREATE TABLE privilege.
- The table name should starts with letter.
- The table name 1-30 characters long.
- Table name cannot be duplicate with other objects.
- Table name should not be oracle server reserved word.
Syntax:
CREATE TABLE Table_Name (Column_Name1 1<Data_type> [size],Column_Name2 <Data_type>[size],...);
Example:
If you try to create with same column name in same table, it will show you below error
Two columns can't have same name in same table :
CREATE TABLE STUDENTS
(STUDNO NUMBER(6),FNAME VARCHAR2(30),LNAME VARCHAR2(30),
DOB DATE,DOJ DATE,FEES NUMBER(7,2),
GENDER VARCHAR2(1),INSERTBY VARCHAR2(10));
If you try to create with same column name in same table, it will show you below error
Two columns can't have same name in same table :
create table col_same_name(col1 varchar2(10),col1 number);
ORA-00957: duplicate column name
If you want to create a table in your database with existing table structure than follow the below SQL.
CREATE TABLE STUDENTS_TBL AS SELECT * FROM STUDENTS WHERE 1=2;
CREATE TABLE STUDENTS_TAB AS SELECT * FROM STUDENTS;
List Of Error |
---|
ORA-00972: identifier is too long |
ORA-00955: name is already used by an existing object |
ORA-00903: invalid table name |
ORA-00957: duplicate column name |
No comments:
Post a Comment