Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic operation of PostgreSQL

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Create a user

Postgres=# create user test password 'test'

CREATE ROLE

Note: there is no distinction between user and role in PostgreSQL. "CREATE USER" is an alias for "CREATE ROLE". The two commands are almost identical, except that the user created by the "CREATE USER" command has the LOGIN attribute by default, while the user created by the "CREATE ROLE" command does not have the LOGIN attribute by default.

two。 Create a tablespace

Postgres=# create tablespace tbs owner test location'd:\ postgresql\ data\ tbs'

CREATE TABLESPACE

3. Create a database

Postgres=# create database mydb with owner = test encoding = 'UTF8' tablespace =' tbs'

CREATE DATABASE

4. Authorize the user

Postgres=# grant all on database mydb to test with grant option

GRANT

Postgres=# grant all on tablespace tbs to test

GRANT

5. Connect to the database with the newly created user

D:\ PostgreSQL\ bin > psql-U test mydb

Psql (12.0)

Enter "help" for help.

Mydb= >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report