Files
urbanLifeline/urbanLifelineServ/.bin/database/postgres/sql/createDB.sql
2025-12-02 13:21:18 +08:00

28 lines
965 B
SQL

-- 删除已存在的数据库(如果存在)
DROP DATABASE IF EXISTS urban-lifeline;
-- 创建新数据库,使用 UTF8 编码,并设置适合中文的排序规则
-- 使用 template0 确保干净的数据库模板
-- zh_CN.UTF-8 支持中文字符排序和比较
CREATE DATABASE urban-lifeline
ENCODING 'UTF8'
TEMPLATE template0
LC_COLLATE 'zh_CN.UTF-8'
LC_CTYPE 'zh_CN.UTF-8';
-- 连接到新创建的数据库
\c urban-lifeline;
-- -- 创建扩展(如果需要)
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- UUID 支持
CREATE EXTENSION IF NOT EXISTS "pg_trgm"; -- 文本搜索支持
CREATE EXTENSION IF NOT EXISTS "btree_gist"; -- GiST 索引支持
-- 设置搜索路径(可选,但建议设置)
-- ALTER DATABASE urban-lifeline SET search_path TO sys, public;
-- sudo ./configure --prefix=/opt/postgres/postgres-17.6
-- --with-uuid=ossp --with-openssl --with-libxml --with-pam
-- && sudo make && sudo make install