To create copy
of existing table use the following syntax
select */<Columnn List> into <New Table Name> From <Old Table Name>
eg.
folowing table create the copy of the table student
form with the name stud
select * into tbl_copy from student
insert
table with only specefic columns or
Conditions.
select * into tbl_Copy1 from tbl_Emp where FName='abhijit'
while
creating a table from another table if you dont
to
copy the data then specify a condition on the where clause which will be false
select * into student2 from Student where 1=0
Note
While creating a table from another table constraints
and indexes available on existing table
will not be copy to new table
------------------------------------------------------------
Inserting
Row from one table to Another Table:-
You can insert rows from one tables to another provided those
tables have columns with same datatype and for this use the following syntax of
insert statement.
insert into <Table Name> <Select Statment>
eg:
insert tbl_Copy(StudentId,FirstName ,LastName )select StudentId,FirstName,LastName from Student
0 comments:
Post a Comment