How to Drop user from Netezza - netezza

How to drop user from netezza database?
I am trying to drop user name from netezza using below query
DROP USER 'mxy';
but it's giving me error like "You can't remove 'mxy' user because user contains objects"
'mxy' user create one user with his own schema object "mxy.jey'
How to remove user created object and as well 'mxy' user?

User "mxy" have some table object like mxy.example table so i couldn't delete the mxy user from the Netezza database so i changed the table schema to system admin user account and now i am able to remove "mxy" user from Netezza database.

Related

How to change prefix table in SQL Server?

I have DataBase Name: PMKIT, prefix Table : PMKIT.TableName.I want rename PMKIT.TableName to DBO.TableName. Can you help me!
You need to transfer your table from PMKIT schema to dbo schema:
ALTER SCHEMA dbo TRANSFER PMKIT.TableName;
Read more here: https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-schema-transact-sql?view=sql-server-2017
Or you can follow these steps to perform the same action via Management Studio user interface
Right click on your table and select Design
In Design view, open the properties window(Simply hit the F4 key on keyboard)
Find the Schema property and change it
Save your changes, and close the Design view

How to assign a user just to one tablespace? - Oracle 11g

When installing a new db, it is a best practice to create a new user and a new tablespace, because creating tables shouldn't be done with SYS/SYSTEM or/and on the tablespace "SYSTEM".
So I created the user "alex" and the tablespace "alexData" with the following commands:
CREATE TABLESPACE alexData datafile 'C:/oraclexe/alexData.dbf'
size 100M;
ALTER USER alex QUOTA UNLIMITED ON alexData;
ALTER USER alex QUOTA 0 ON SYSTEM;
I want to accomplish that the user "alex" is only able to save his data in the "alexData" tablespace.
Why? Because when he wants to access a table he shouldn't always have to mention the tablespace "alexData".
otherwise he would always need to mention it like:
SELECT *
FROM alexData.table
but I want that he always is JUST in that tablespace so he doesn't need to mention it:
SELECT *
FROM table;
Is this possible?
First of all , Consequence of what #Mat told, you can not use like
SELECT * FROM alexData.table_ but SELECT * FROM alex.table_, since a table may be prefixed with a schema name. As you may notice, you can not use table,which is a keyword for oracle, as table name, so i've used table_ instead.
When you create user, the object is automatically created inside that tablespace. As an example, when create table ... statement issued, there's no need to mention about the tablespace provided that you create or alter your user with DEFAULT TABLESPACE phrase:
CREATE USER alex IDENTIFIED BY alex321
DEFAULT TABLESPACE alexData
TEMPORARY TABLESPACE alexTempData;
OR
ALTER USER alex IDENTIFIED BY alex321
DEFAULT TABLESPACE alexData;
You cannot create triggers on a table owned by SYS, or SYSTEM see:
Why cannot I create triggers on objects owned by SYS?
If the table on which you wish to create a trigger is a table which you have created, it should live on the ALEX schema. This schema should have privileges to create triggers on tables created in the same schema. As previously mentioned in the comments, you should revoke the CREATE ANY TABLE privilege from the ALEX schema, as this user should only be able to create tables on their own schema.

prevent some user from seeing db2 tables structure

How can I restrict some users in DB2, not to see the table structure. I set the user privilege and restrict user from table access. so that user can not select data or change table but still can see the table structure or describe it.
This problem refers to row access in tables which is added in db2 version 10.
I had this problem too.
you can use this version - if applicable- and restrict user access from specific table structures.
You need to remove the select grant on catalog tables. For example, the following query should return 0 rows when executing with q restricted user.
db2 "select tabschema, tabname from syscat.tables"
All tables and views in the following schemas should not have select on public, nor in any group the restrictive user is in.
sysibm
syscat
db2 revoke select on SYSIBM.SYSTABLES from username

Triggers in sql server 2008 management studio

I am trying to set up the trigger in a way that when the administrator (not users) make any changes to the database, all the changed data with the administrator name and time gets saved in the audit table (already created) that has all the possible fields.
I have created triggers on each table for any sort of updates in those tables. The trigger saves the information in audittable. However, i want to restrict this action for administrators only. Like I only want to keep the record of changes made by adminsitrators with their name, time and changes made by them(I have a separate table for adminsitrator names, username, pw and all that).
Can someone please help me with that.
Thanks
To get the user you may use:
server level (login)
select system_user , suser_sname() , suser_sid()
db level (db user)
select session_user , current_user , user , user_name() , user_id()
Than and check that this user is admin or not in that additional table.
You can try one of these two functions, depending on what you define as "administrator".
SELECT IS_MEMBER('dbo'), IS_SRVROLEMEMBER('sysadmin')
The IS_MEMBER function evaluates the database role and the IS_SRVROLEMEMBER evaluates the server role. So, if you want to know if the user is a database admin, you would use IS_MEMBER. These will work for user-defined roles as well as built-in roles.
UPDATE:
Here's an example of the trigger that would add data to the audit table when a server administrator inserts data to the table.
CREATE TRIGGER trg_InfoUpdates ON tblCustomerInfo
FOR INSERT AS
IF IS_SRVROLEMEMBER('sysadmin') = 1
BEGIN
INSERT INTO tblAuditLog (CustomerID)
SELECT CustomerID
FROM inserted
END
;

default schema synonym

I have a database FooDb with a schema BarSchema that contains a table Tbl (i.e. FooDb.BarSchema.Tbl)
I am also logged in as a user with BarSchema as default.
This query works fine
SELECT * FROM FooDb..Tbl
I also have a synonym for this table in another db
CREATE SYNONYM TblSynonym FOR FooDb..Tbl
But now I get an error "Invalid object name 'FooDb..Tbl'" when executing
SELECT * FROM TblSynonym
If i change the synonym to
CREATE SYNONYM TblSynonym FOR FooDb.BarSchema.Tbl
it works fine.
Why doesn't the default schema work in synonyms?
(The background is that I'm consoldating data from several databases which all got same table names but different schema names. It would be a lot easier if I could set the default schema for each database on the user and then ignore it everywhere in the script)
The documentation suggests the db..tbl syntax should work:
schema_name_2 Is the name of the
schema of the base object. If
schema_name is not specified the
default schema of the current user is
used.
This works for me in SQL Server 2008:
create synonym TestSynonym for TestDB..TestTable
One cause might be that the default schema is associated with the user, not the database. Check if your user has an unexpected default schema? In my SSMS, that setting is located under Database -> Security -> Users -> Properties.

Resources