MogDB/openGauss学习笔记-获取对象DDL
MogDB/openGauss 学习笔记-获取对象 DDL
本文出处:https://www.modb.pro/db/399230
内置函数
omm2=# \df *def List of functions Schema | Name | Result data type | Argument data types | Type | fencedmode | propackage | prokind ------------+----------------------+------------------+----------------------------------------------------------+--------+------------+------------+--------- pg_catalog | pg_get_constraintdef | text | oid | normal | f | f | f pg_catalog | pg_get_constraintdef | text | oid, boolean | normal | f | f | f pg_catalog | pg_get_functiondef | record | funcid oid, OUT headerlines integer, OUT definition text | normal | f | f | f pg_catalog | pg_get_indexdef | text | oid | normal | f | f | f pg_catalog | pg_get_indexdef | text | oid, boolean | normal | f | f | f pg_catalog | pg_get_indexdef | text | oid, integer, boolean | normal | f | f | f pg_catalog | pg_get_ruledef | text | oid | normal | f | f | f pg_catalog | pg_get_ruledef | text | oid, boolean | normal | f | f | f pg_catalog | pg_get_tabledef | text | regclass | normal | f | f | f pg_catalog | pg_get_triggerdef | text | oid | normal | f | f | f pg_catalog | pg_get_triggerdef | text | oid, boolean | normal | f | f | f pg_catalog | pg_get_viewdef | text | oid | normal | f | f | f pg_catalog | pg_get_viewdef | text | oid, boolean | normal | f | f | f pg_catalog | pg_get_viewdef | text | oid, integer | normal | f | f | f pg_catalog | pg_get_viewdef | text | text | normal | f | f | f pg_catalog | pg_get_viewdef | text | text, boolean | normal | f | f | f (16 rows)
示例
获取表的 DDL
omm2=# select pg_get_tabledef('t');
pg_get_tabledef
SET search_path = public; +
CREATE TABLE t ( +
id numeric, +
c character varying(100) +
) +
WITH (orientation=row, fillfactor=50, compression=no);
(1 row)
omm2=# \x
Expanded display is on.
omm2=# select pg_get_tabledef('t');
-[ RECORD 1 ]---+-------------------------------------------------------
pg_get_tabledef | SET search_path = public;
| CREATE TABLE t (
| id numeric,
| c character varying(100)
| )
| WITH (orientation=row, fillfactor=50, compression=no);
获取索引 DDL
omm2=# select pg_get_indexdef('idx_t_id'::regclass);
pg_get_indexdef
CREATE INDEX idx_t_id ON t USING btree (id) TABLESPACE pg_default
(1 row)
还可以直接查询视图
omm2=# \x
Expanded display is on.
omm2=# select * from pg_indexes where indexname='idx_t_id';
-[ RECORD 1 ]-----------------------------------------------------------------
schemaname | public
tablename | t
indexname | idx_t_id
tablespace |
indexdef | CREATE INDEX idx_t_id ON t USING btree (id) TABLESPACE pg_default
通过 gs_dump 生成 ddl
这样还可以生成表及表上的索引定义等 $ gs_dump -t t –section pre-data omm2
$ gs_dump -t t --section pre-data omm2
SET statement_timeout = 0;
SET xmloption = content;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: t; Type: TABLE; Schema: public; Owner: omm2; Tablespace:
CREATE TABLE t (
id numeric,
c character varying(100)
)
WITH (orientation=row, fillfactor=50, compression=no);
ALTER TABLE public.t OWNER TO omm2;
$ gs_dump -t t –section post-data omm2
$ gs_dump -t t --section post-data omm2
SET statement_timeout = 0;
SET xmloption = content;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public;
SET default_tablespace = '';
--
-- Name: idx_t_id; Type: INDEX; Schema: public; Owner: omm2; Tablespace:
CREATE INDEX idx_t_id ON t USING btree (id) TABLESPACE pg_default;
MogDB/openGauss学习笔记-获取对象DDL的更多相关文章
- Python学习笔记_Python对象
Python学习笔记_Python对象 Python对象 标准类型 其它内建类型 类型对象和type类型对象 Python的Null对象None 标准类型操作符 对象值的比較 对象身份比較 布尔类型 ...
- es6学习笔记-proxy对象
前提摘要 尤大大的vue3.0即将到来,虽然学不动了,但是还要学的啊,据说vue3.0是基于proxy来进行对值进行拦截并操作,所以es6的proxy也是要学习一下的. 一 什么是proxy Prox ...
- Python核心编程--学习笔记--4--Python对象
现在开始学习Python语言的核心部分.首先了解什么是Python对象,然后讨论最常用的内建类型,接下来讨论标准类型运算符和内建函数,之后给出对标准类型的不同分类方式,最后提一提Python目前还不支 ...
- JavaScript:学习笔记(8)——对象扩展运算符
JavaScript:学习笔记(8)——扩展运算符 对象的扩展运算符 扩展运算符是三个点(...).用于取出参数对象的所有可遍历属性,然后拷贝到当前对象之中. 如上图所示,新建了一个对象a,然后通过扩 ...
- 【cocos2d-x 3.x 学习笔记】对象内存管理
内存管理 内存管理一直是一个不易处理的问题.开发人员必须考虑分配回收的方式和时机,针对堆和栈做不同的优化处理,等等.内存管理的核心是动态分配的对象必须保证在使用完成后有效地释放内存,即管理对象的生命周 ...
- es6学习笔记--promise对象
Promise对象是为了简化异步编程.解决回调地狱情况 Promise,简单说就是一个容器,里面保存着某个未来才会结束的事件(通常是一个异步操作)的结果.从语法上说,Promise 是一个对象,从它可 ...
- struts2学习笔记--ActionContext对象
什么是ActionContext? ActionContext是Map结构的容器,ActionContext是Action的上下文,类比ServletContext,存放着Action执行过程中的数据 ...
- 重温Servlet学习笔记--session对象
session的类型是属于HttpSession,HttpSession是由javaWeb提供的,用来会话跟踪的类.session是服务器端对象,保存在服务器端. HttpSession是servle ...
- 重温Servlet学习笔记--Cookie对象
首先要了解cookie必须得先了解http协议,,Cookie是http协议指定的,先由服务器保存cookie到浏览器,在下次浏览器请求服务器时把上次请求得到的cookie归还给服务器,cookie以 ...
- 重温Servlet学习笔记--request对象
request和response是一对搭档,一个负责请求一个负责响应,都是Servlet.service()方法的参数,response的知识点前面梳理过了,这里只说一下request,在客户端发出每 ...
随机推荐
- 【Azure Redis 缓存】应用中出现连接Redis服务错误(production.ERROR: Connection refused)的排查步骤
问题描述 在PHP应用中,连接Redis的方法报错 RedisException(code: 0): Connection refused at /data/Redis/Connectors/Php ...
- 【Azure 应用服务】能否通过 Authentication 模块配置 Azure AD 保护 API 应用?
问题描述 在App Service Authentication 中配置 Azure AD 注册的应用信息后,根据官方文档,可以让前端应用实现用户 AAD 登录,然后通过前端应用获取的Token,来访 ...
- hbase报错ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet 采坑记
1.错误异常信息: Exception in thread "main" java.lang.IllegalArgumentException: Failed to find me ...
- Jmeter json断言的使用
1 添加方式:取样器右键->添加->断言->JSON断言 作用:使用JSON表达式提取实际数据与预期进行比较 2首先我们来了解下断言组件的各个功能: Asset JSON Pat ...
- 微信小程序测试点,9大方面全方位总结
微信小程序无需下载安装,用户在微信扫一扫或搜索即可使用,小程序版本类型可分为:开发版.体验版.正式版. 开发版.体验版无需审核,只需要给微信号权限,经过扫小程序的二维码就能访问,正式版本需要经过微信审 ...
- C++ Qt开发:运用QThread多线程组件
Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍如何运用QTh ...
- 使用PdfSharp从模板生成Pdf文件
最近在做一个生成文档的需求.通过先制作一个包含各字段占位符的文档模板,导入这个模板并填写内容替换掉占位符,再输出成最终文件. 由于版式固定,安全性更好,业务上常用Pdf作为最终标准化的格式, 在. ...
- Github登录 2FA(Two-Factor Authentication/两因素认证) 浏览器插件-已验证
Github登录 2FA(Two-Factor Authentication/两因素认证) 浏览器插件-已验证 chrome 装下这个扩展 身份验证器 https://chromewebstore.g ...
- VS Code Snippet Generator 插件 生成 vscode代码片段
VS Code Snippet Generator 插件 生成 vscode代码片段
- vue入门教程之-插槽
vue入门教程之-插槽 欢迎关注博主公众号「java大师」, 专注于分享Java领域干货文章, 关注回复「资源」, 免费领取全网最热的Java架构师学习PDF, 转载请注明出处 https://www ...