How to grant privileges to a user for any firebird database - sql

I want to GRANT some privileges to a particular user in Firebird like we can do it in MySql as shown below.
CREATE USER 'user123'#'localhost' IDENTIFIED BY 'user123pass';
GRANT CREATE, SELECT, INSERT, DELETE, DROP, UPDATE ON MyTestDb.* TO 'user123'#'localhost';
Is possible in Firebird?

Unfortunately, this is not possible. You will need to grant privileges per table or view explicitly and individually.
See also the GRANT syntax in the Firebird 2.5 Language Reference and the Firebird 3 release notes

Related

Create DML, DDL, DQL user in PostgreSQL

I need to create 3 users with different DML, DDL, DQL on newly created clean Database in PostgreSQL.
DML should have SELECT, UPDATE, DELETE
DDL should have CREATE, DROP, ALTER, TRUNCATE, INSERT
DQL should have SELECT
all of this in standard scheme public.
Important is that user inherit right on newly created tables by DDL user.
users ref: https://www.geeksforgeeks.org/sql-ddl-dql-dml-dcl-tcl-commands/
I did some coding but I'm pretty new in PostgreSQL and it didn't work :(
The main problem was that I cannot perform GRANT or REVOKE on CREATE, DROP, ALTER, TRUNCATE :(
Can someone help please?
Maybe you have something similar already prepared?
The setup you want, can be done to some extent. However these privileges are controlled on schema level, not on database level.
Assuming you have a schema app_schema for which this should be defined, you can do the following:
First create the users:
create user ddl with password '***';
create user dml with password '***';
create user dql with password '***';
Then create the schema:
create schema app_schema;
Then allow the ddl user to create objects:
grant create,usage on schema app_schema to ddl;
Then change the default privileges on the schema, so that every table (or view, or sequence ...) created by the ddl user is accessible by the dml and dql users:
alter default privileges
for role ddl
grant select,update,delete on tables
to dml;
alter default privileges
for role ddl
grant select on tables
to dql;
This will affect all future tables created in the schema by the user ddl.
The owner of the tables automatically has the privileges to INSERT,UPDATE,DELETE or TRUNCATE the tables.
I have never tried this, but it seems possible to revoke the UPDATE and SELECT privileges:
alter default privileges
for role ddl
in schema app_schema
revoke update,select,delete on tables
from ddl;
If there are already tables in the schema, you need to grant the desired privileges for them:
grant select,insert,update,delete on all tables
in schema app_schema
to dml;
grant select on all tables
in schema app_schema
to dql;

Creating roles for environments

If I'm creating the role 'VIPGUEST' and giving them object privileges to these environments:
BedroomDEV
KitchenINT
GarageTEST
LivingroomTRN
DiningroomPROD
Create role VIPGUEST not identified
Grant connect to VIPGUEST
Grant create session TO VIPGUEST
Grant delete, execute to VIPGUEST
Grant insert, load, view to VIPGUEST
Grant refresh, references, select to VIPGUEST
Grant update, resource, index, alter to VIPGUEST
How do I combine these to get the results that I want?
I know my statements are incomplete, but I don’t know how.
There are different categories of privileges, such as system, table or procedure ones. Depending on that, GRANT differs.
You can GRANT CREATE SESSION TO VIPGUEST, but can't GRANT DELETE TO VIPGUEST. Delete what? GRANT DELETE ON EMP TO VIPGUEST would make sense.
The same goes for, for example, EXECUTE: you have to say what you'd want to allow VIPGUEST to execute, e.g. GRANT EXECUTE ON p_insert_employee TO VIPGUEST.
Have a look at the Security Guide (of your database version) for some more info.
P.S. Don't grant CONNECT nor RESOURCE. Those were "popular" roles some time ago but will be deprecated in future Oracle database releases. Correct way is what you're trying to do: create your own role with minimum set of privileges which will enable users (who will be granted that role) to work.

Grant all privileges to all users in SQL view

I have a view called Directors on a SQL database called Theatre. I need to grant all users in this view all privileges.
So far I have this:
GRANT ALL ON Theatre.Director '*'#'.\SQLEXPRESS'
.\SQLEXPRESS Is my SQL host server.
But this returns an error. How Do I complete this task?
GRANT DELETE, INSERT, REFERENCES, SELECT, UPDATE ON Theatre.Director TO public
all users are member of the "public" group. As for the "all" you should avoid using it since it is deprecated.

How to grant privileges on trigger and synonyms in oracle 11g

I have created a sample application to get schema of all objects and generate SQLfile, so I simply created two user, user 'SYSTEM' and 'SCOTT' , and user SYSTEM grant all privileges to access some of tables,views,function etc. to user SCOTT,
for grant privileges to user SCOTT use following oracle query
GRANT ALL ON table_name to username
But the problem is this query is not working for trigger and synonyms.
so anyone please suggest me how can I grant privileges on triggers and synonyms to user SCOTT.
But the problem is this query is not working for trigger and synonyms. so anyone please suggest me how can I grant privileges on triggers and synonyms to user SCOTT.
TRIGGER - You cannot t give grants for trigger. There is no such thing. Triggers fire automatically whenever the trigger event is done on the table on which the the trigger is created. You only need to grant privilege on the table.
SYNONYM - You just create a synonym for the schema.table and grant privilege on the table such that other users doesn't have to fully qualify the table and just use the synonym instead.

postgres table privileges do not allow user to create/select view

I am managing a database that has a number of schemas. I am having some difficulty with setting privileges and would like to request some help.
I have the schema called schemaA and a group_role db_writer
I use the following sql:
GRANT USAGE ON SCHEMA schemaA TO db_writer;
GRANT UPDATE, INSERT, SELECT, DELETE ON ALL TABLES IN SCHEMA schemaA TO db_writer;
However, the db_writer is unable to create views. They are returned with a permission denied error. Also, when I create views, she is then unable to select them...and I have to set the priviliges again for that view.
It was my understanding the views were treated as tables with respect to privileges...and if one is granted certain permissions to all tables in a schema this would apply to views also.
What am I missing? Any advice appreciated.
The problem is USAGE does not allow users to create objects within the database.
Try
GRANT USAGE, CREATE ON SCHEMA schemaA TO db_writer
Edit:
New objects will get default privileges, for the user to have those privileges for objects created in the future you can do it as:
ALTER DEFAULT PRIVILEGES IN SCHEMA schemaA GRANT UPDATE, INSERT, SELECT, DELETE ON TABLES TO db_writer;
ALTER DEFAULT PRIVILEGES IN SCHEMA schemaA GRANT SELECT ON TABLES TO db_reader;
Check this answer for more info