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的更多相关文章

  1. Python学习笔记_Python对象

    Python学习笔记_Python对象 Python对象 标准类型 其它内建类型 类型对象和type类型对象 Python的Null对象None 标准类型操作符 对象值的比較 对象身份比較 布尔类型 ...

  2. es6学习笔记-proxy对象

    前提摘要 尤大大的vue3.0即将到来,虽然学不动了,但是还要学的啊,据说vue3.0是基于proxy来进行对值进行拦截并操作,所以es6的proxy也是要学习一下的. 一 什么是proxy Prox ...

  3. Python核心编程--学习笔记--4--Python对象

    现在开始学习Python语言的核心部分.首先了解什么是Python对象,然后讨论最常用的内建类型,接下来讨论标准类型运算符和内建函数,之后给出对标准类型的不同分类方式,最后提一提Python目前还不支 ...

  4. JavaScript:学习笔记(8)——对象扩展运算符

    JavaScript:学习笔记(8)——扩展运算符 对象的扩展运算符 扩展运算符是三个点(...).用于取出参数对象的所有可遍历属性,然后拷贝到当前对象之中. 如上图所示,新建了一个对象a,然后通过扩 ...

  5. 【cocos2d-x 3.x 学习笔记】对象内存管理

    内存管理 内存管理一直是一个不易处理的问题.开发人员必须考虑分配回收的方式和时机,针对堆和栈做不同的优化处理,等等.内存管理的核心是动态分配的对象必须保证在使用完成后有效地释放内存,即管理对象的生命周 ...

  6. es6学习笔记--promise对象

    Promise对象是为了简化异步编程.解决回调地狱情况 Promise,简单说就是一个容器,里面保存着某个未来才会结束的事件(通常是一个异步操作)的结果.从语法上说,Promise 是一个对象,从它可 ...

  7. struts2学习笔记--ActionContext对象

    什么是ActionContext? ActionContext是Map结构的容器,ActionContext是Action的上下文,类比ServletContext,存放着Action执行过程中的数据 ...

  8. 重温Servlet学习笔记--session对象

    session的类型是属于HttpSession,HttpSession是由javaWeb提供的,用来会话跟踪的类.session是服务器端对象,保存在服务器端. HttpSession是servle ...

  9. 重温Servlet学习笔记--Cookie对象

    首先要了解cookie必须得先了解http协议,,Cookie是http协议指定的,先由服务器保存cookie到浏览器,在下次浏览器请求服务器时把上次请求得到的cookie归还给服务器,cookie以 ...

  10. 重温Servlet学习笔记--request对象

    request和response是一对搭档,一个负责请求一个负责响应,都是Servlet.service()方法的参数,response的知识点前面梳理过了,这里只说一下request,在客户端发出每 ...

随机推荐

  1. DataGear 制作自适应任意屏幕尺寸的数据可视化看板

    DataGear 即支持以编写HTML.JavaScript.CSS源码的源码模式制作看板,也支持直观可见.友好快捷的可视模式制作看板. 本文将通过看板可视编辑模式提供的网格布局和样式设置功能,介绍如 ...

  2. [C/C++] PCWSTR LPCTSTR等等

    目录 为什么会有这个 L"" 宏 LPCWSTR字符串比较 wchar_t 和 char 之间转换 关于 ANSI编码 乌拉~~~ 这是我第一百篇博文咯~ 为什么会有这个 真的开发 ...

  3. Jmeter 之正则表达式的使用

    1 背景及用途: html.json数据都可以转化为文本,提供给正则去提取,使用正则可以提取全部数据,这就是正则表达式非常强大的一点. html格式响应更适合用xpath提取,性能比正则好一点 jso ...

  4. Redis高级数据类型

    ## 1.Redis相关配置信息 服务器端设定 设置服务器以守护进程的方式运行 daemonize yes|no 绑定主机地址 (只能此ip访问) bind 127.0.0.1 设置服务器端口号 po ...

  5. Java 一悟结束异常处理 Biu丶

  6. Apollo获取配置异常:Load config failed, will retry in 1 SECONDS

    一.现象 apollo开启秘钥,服务获取配置参数需要启动参数中添加:jvm参数-Dapollo.accesskey.secret=XXX.日志如下: 二.解决方案 应用服务器时间异常,重置应用服务器时 ...

  7. .bat 批处理 手册 教程

    有时候bat写个脚本 还是挺方便的,网上也没有不错的手册,有时间再整理看吧.网上找几个,先留存. 系统变量 %USERPROFILE% https://blog.csdn.net/ztx114/art ...

  8. SelectZenEmpty 下拉框 支持 最大长度 超出... vue 组件

    <template> <Select v-model="innerValue" :disabled="disabled" :clearable ...

  9. B站Aimls的JavaFx教程目录合集

    B站里有时候不太好去找资源,用JS爬了下,整出标题和链接,方便后续查询某个知识点的使用! JavaFX视频教程第1课,hello world JavaFX视频教程第2课,application的启动方 ...

  10. Base MYSQL Database create stored procedures resolve the Delimiter error

    Base MYSQL Database create stored procedures resolve the Delimiter error, It must be created using a ...