openGauss每日一练第三天
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每日一练第三天的更多相关文章
- javascript每日一练(三)——DOM一
一.Dom基础 childNodes(有兼容问题),children nodeType getAttribute() firstChild,lastChild,previousSilbing,next ...
- CSS3每日一练之内容处理-嵌套编号
出处:http://www.w3cfuns.com/thread-5592229-1-17.html 1.大标题一 1.子标题 2.子标题 3.子标题2.大标题二 1.子标题 2. ...
- WindowsAPI每日一练(2) 使用应用程序句柄
WindowsAPI每日一练系列 :https://www.cnblogs.com/LexMoon/category/1246238.html WindowsAPI每日一练() WinMain Win ...
- WindowsAPI每日一练(1) MessageBoxA
WindowsAPI每日一练系列 :https://www.cnblogs.com/LexMoon/category/1246238.html WindowsAPI每日一练(1) WinMain 要跟 ...
- 每日一小练——Armstrong数
上得厅堂.下得厨房,写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练! 题目:Armstrong数 内容: 在三位的正整数中,比如abc.有一些能够满足a^3+b^3+c^3=abc的条件,也就是说各 ...
- Python 每日一练(5)
引言 Python每日一练又开始啦,今天的专题和Excel有关,主要是实现将txt文本中数据写入到Excel中,说来也巧,今天刚好学校要更新各团支部的人员信息,就借此直接把事情做了 主要对于三种数据类 ...
- Python每日一练(1)
这两天在做Python的每日一练,感觉收获颇丰,所以来记录分享一下,一共做了三个,涉及socket,PIL,pymysql三个库,另外终于开始了Flask框架的学习,后续也会做出一些分析 第一个是一个 ...
- CSS3每日一练之选择器-结构性伪类选择器
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312"> <title> ...
- HTML5每日一练之progress标签的应用
progress标签:从名字上来看,估计大家也能猜到这个标签是什么标签了,没错,他是一个进度条.在HTML5中我们终于可以不用模拟了. <progress id="W3Cfuns_pr ...
- HTML5每日一练之figure新标签的应用
igure元素是一种元素的组合,可带有标题(可选).figure标签用来表示网页上一块独立的内容,将其从网页上移除后不会对网页上的其他内容产生影响.figure所表示的内容可以是图片.统计图或代码示例 ...
随机推荐
- 【Azure Cloud Service】云服务升级后,查看配置文件发现编码变为utf-16
问题描述 通过Migrate to ARM,把经典云服务升级成云服务(外延支持)后,在查看云服务的配置XML文件,发现文件的编码格式由 UTF-8 改变为 UTF-16 由此,引发了三个问题 1)Cl ...
- 【Azure 应用服务】使用命令行创建 webapp 应用出现命令语法不正确错误
问题描述 根据Azure App Service 入门文档 "快速入门:在 Linux 上的 Azure 应用服务中创建 Python 应用" 在创建App Service应用时候 ...
- mysql-添加、删除索引
-- 添加联合唯一索引 alter table b_report_file add unique index nc (name, code, org_id); -- 删除索引 ALTER TABLE ...
- Inertial Explorer Xpress 学习笔记
KEY WORDS: Coordinate Updates (CUPTs) Zero Velocity Updates (ZUPTs) Google Protocol Buffer (GPB) 是一 ...
- 五: Mysql权限管理
# 权限管理 关于MySQL的权限简单的理解就是MySQL允许你做你权力以内的事情,不可以越界.比如只允许你执行SELECT操 作, 那么你就不能执行UPDATE操作.只允许你从某台机器上连接MySQ ...
- C++//vector存放自定义数据类型
1 //vector存放自定义数据类型 2 3 #include <iostream> 4 #include <string> 5 #include<fstream> ...
- python3 Crypto模块实例解析
一 模块简介 1.简介 python的Crypto模块是安全hash函数(例如SHA256 和RIPEMD160)以及各种主流的加解密算法的((AES, DES, RSA, ElGamal等)的集合. ...
- 快速将json装DTO的GsonFormatPlus插件使用
参考:https://www.jianshu.com/p/8fb0e4274436 https://blog.csdn.net/qq_43039260/article/details/12676582 ...
- leetcode数据库sql之Department Top Three Salaries
leetcode原文引用: How would you print just the 10th line of a file? For example, assume that file.txt ha ...
- AOSP源码编译—交换空间扩容
编译AOSP源码的时候会出现提示如下: 意思是需要16G左右的内存(实际上编译会超过16G),而我们之前安装Ubuntu的时候只分配了8G,编 译一定会失败!此时需要添加虚拟内存(swap交换空间) ...