ITPub博客

首页 > 数据库 > > CUBRID学习笔记 30 复制表结构 cubrid教程

CUBRID学习笔记 30 复制表结构 cubrid教程

作者:LCR_ 时间:2022-04-08 10:46:13 0 删除 编辑
语法

CREATE {TABLE | CLASS} <new_table_name> LIKE <old_table_name

如下

CREATE TABLE a_tbl(

id INT NOT NULL DEFAULT 0 PRIMARY KEY,

phone VARCHAR(10));

INSERT INTO a_tbl VALUES(1,'111-1111'), (2,'222-2222'), (3, '333-3333');

 

--creating an empty table with the same schema as a_tbl

CREATE TABLE new_tbl LIKE a_tbl;

SELECT * FROM new_tbl;

There are no results.

;schema a_tbl

=== <Help: Schema of a Class> ===

 <Class Name>

 a_tbl

 <Attributes>

     id                   INTEGER DEFAULT 0 NOT NULL

     phone                CHARACTER VARYING(10)

 <Constraints>

     PRIMARY KEY pk_a_tbl_id ON a_tbl (id)

Current transaction has been committed.

;schema new_tbl

=== <Help: Schema of a Class> ===

 <Class Name>

     new_tbl

 <Attributes>

     id                   INTEGER DEFAULT 0 NOT NULL

     phone                CHARACTER VARYING(10)

 <Constraints>

     PRIMARY KEY pk_new_tbl_id ON new_tbl (id)

Current transaction has been committed.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70000523/viewspace-3124386/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: mnesia
请登录后发表评论 登录
全部评论

注册时间:2022-02-22

  • 博文量
    1402
  • 访问量
    15039