General Table Guidelines
The following guidelines provide helpful hints for you to follow as you implement and manage tables within your DB2 applications and systems.
Use LIKE To Duplicate a Table’s Schema
Use the LIKE
clause to create a table with the same columns as another table or view. The following SQL creates a new table OLD_PROJ
using the PROJ
table as a template:
CREATE TABLE DSN81010.OLD_PROJLIKE DSN81010.PROJIN db.ts;
The LIKE
clause is particularly useful in the following instances:
• When creating exception tables required by the CHECK
utility
• When multiple instances of a similar table must be created
• When creating a PLAN_TABLE
• When creating the same table for multiple users
Use a Fullselect to Define a Table’s Schema
You can ...
Get DB2 Developer’s Guide: A Solutions-Oriented Approach to Learning the Foundation and Capabilities of DB2 for z/OS, Sixth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.