首页 > 其他分享 >openGauss每日一练第三天

openGauss每日一练第三天

时间:2024-03-30 15:11:08浏览次数:16  
标签:en UTF UTF8 每日 第三天 US omm openGauss tpcc2

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 ~]$

标签:en,UTF,UTF8,每日,第三天,US,omm,openGauss,tpcc2
From: https://www.cnblogs.com/helloopenGauss/p/18105518

相关文章

  • python每日练(二)
    1:九九乘法表foriinrange(1,10):forjinrange(1,i+1):print("%d*%d=%d"%(i,j,i*j),end='')print()通过两个for循环嵌套使用调用乘法的因子,最后的print()是为了让输出的结果美观,因为print()自带换行的功能。1*1=12*1=22*2=43*1=33*2=63*3=9......
  • MogDB/openGauss 坏块测试-对启动的影响-测试笔记1
    MogDB/openGauss坏块测试-对启动的影响-测试笔记1在UPDATE操作提交后,脏块落盘前kill掉mogdb数据库,然后对UPDATE修改的坏进行以下破坏操作,仍然能够启动数据库,数据未丢失。1、用旧数据文件替换,可以启动2、修改成错误的checksum,可以启动3、数据块修改成错误的lsn,可......
  • 编译安装openGauss 3.0.0
    编译安装openGauss3.0.0环境检查1.1检查OS版本openGauss支持的操作系统:CentOS7.6(x86架构)openEuler-20.03-LTS(aarch64架构)openEuler-20.03-LTS(x86架构)Kylin-V10(aarch64架构)[root@og3~]#cat/etc/redhat-releaseCentOSLinuxrelease7.6.1810(Core)1.2修......
  • MogDB/openGauss学习笔记-获取对象DDL
    MogDB/openGauss学习笔记-获取对象DDL本文出处:https://www.modb.pro/db/399230内置函数omm2=#\df*defListoffunctionsSchema|Name|Resultdatatype|......
  • openGauss 数据库认证机制
    数据库认证机制可获得性本特性自openGauss1.1.0版本开始引入。特性简介提供基于客户端/服务端(C/S)模式的客户端连接认证机制。客户价值加密认证过程中采用单向Hash不可逆加密算法PBKDF2,有效防止彩虹攻击。特性描述openGauss采用基本的客户端连接认证机制,客户端发起连接请......
  • openGauss 数据库指标采集-预测与异常监控
    数据库指标采集、预测与异常监控可获得性本特性自openGauss1.1.0版本开始引入。特性简介本特性是openGauss集成的、可以用于数据库指标采集、预测以及异常监控与诊断的AI工具,是DBMind套间中的一个组件。当前通过兼容Prometheus平台来采集数据库系统的指标,提供Prometheusexpo......
  • openGauss 事件触发器
    事件触发器可获得性本特性自openGauss5.0.0版本开始引入。特性简介支持事件触发器,允许捕获DDL操作并做相应处理。客户价值典型使用场景是:通过事件触发器捕获DDL操作和目标对象,来实现数据同步。特性描述事件触发器支持捕获当前数据库下的ddl操作以及ddl操作的目标对象(事件......
  • openGauss 数据加密存储
    数据加密存储可获得性本特性自openGauss1.1.0版本开始引入。特性简介提供对导入数据的加密存储。客户价值为客户提供加密导入接口,对客户认为是敏感信息的数据进行加密后存储在表内。特性描述openGauss提供加密函数gs_encrypt_aes128()、gs_encrypt()和解密函数gs_decrypt......
  • openGauss 全文索引
    全文索引可获得性本特性自openGauss1.1.0版本开始引入。特性简介openGauss中提供的全文索引功能可以对文档进行预处理,并且可以使后续的搜索更快速。客户价值openGauss全文索引功能提供了查询可读性文档的能力,并且通过查询相关度将结果进行排序。特性描述构建全文索引的......
  • openGauss 使用kubernetes部署分布式数据库
    使用kubernetes部署分布式数据库可获得性本特性自openGauss2.1.0版本开始引入。特性简介一键式部署分布式数据库。客户价值快速完成分布式数据库搭建,验证和使用分布式能力。特性描述通过patroni实现计划内switchover和故障场景自动failover,通过haproxy实现openGauss主备......