postgresql创建数据库

news/2024/7/9 20:43:12 标签: postgresql

一、环境

docker中编译的postgreSQL14.2

postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/psql 
psql (14.2)
Type "help" for help.

postgres=# select version();
                                             version                                              
--------------------------------------------------------------------------------------------------
 PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, 64-bit
(1 row)

二、创建数据库

2.1 使用createdb

src/bin/scripts/createdb.c

postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/createdb --help
createdb creates a PostgreSQL database.

Usage:
  createdb [OPTION]... [DBNAME] [DESCRIPTION]

Options:
  -D, --tablespace=TABLESPACE  default tablespace for the database
  -e, --echo                   show the commands being sent to the server
  -E, --encoding=ENCODING      encoding for the database
  -l, --locale=LOCALE          locale settings for the database
      --lc-collate=LOCALE      LC_COLLATE setting for the database
      --lc-ctype=LOCALE        LC_CTYPE setting for the database
  -O, --owner=OWNER            database user to own the new database
  -T, --template=TEMPLATE      template database to copy
  -V, --version                output version information, then exit
  -?, --help                   show this help, then exit

Connection options:
  -h, --host=HOSTNAME          database server host or socket directory
  -p, --port=PORT              database server port
  -U, --username=USERNAME      user name to connect as
  -w, --no-password            never prompt for password
  -W, --password               force password prompt
  --maintenance-db=DBNAME      alternate maintenance database

By default, a database with the same name as the current user is created.

Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/createdb -h 127.0.0.1 -p 5432 mydb

2.2 使用psql命令行

postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/psql 
psql (14.2)
Type "help" for help.

postgres=# CREATE DATABASE test2;
CREATE DATABASE
postgres=# 

三、删除数据库

postgres=# DROP DATABASE test2;
<p>DROP DATABASE</p>
postgres=# 

http://www.niftyadmin.cn/n/1830035.html

相关文章

ASP.NET MVC+EF框架+EasyUI实现权限管理系列之开篇

原文:ASP.NET MVCEF框架EasyUI实现权限管理系列之开篇前言&#xff1a;博客又有一段时间没有更新了&#xff0c;心里感觉这段时间空空的&#xff0c;好像什么都没有学下&#xff0c;所以就想写博客&#xff0c;所以就有了这个系列&#xff0c;这里当然也要感谢大家了&#xff0…

postgresql创建表

一、环境 postgres2f9d6ce41c2b:~$ cat /etc/os-release PRETTY_NAME"Ubuntu 22.04 LTS" NAME"Ubuntu" VERSION_ID"22.04" VERSION"22.04 LTS (Jammy Jellyfish)" VERSION_CODENAMEjammy IDubuntu ID_LIKEdebian HOME_URL"http…

数据库SQL语句学习--view

1.新建一个view create view view_name as select * from table_name where... 2.删除一个view drop view view_name 3.新增一列 ALTER TABLE table_name ADD column_name column_type 4.删除一列&#xff1a; COLUMN 是关键字 ALTER TABLE table_name drop COLUMN column_name…

LeetCode Kth Largest Element in an Array

原题链接在这里&#xff1a;https://leetcode.com/problems/kth-largest-element-in-an-array/ 题目&#xff1a; Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam…

Objective-C学习——中文URL编码和解码

发现NSString类中有内置的方法可以实现。他们分别是&#xff1a; - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding - (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding 只要传入相应的编码即可以进…

postgresql启动过程

一、主进程 src/backend/main/main.c int main(int argc, char *argv[]) {... PostmasterMain(argc, argv); /* does not return */... }二、服务器初始化 src/backend/postmaster/postmaster.c 主进程初始化&#xff0c;然后进行主循环loop void PostmasterMain(int arg…

Cocos2d-x 3.2:UI树

Cocos2d-x 3.2&#xff1a;UI树 本文参考与深入理解Cocos2d-x 3.x&#xff1a;UI树一文 Cocos2d-x 3.x 引擎的UI树系统 首先得普及一下Cocos2d-x的基础概念&#xff0c;Cocos2d- x的游戏世界一般是由一个又一个的场景&#xff08;Sence&#xff09;组成的&#xff0c;比如登录是…

java List的排序

List自定义排序 1、第一种方法&#xff0c;就是list中对象实现Comparable接口&#xff0c;重写compareTo接口&#xff0c; 对排序的字段进行比较。2、第二种方法&#xff0c;就是在重载Collections.sort方法。 代码示例 package com.xmy.list.sort;import java.util.ArrayList;…