postgres创建和数据表相同结构的表的方法
来源:互联网 发布:微软人工智能培训机构 编辑:程序博客网 时间:2024/06/06 02:41
highgo=# select * from test;
id
------
1
1
1
1
1
100
200
300
400
400
1000
2000
3000
3000
3000
1
(16 rows)
highgo=# create table testa as select * from test; -此方式即有表结构又包含数据
SELECT 16
highgo=# create table testb (like test); --此方式仅创建表结构,没有数据
CREATE TABLE
highgo=#
highgo=# select * from testa;
id
------
1
1
1
1
1
100
200
300
400
400
1000
2000
3000
3000
3000
1
(16 rows)
highgo=# select * from testb;
id
----
(0 rows)
highgo=# create table testc as select * from test with no data; ---此方式效果和like方式相同
CREATE TABLE AS
highgo=#
highgo=# select * from testc;
id
----
(0 rows)
使用like方式时,有如下选项:
highgo=# create table testc as select * from test with no data including all;
错误: 语法错误 在 "including" 或附近的
LINE 1: ...te table testc as select * from test with no data including ...
^
highgo=#
highgo=# create table testd (like test) including all;
错误: 语法错误 在 "including" 或附近的
LINE 1: create table testd (like test) including all;
^
highgo=# create table testd (like test including all);
CREATE TABLE
including default
including constraints
including indexes
including storage
including comments
including all---把所有属性都复制过去
id
------
1
1
1
1
1
100
200
300
400
400
1000
2000
3000
3000
3000
1
(16 rows)
highgo=# create table testa as select * from test; -此方式即有表结构又包含数据
SELECT 16
highgo=# create table testb (like test); --此方式仅创建表结构,没有数据
CREATE TABLE
highgo=#
highgo=# select * from testa;
id
------
1
1
1
1
1
100
200
300
400
400
1000
2000
3000
3000
3000
1
(16 rows)
highgo=# select * from testb;
id
----
(0 rows)
highgo=# create table testc as select * from test with no data; ---此方式效果和like方式相同
CREATE TABLE AS
highgo=#
highgo=# select * from testc;
id
----
(0 rows)
使用like方式时,有如下选项:
highgo=# create table testc as select * from test with no data including all;
错误: 语法错误 在 "including" 或附近的
LINE 1: ...te table testc as select * from test with no data including ...
^
highgo=#
highgo=# create table testd (like test) including all;
错误: 语法错误 在 "including" 或附近的
LINE 1: create table testd (like test) including all;
^
highgo=# create table testd (like test including all);
CREATE TABLE
including default
including constraints
including indexes
including storage
including comments
including all---把所有属性都复制过去
阅读全文
0 0
- postgres创建和数据表相同结构的表的方法
- 创建与已有数据表结构相同的表
- postgres数据表行转列的方法
- mysql快速创建和已有表相同表结构的表
- SQL语句创建相同结构的表
- 合并结构相同的表的方法
- 创建数据表的一种方法
- Postgres的搭建配置和创建
- 拼接多个相同结构的数据表,并剔出重复
- arcengine,按相同的表结构创建表
- 快速创建与现有表相同结构的表
- 创建一个与已知表相同的 表结构
- 创建与原有表结构相同的空白表
- mysql如何快速创建相同结构的表
- 连接postgres的方法
- jdbctemplate 获取数据表结构的方法&注意事项
- MySQL入门--创建数据表、显示指定数据库的数据表、查看数据表结构
- MySQL入门--创建数据表、显示指定数据库的数据表、查看数据表结构
- 0xC0000005: 写入位置 0x00000000 时发生访问冲突
- Android-SnackBar
- 解压文件报错:gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverabl
- [BZOJ]1835: [ZJOI2010]base 基站选址 线段树+DP
- AJAX技术
- postgres创建和数据表相同结构的表的方法
- mysql学习
- 实验二:命令行菜单小程序V1.0
- AutoCompleteTextView与MultiAutoCompleteTextView简单使用
- (三)自己写一个HelloWorld类
- Spring AOP 切点语法详解
- 数据结构思维 第九章 `Map`接口
- 5G 商业模式的思索?
- 使用iptables实现etcd集群白名单功能