Sybase add current user id on insert and update to the table - database

I need to track user making inserts and updates on Sybase table.
What is the best way of achieving this?

Please use trigger to track all the inserts and updates. For every action store/update USER name in a particular column say, modifier.

Related

Trigger to get table name

I have several bases on multiple servers with tables in the same column pattern.
What I need to do is create a trigger in the database to audit delete, update, insert is there any way I can dynamically leave the table name that was given update?
There is more than one table in each database to be monitored.
Every help is welcome
You can check with this answer this might help you. Here I have given idea to create a trigger to monitor the update value in table.
https://stackoverflow.com/a/54229188/10532500
The output is as shown below of the trigger in the form of an audit table.

How to identify user inserting data in a netezza table

Is there a way to identify which user inserted/modified a particular row in a netezza table? The table is open to a group of user and I need to track (for auditing purpose) who inserted each row before using that data.
Any help would be appreciated.
Thanks
If you enable AUDIT history collection (one of the best Netezza features apart from raw performance) it is possible to trace back from the InsertXID of each record

Hide table row from other Users In Database if it is access by User

I have an table on which multiple records.
if user(A) get record from table then others user can not get that record particular record that is retrieve by User(A) what should i do to reslove this
You can add a locked bool column to the table, to signify that the record is locked by some user. Rather than a bool, you can reference the user_id that has locked the row. You'll have to do this in your application code, since sql-server cannot do this work for you out of the box.
As i see in your comment,You can create new column or table to store id of user and flag accessed in that. While accessing records use this relationship.
Or please elaborate your question and if possible provide an table structure

Select last updated row ID and last deleted row ID in trigger before they occur in SQL Server

I need to get the id of the updated row in a table to use it to update another table via trigger
Also need to get the id of the deleted row in a table to use it to update another table via trigger
How can I do this?
Is there any built in functions in SQL Server?
If not what kind of trick that can help to accomplish this
Within your trigger, if you want to know the OLD value that was either updated / deleted
SELECT idColumnName FROM deleted
Where idColumnName is the column that contains the ID that you are interested in.
You can then use this ID value to then perform whatever processing that you need.
Additionally. if you want to use the NEW value being updated, the below query gives you that. This is useful especially in case of Updates where you want to compare old / new values of certain fields. In your case, since its an ID column, this will probably not be relevant
SELECT idColumnName FROM inserted

How can I insert row in table when one field is get updated?

I have requirement like, suppose I have a 'property' table which has 'ListingKey' field and I want to do entry in another table say 'property_history' table whenever 'ListingKey' field is update. How it is possible with mysql ? should I use trigger then how can I use it?
Please Help me,
Thanks,
:Jimit
By using trigger you can easily achieve this
following is link for the my sql trigger creation
http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html

Resources