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. vivo 在离线混部探索与实践

    作者:来自 vivo 互联网服务器团队 本文根据甘青.黄荣杰老师在"2023 vivo开发者大会"现场演讲内容整理而成. 伴随 vivo 互联网业务的高速发展,数据中心的规模不断扩 ...

  2. base64 转文件上传

    // 将base64转换为blob dataURLtoBlob (dataurl) { let arr = dataurl.split(',') let mime = arr[0].match(/:( ...

  3. Prometheus组件构成及介绍

    Prometheus是一个开源的监控和告警工具包,其常用的组件主要包括以下几个部分: Prometheus Server 功能:Prometheus Server是Prometheus的核心组件,负责 ...

  4. epoll实现的简单服务器

    #include "../wrap/wrap.h" #include <sys/epoll.h> #define SIZE 1024 #define FUCK prin ...

  5. NJOPT自控第三次积分赛--风力摆小结

    NJOPT自控第三次积分赛--风力摆小结 题目 题目就不放了,百度一搜就有,就是2015国赛的风力摆.. 方案 我们队采用的主控是STM32F401CCU6(科协传统),性能完全够用:姿态传感器采用的 ...

  6. App启动流程

    目录介绍 1.什么是Zygote进程 1.1 简单介绍 1.2 各个进程的先后顺序 1.3 进程作用说明 2.Zygote进程的启动流程 2.1 源码位置 2.2 ZygoteInit类的main方法 ...

  7. 三维模型3DTile格式轻量化在网络传输中的重要性分析

    三维模型3DTile格式轻量化在网络传输中的重要性分析 三维模型3DTile格式轻量化在网络传输中扮演了至关重要的角色.随着数字化和虚拟化技术的发展,越来越多的应用需要通过网络来获取和分享大规模三维地 ...

  8. 三维模型3DTile格式轻量化压缩文件大小的技术方法研究

    三维模型3DTile格式轻量化压缩文件大小的技术方法研究 倾斜摄影三维模型,由于数据量大.复杂度高,轻量化压缩成为其在网络传输和实时渲染中必不可少的环节.以下是几种常用的3DTile格式轻量化压缩技术 ...

  9. 记录--JavaScript原型和原型链复习笔记

    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 原型和原型链 1. 原型 每个JS对象一定对应一个原型对象,并从原型对象继承属性和方法 1.1 __proto__ 对象的__proto_ ...

  10. LOTO仪器---如何用LOTO的EMI模块锁定你PCB上的干扰做分析?

    在开发电子产品的过程中,电磁干扰(EMI)可能会导致许多问题,可能会在模拟电路上出现很大的噪声,可能导致通讯乱码,可能导致芯片无规律重启,可能会导致数字电路有莫名其妙的误动作. 硬件工程师通常会把主要 ...