码迷,mamicode.com
首页 > 其他好文 > 详细

Working with Data Source 12

时间:2016-11-29 09:27:52      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:username   ant   deposits   can   sql   current   revoke   exit   deposit   

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

标签:username   ant   deposits   can   sql   current   revoke   exit   deposit   

原文地址:http://www.cnblogs.com/kingoscar/p/6112120.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!