企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 创建数据库 语法: ``` createdb [option...] [dbname [description]] ``` example: ``` CREATE DATABASE dbname; ``` ## 查看数据库 命令行 ``` postgres=# \l 名称 | 拥有者 | 字元编码 | 校对规则 | Ctype | 存取权限 -----------+----------+----------+--------------------------------+--------------------------------+----------------------- dd | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | demo | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | hello | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | postgres | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | template0 | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | Chinese (Simplified)_China.936 | Chinese (Simplified)_China.936 | =c/postgres + | | | | | postgres=CTc/postgres ``` sql ``` > SELECT datname FROM pg_database; datname ----------- postgres demo template1 template0 hello dd ``` ## 进入 数据库 ``` postgres=# \c runoobdb ``` ## 删除数据库 语法 ``` DROP DATABASE [ IF EXISTS ] name ``` example ``` DROP DATABASE runoobdb; ```