Write SQL statement to create a table
The CREATE TABLE statement is used to create a new table in a database
Syntax of Table Creation
CREATE TABLE TABLE_NAME (colName1 datatype constraint,colName2 datatype constraint,....);
Query: Create EMPLOYEE table statement
create table Employee (ID number not null constraint employee_pk primary key,Name varchar2(20) not null ,Salary number,DepartmentID number not null ,DOJ date not null);/
Query: Create a new table from the existing table without data
CREATE TABLE TmpEmployee asSELECT * FROM Employee where 1=2;
Query: Create a new table from the existing table with data
CREATE TABLE TmpEmployee asSELECT * FROM Employee where 1=1;
Related post
- Write SQL INSERT queries
- Create a table from another table with data, without data, filtered data, and specific columns
No comments:
Post a Comment