- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a table TAB2 having same attributes & columns as for table TAB1
DB2 gives us an option to copy the structure of an existing table to a new table. To copy the attributes and column of table TAB1 to a new table TAB2 we can use the following command−
CREATE TABLE DBSET1.TAB2 LIKE DBSET1.TAB1
The CREATE TABLE reserved words are followed by table name. The table name needs to be qualified by a database in which it will reside. In this case this new table is TAB2 and its database is DBSET1.
The LIKE parameter is used after that followed by the name of the original table qualified by its database i.e. DBSET1.TAB1
The important point to note here is, primary and foreign keys are not inherited automatically and we have to define them using the ALTER table command on the new table.
- Related Articles
- How to create an ALIAS TAB2 for DB2 table TAB1?
- How do we include attributes for table columns in HTML?
- How to create a DB2 table TAB1 with 4 columns, Student ID, Enrollment ID, Name and Age?
- How to delete a DB2 table TAB1?
- How to create a view on table TAB1 for column Name, age, enrollmentId & age > 10 years. >
- How to do a full & incremental MERGECOPY for a DB2 table TAB1?
- How to find out all the indexes for a DB2 table TAB1?
- How to create table rows & columns in HTML?
- How to add a row compression to a DB2 table TAB1?
- How to find the primary key of a DB2 table TAB1?
- How to create conditions in a MySQL table with multiple columns?
- How can create a table having the name like a^b along with same column name?\nname?
- How do I use `SHOW COLUMNS` as a valid data source for a table?
- How to image copy the entire DB2 table TAB1 into a dataset?
- How to find all the foreign keys of a DB2 table TAB1?

Advertisements