不想要删除数据库本身,仅删除所有表及其中的所有数据:
所有表都在单个模式中,则此方法可行(以下代码假定模式名称为public):
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
使用的是PostgreSQL 9.3或更高版本,则可能还需要恢复默认授予.
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
https://www.bookstack.cn/read/opengauss-3.1.1-zh/f3046c3517359a0c.md
https://ftp.gnu.org/gnu/bison/
https://gitee.com/opengauss/openGauss-server#https://gitee.com/link?target=https%3A%2F%2Fopengauss.obs.cn-south-1.myhuaweicloud.com%2Flatest%2Fbinarylibs%2Fgcc7.3%2FopenGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
gram.y 中的 target_list 的定义:
target_list:
target_el
{ $$ = list_make1($1); }
| target_list ',' target_el
{ $$ = lappend($1, $3); }
;
#define list_make1(x1) lcons(x1, NIL)
#define list_make2(x1,x2) lcons(x1, list_make1(x2))
#define list_make3(x1,x2,x3) lcons(x1, list_make2(x2, x3))
#define list_make4(x1,x2,x3,x4) lcons(x1, list_make3(x2, x3, x4))
listmake1($1) 就是,通过 lcons来建立一个空的List, 其head 指向 $1。