从pgAdmin导出数据库的CREATE脚本 [英] Export a CREATE script for a database from pgAdmin

查看:2042
本文介绍了从pgAdmin导出数据库的CREATE脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我在pgAdmin中创建了一个数据库,但是我想导出一个CREATE sql文件。

Say I've created a database in pgAdmin, but I want to export a CREATE sql file.

我该如何生成转储?

推荐答案

要生成一个sql脚本,它将创建表,因为它们存在于给定数据库中:

To generate a sql script that will create the tables as they exist in a given database do:

pg_dump - 仅限模式--no-owner the_database> create_the_tables.sql

这将给你一堆create table语句。只是看看它是如何便携式,我尝试以上如下:

This will give you a bunch of create table statements. Just to see how portable it was I tried the above as follows:

bvm$ pg_dump -s --no-owner devdb | sqlite3 so_ans.db

然后:

bvm$ sqlite3 so_ans.db .schema
CREATE TABLE courses (
    id integer NOT NULL,
    name text,
    created_by integer,
    jc text
);

种类很酷。

这篇关于从pgAdmin导出数据库的CREATE脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆