暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openGauss每日一练第 14天|导出数据

原创 杨凯同学 2021-12-17
177

心得

以后项目迁移,不用费事了


课程作业

1.创建数据库tpcc,在数据库tpcc中创建模式schema1,在模式schema1中建表products

omm=# create database tpcc;
CREATE DATABASE
omm=# \c tpcc
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "tpcc" as user "omm".
tpcc=# create table schema1.products(
tpcc(# id integer not null ,
tpcc(# name char(10),
tpcc(# addr char(50)
);

tpcc=# insert into schema1.products values(1,'yangkai','hhht'),(2,'yangkai2','hhht2'); INSERT 0 2 tpcc=#


2.使用gs_dump工具以文本格式导出数据库tpcc的全量数据

gs_dump -f /home/omm/all.sql tpcc -F p
more /home/omm/all.sql


3.使用gs_dump工具以文本格式导出模式schema1的定义

gs_dump -f /home/omm/define.sql tpcc -n schema1 -s -F p
more /home/omm/define.sql


4.使用gs_dump工具以文本格式导出数据库tpcc的数据,不包含定义

gs_dump -f /home/database_data.sql tpcc -a -F p 
more /home/omm/database_data.sql


5.删除表、模式和数据库

\c tpcc
drop table schema1.products;
drop schema schema1;
\c omm
drop database tpcc;
最后修改时间:2021-12-21 10:57:34
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论