Working with Data Source 12
Posted 阿难的机器学习计划
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Working with Data Source 12相关的知识,希望对你有一定的参考价值。
In command line, psql helps you to manage and connect the database:1
1. Type psql in command line to enter the psql command line tool.
2. In the shell, type \q to exit.
3. In the psql tool, we can create a database by directly typing:
CREATE DATABASE bank_accounts;
4. To enter the database, we can use:
psql database_name
5. In the database, we can create a table:
create table deposits(id integer primary key, name text, amount float); # Do not forget semicolon in the end.
6. Create role, login, create password and role authorizaion:
CREATE ROLE userName WITH CREATEDB LOGIN PASSWORD `password`;# Create role: create a user; CREATEDB: the owner has authorization of creating database; login: automatically login with current username; password: with the passwork
7. Give user privileges:
GRANT SELECT, INSERT, UPDATE, DELETE ON tableName TO userName; # Allow user to select,insert,update,delete on the table
GRANT ALL PRIVILEGES ON tableName TO userName;# allow people to do anything on the table
8. Remove permissions:
REVOKE SELECT, INSERT, UPDATE, DELETE ON tableName FROM userName;
REVOKE ALL PRIVILEGES ON tableName FROM userName;
9. \l
-- list all available databases.
\dt
-- list all tables in the current database.
\du
-- list users.
以上是关于Working with Data Source 12的主要内容,如果未能解决你的问题,请参考以下文章