Home > Database > Mysql Tutorial > How to Create an Empty Table Copy with the Same Schema as an Existing Table in Oracle?

How to Create an Empty Table Copy with the Same Schema as an Existing Table in Oracle?

Mary-Kate Olsen
Release: 2025-01-02 14:52:38
Original
499 people have browsed it

How to Create an Empty Table Copy with the Same Schema as an Existing Table in Oracle?

Creating a Table Copy Without Data in Oracle

Original Query:

"I am aware of the statement:

create table xyz_new as select * from xyz;
Copy after login

which duplicates both the schema and the data. However, what if I only need the schema?"

Solution:

To create a table copy without copying the data, simply add a WHERE clause that filters out all rows:

create table xyz_new as select * from xyz where 1=0;
Copy after login

This technique copies the table structure (columns, data types, constraints) without populating the table with any data.

Limitations:

While this method is efficient for copying the table structure, it has certain limitations:

  • Sequences, triggers, indexes, materialized view logs, and some constraints may not be copied.
  • Partitions are not handled by this method.

The above is the detailed content of How to Create an Empty Table Copy with the Same Schema as an Existing Table in Oracle?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template