解析:
\dg Lists database roles. (Since the concepts of “users” and “groups” have been unified into “roles”, this command is now equivalent to \du.) 作者: 郑全 时间: 2024-11-30 17:39
11.psql元命令\pset border 1表示什么?
解析:
参见: CREATE DATABASE 语法,部分:The encoding and locale settings must match those of the template database, except when template0 is used as template. This is because other databases might contain data that does not match the specified encoding, or might contain indexes whose sort ordering is affected by LC_COLLATE and LC_CTYPE. Copying such data would result in a database that is corrupt according to the new settings. template0, however, is known to not contain any data or indexes that would be affected.
大体意思就是template0 ,是一个全新的,没有数据的模板,编码不存在冲突,如果是其他模板,有数据,可能编码有冲突。所以,选择 A。
作者: 郑全 时间: 2024-12-1 14:16
14.删除数据库drop database加上参数if exists是什么意思?
A. 强制删除该数据库
B. 不显示报错信息
C. 如果数据库不存在,该命令不报错
D. 显示完整的报错信息
答案:C
解析:
下面的执行结果:
test=# DROP DATABASE IF EXISTS test1;
NOTICE: database "test1" does not exist, skipping
DROP DATABASE
执行DROP DATABASE IF EXISTS db_name,如果该db_name不存在,不报错,但是会有提示,跳过该动作。
带 FORCE 选项才是强制删除。
所以,该题选择 C .
1)<,<=,=,>,>=
2)以及这些操作的组合,比如between and,也可以使用BTREE。
3)在索引列上的IS NULL 或者IS NOT NULL也可以使用BTREE。
4)BTREE索引也可以用于模糊查询,但是仅限字符串开头是常量的情况下,比如 name LIKE ‘Jason%’,或者name ~ ’^Jason’。但是name LIKE ‘%Jason’是不能用的。
5)Min/Max聚集操作也可使用BTREE索引。
6)其实在merge join以及order by中,可以通过使用BTREE索引的有序性来减少sort带来的代价。
A. 块的checksum值
B. 空闲空间的真实位置和结束位置
C. 特殊数据的其实位置
D. 数据块的位置
答案: D
解析:
下面列出页头内容,不包含块的位置。
field Type Length Description
pd_lsn PageXLogRecPtr 8 bytes LSN: next byte after last byte of WAL record for last change to this page
pd_checksum uint16 2 bytes Page checksum
pd_flags uint16 2 bytes Flag bits
pd_lower LocationIndex 2 bytes Offset to start of free space
pd_upper LocationIndex 2 bytes Offset to end of free space
pd_special LocationIndex 2 bytes Offset to start of special space
pd_pagesize_version uint16 2 bytes Page size and layout version number information
pd_prune_xid TransactionId 4 bytes Oldest unpruned XMAX on page, or zero if none 作者: 郑全 时间: 2024-12-8 16:13
37. 在PostgresSQL中,行指针的结构不包括下面哪一个?
A. 行内容的偏移量
B. 行内容的位置
C. 指针的标记
D. 行内容的长度
答案: B
解析:
An item identifier contains a byte-offset to the start of an item, its length in bytes, and a few attribute bits which affect its interpretation
简单说,行指针占4个字节,32位,具体包含如下:
1.行内容的偏移量,占15个位
2.行内容的长度,占15个位
3.指针的标志,占2个位
尤其注意,行内容的偏移量和行内容的位置,不是一个概念,行内容的偏移量是指行在页内的位置,可以通过行指针快速定位到行数据;行内容的位置是指行数据在磁盘上的位置,所以本题选择 B.
解析:
数据行头如下:
Field Type Length Description
t_xmin TransactionId 4 bytes insert XID stamp
t_xmax TransactionId 4 bytes delete XID stamp
t_cid CommandId 4 bytes insert and/or delete CID stamp (overlays with t_xvac)
t_xvac TransactionId 4 bytes XID for VACUUM operation moving a row version
t_ctid ItemPointerData 6 bytes current TID of this or newer row version
t_infomask2 uint16 2 bytes number of attributes, plus various flag bits
t_infomask uint16 2 bytes various flag bits
t_hoff uint8 1 byte offset to user data