openGauss 每日一练第三天

本文出处:https://www.modb.pro/db/193083

学习目标

学习 openGauss 创建数据库、修改数据库属性和删除数据库

课后作业

1.分别创建名为 tpcc1 和 tpcc2 的数据库

SQL文本:

create database tpcc1;

create database tpcc2;

\l

omm=# create database tpcc1;

CREATE DATABASE

omm=# create database tpcc2;

CREATE DATABASE

omm=# omm=# \l

List of databases

Name | Owner | Encoding | Collate | Ctype | Access privileges

-----------+-------+----------+-------------+-------------+-------------------

omm | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

postgres | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

template0 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +

| | | | | omm=CTc/omm

template1 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +

| | | | | omm=CTc/omm

tpcc1 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

tpcc2 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

(6 rows)

omm=#

2.将 tpcc1 数据库重命名为 tpcc10

SQL文本:

alter database tpcc1 rename to tpcc10;

omm=# alter database tpcc1 rename to tpcc10;

ALTER DATABASE

omm=#

3.分别使用\l 和\l+两个元命令查看数据库信息

SQL文本:

\l

\l+

omm=# \l

List of databases

Name | Owner | Encoding | Collate | Ctype | Access privileges

-----------+-------+----------+-------------+-------------+-------------------

omm | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

postgres | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

template0 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +

| | | | | omm=CTc/omm

template1 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +

| | | | | omm=CTc/omm

tpcc10 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

tpcc2 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

(6 rows)

omm=# \l+

List of databases

Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description

-----------+-------+----------+-------------+-------------+-------------------+-------+------------+--------------------------------------------

omm | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 11 MB | pg_default |

postgres | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 41 MB | pg_default | default administrative connection database

template0 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +| 10 MB | pg_default | default template for new databases

| | | | | omm=CTc/omm | | |

template1 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +| 10 MB | pg_default | unmodifiable empty database

| | | | | omm=CTc/omm | | |

tpcc10 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 10 MB | pg_default |

tpcc2 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 10 MB | pg_default |

(6 rows)

omm=#

4.在数据库 tpcc2 中创建 customer 表,字段自定义

SQL文本:

\c tpcc2

create table customer_t

(c_customer_sk integer,

c_customer_id char(5),

c_first_name char(6),

c_last_name char(8)

) ;

\d

tpcc2=# \c tpcc2

Non-SSL connection (SSL connection is recommended when requiring high-security)

You are now connected to database "tpcc2" as user "omm".

tpcc2=# create table customer_t

tpcc2-# (c_customer_sk integer,

tpcc2(# c_customer_id char(5),

tpcc2(# c_first_name char(6),

tpcc2(# c_last_name char(8)

tpcc2(# ) ;

CREATE TABLE

tpcc2=# \d

List of relations

Schema | Name | Type | Owner | Storage

---------+------------+-------+-------+----------------------------------

schema2 | customer_t | table | omm | {orientation=row,compression=no}

(1 row)

tpcc2=#

5.删除新创建的数据库

SQL文本:

\c omm

drop database tpcc2;

drop database tpcc10;

tpcc2=# \c omm

Non-SSL connection (SSL connection is recommended when requiring high-security)

You are now connected to database "omm" as user "omm".

omm=# drop database tpcc2;

DROP DATABASE

omm=# drop database tpcc10;

DROP DATABASE

omm=#

6.退出 gsql 程序

SQL文本:

\q

omm=# \q

[omm@modb ~]$

openGauss每日一练第三天的更多相关文章

  1. javascript每日一练(三)——DOM一

    一.Dom基础 childNodes(有兼容问题),children nodeType getAttribute() firstChild,lastChild,previousSilbing,next ...

  2. CSS3每日一练之内容处理-嵌套编号

    出处:http://www.w3cfuns.com/thread-5592229-1-17.html 1.大标题一   1.子标题   2.子标题   3.子标题2.大标题二   1.子标题   2. ...

  3. WindowsAPI每日一练(2) 使用应用程序句柄

    WindowsAPI每日一练系列 :https://www.cnblogs.com/LexMoon/category/1246238.html WindowsAPI每日一练() WinMain Win ...

  4. WindowsAPI每日一练(1) MessageBoxA

    WindowsAPI每日一练系列 :https://www.cnblogs.com/LexMoon/category/1246238.html WindowsAPI每日一练(1) WinMain 要跟 ...

  5. 每日一小练——Armstrong数

    上得厅堂.下得厨房,写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练! 题目:Armstrong数 内容: 在三位的正整数中,比如abc.有一些能够满足a^3+b^3+c^3=abc的条件,也就是说各 ...

  6. Python 每日一练(5)

    引言 Python每日一练又开始啦,今天的专题和Excel有关,主要是实现将txt文本中数据写入到Excel中,说来也巧,今天刚好学校要更新各团支部的人员信息,就借此直接把事情做了 主要对于三种数据类 ...

  7. Python每日一练(1)

    这两天在做Python的每日一练,感觉收获颇丰,所以来记录分享一下,一共做了三个,涉及socket,PIL,pymysql三个库,另外终于开始了Flask框架的学习,后续也会做出一些分析 第一个是一个 ...

  8. CSS3每日一练之选择器-结构性伪类选择器

    <!DOCTYPE HTML> <html> <head> <meta charset="gb2312"> <title> ...

  9. HTML5每日一练之progress标签的应用

    progress标签:从名字上来看,估计大家也能猜到这个标签是什么标签了,没错,他是一个进度条.在HTML5中我们终于可以不用模拟了. <progress id="W3Cfuns_pr ...

  10. HTML5每日一练之figure新标签的应用

    igure元素是一种元素的组合,可带有标题(可选).figure标签用来表示网页上一块独立的内容,将其从网页上移除后不会对网页上的其他内容产生影响.figure所表示的内容可以是图片.统计图或代码示例 ...

随机推荐

  1. Node.JS http server

    一.自动更新刷新 http server browser-sync dist --files "**/*" 二.http-server 三.webpack-dev-server的c ...

  2. 【Azure 微服务】Service fabric升级结构版本失败问题

    问题描述 Service fabric升级结构版本失败,Service Fabric的可靠性层是白银层,持久性层为青铜层,当把节点从6个直接在虚拟规模集(VMSS)中缩放成了3个.从而引起了Servi ...

  3. Python(上机题) 通俗易懂的基础题目解析

    python 题目 文章目录 python 题目 题目一:幸运数对 题目二:lambda 函数找最大值 题目三:n个数前后互换 (切片) 题目四:字符串相减(删除指定字符) 方法一:可以用空字符来替换 ...

  4. netcore linux ffmpeg 首帧图

    第一步 On CentOS/RHEL 6.*: $ sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-r ...

  5. mikumikudance 和 pmxEditor 都可以打开 pmx

    mikumikudance 和 pmxEditor 都可以打开 pmx 模型下载 https://www.bilibili.com/blackboard/activity-5hkwDIRkBv.htm ...

  6. https://pengchenggang.github.io/vuejsdev-com-github 备份发布

    https://pengchenggang.github.io/vuejsdev-com-github 备份发布 现在还没有解决的就是 开clash,代码提交不上去,只能关了提,但是关了提交,也得赶运 ...

  7. Python使用os模块创建带时间戳的文件

    直接上源码: import os import time # 定义函数名:在py文件路径下创建cache的txt文件 def txt(name, text): # os.getcwd() 获取当前的工 ...

  8. Web安全前端基础

    Web安全前端基础 1.Web前端介绍 2.前端代码语言简单学习 一.Web前端介绍 web前端就是前端网络编程,也被认为是用户端编程,是为了网页或者网页应用,而编写HTML,CSS以及JS代码,所以 ...

  9. 用免费GPU部署自己的stable-diffusion-学习笔记

    最近由于工作需要,开始学习AI+大模型,零基础,听从同事的推荐报名参加了一个免费学习团队,本文是整理的一些学习笔记. 课程是趋动云提供支持的,在注册时赠送了足够学习使用的188算力.项目在趋动云上可以 ...

  10. drf(视图组件)

    一. 前言 Django REST framwork 提供的视图的主要作用 1. 控制序列化器的执行(检验.保存.转换数据) 2. 控制数据库查询的执行 二. 两个视图基类 两个视图基类: APIVi ...