In Snowflake I want to be able to see which objects have been modified by which users.
In the Snowflake documentation it states a stream can be created to track object changes but does not mention whether this includes tracker the user who made the changes.
Can someone confirm if user changes are tracked?
Thanks
Tracking the actual changes to objects with users who did it, is not a supported feature in Snowflake at the moment.
However, there can be different alternatives to extract what has happened to a given object.
There is an example of that here Get ddl type sqls from Snowflake History
The above linked example only shows four columns - there is also the possibility of retrieving the USER who issued the query, the role etc. from the same query.
Regarding STREAMS: A STREAM in Snowflake only tracks the changes to the data, not who made the changes or what DDL changes has happened to a table.
Hope that clarifies things for you.
Related
Snowflake database storage includes (maybe there are some others)
tables
time travel
fail safe
clones
files staged
I am trying to find a way to calculate tables + time-travel + fail-safe with and without clones not using TABLE_STORAGE_METRICS.
Currently looking at ACCOUNT_USAGE.database_storage_usage_history, but I am not sure what is included in AVERAGE_DATABASE_BYTES.
How do I find the correct values for current database?
Edit:
I am not an account admin
Would like to use query instead of UI
Edit 2: Result from SELECT * FROM INFORMATION_SCHEMA.TABLE_STORAGE_METRICS;
With no IMPORTED privilege or permission to view SNOWFLAKE database.
The documentation is a great source of information on this:
https://docs.snowflake.com/en/sql-reference/account-usage/database_storage_usage_history.html#database-storage-usage-history-view
Number of bytes of database storage used, including data in Time
Travel.
Per your list, this would include tables, clones (which are tables on their own), and Time Travel.
For stages, you'd need to use the STAGE_STORAGE_USAGE_HISTORY view.
Is there a reason you don't want to use the TABLE_STORAGE_METRICS? Just curious.
If you are an accout admin, you should be able to see this on your snowflake console
I am now working on a project which requires to show the transaction history of one customer and if the product customer buys is under warranty or not. I need to use the data from the current system, the system can provide Web API, which is a .csv file. So how can I make use of the current system data?
A solution I think of is to download all the .csv files and write scripts to insert every record into the database I built which contains the necessary tables and relations to hold the data I retrieve. Then I can have a new database which I want. because I never done this before so I want know if it is feasible?
And one more question would be, if I should store the data locally or use a cloud database like Firebase?
High-end databases like SQL Server and Oracle come with utilities that allow you to read directly from a csv file. Check the docs. Having done this many times, the best procedure I found was to read the file into one holding table. This gives you the chance to examine the data and find any unexpected quirks or missing fields. This allows you to correct the data, where possible.
Then write the scripts to move the data from the holding table into the proper tables you have designed. This must be done in a logical manner. For example, move the customer data before the buy transactions. Thus any error messages you get will not be because you tried to store a transaction before you stored the customer. (You will have referential integrity set up, yes?) This gives you more chances to correct or adjust the data or just identify problems more or less at your leisure.
Whether or not to store the data in the cloud is strictly according to the preferences of your employer.
I am trying to design my database and I want to have the ability to keep a track of history of changes.
I will have a table that will have all the nutritional facts of an food. When a user makes changes to the item(say changes calories from 100 to 200). I want to make that as a new revision.
That way a person who comes along can see that it was original 100 calories and then was updated to 200 calories. I guess this would be alot like how stack does it now where you can see what has been edited.
I am wondering what is the best way to do this? I am using sql server and nhibernate.
I was thinking of have another column or something that would be revision number. Then every-time a revision is made the number is incremented. Is this a good way?
NHibernate.Envers helps you with that.
You could just do as you've written, add another revision number.
Another approach would be adding a timestamp and use that as history. Every time an item is updated you add a row with the current values and the current timestamp.
I'd normally use some form of audit table(s) to handle this. What we do where I currently work is have all our audit tables under an audit schema, and we have an audit table for every that we wish to track revisions for. We don't use NHibernate, so we simply utilise triggers to ensure that every update to a given row is recorded in the audit table along with a timestamp and user id so you can get some context and order to the way in which the revisions were made.
It seems like it is difficult using triggers with NHibernate, but you could use something like NHibernate interceptors or events as mentioned in this post. I'd say triggers would be preferable to relying on your code, but if this is the only way to go with NHibernate, then maybe it is worth a look.
Lastly, I've seen it mentioned that you can use SQL Servers native audit or trace capabilities. I've never used this myself, but do remember some post on SO suggesting that this replaced the need for creating your own manual audit tables and associated triggers. It seems to do what you want as illustrated by this quote from the link above;
The auditing of activity of users, roles, or groups on database
objects can be restricted down to the table level. That is, you can
target SQL Server Audit to track specific activities of a user or
users down to the individual table level. For example, SQL Server
Audit allows a record to be made of all the UPDATEs to the Payroll
table by DBO.
To me that sounds more like a true audit rather than just a revision history, but maybe someone with more experience in this area could comment on its feasibility to be used for revision tracking. Of course, you'd have to see what effect it had on NHibernate also.
My wife works for a medium sized retail chain. Managers from each of the 80 outlets have to fill in one row of performance info for each of their staff (900 in all), but aren't allowed to see the data of other stores' staff.
My wife currently manages this with lots of spreadsheets, because each month the executive change what they want to collect, and their IT team don't have the resources to update their SAS system. She has to manually compile all the data into 1 spreadsheet for analysis which is time consuming and error prone. She's recently gone from having to do this for 20 outlets to 80 outlets and thinks she must be an easier way.
Is there a simple form based system, that can leverage what is already installed (microsoft office and lotus but not MSAccess), or can be run from a network drive. Cloud apps are banned. Excel's security is all wrong. Can word form templates append to a shared data source? Any ideas?
TIA
You could have a single table with all the data, then create 'shadowtables' on this table for each individual store.
in MySQL this would probably be either a 'partition table' (I've never used this so not sure how it works) or the use of temp tables.
You would then need to implement a method whereby when a user logs in at a given location (IP address) a trigger would create the temp table, then populate it with the relevent data for the store at that IP address.
An alternative (probably easier too) would be to have a specied table for each store, then grant users specific priveleges on each table you create. Again you'll need trigers to either populate a single 'master table' with info as it is updated, or you will just send a
select * from outlet1, outlet2... outlet80
again you may decide to create a temp table from the above select, and implement a custom script to create it only when required.
In fact that is probably how I would do it.
Then in you web interface have a button to create the temp table, and display it to the current user (provided they have the required priveleges to view all the tables of course).
I don't know for certain if Lotus is able to implement this, I don't know about its 'database' solution. I know that to do something similar in Access isn't that hard, the only downside would be needing to handle user identification (which Access doesn't do natively), again I don't know about Lotus.
In my experience the 'flat file database systems' don't generally handle user permisions in a native fashion, it is put onto the interface development to hand this.
I'm not sure how helpful the answer is, but it may take you a little way to a solution (even if you end up going for a server/client dbms system)
You can use Lotus for this. A simple start for you:
Create a database with one form and one view
On the form add whatever fields you want but also add a computed-when-composed multi-value field of type "Readers" with formula:
"[Admin]" : #Name( [CANONICALIZE];#userName)
With the exception of those with an Admin role (e.g., your wife), the view will display to each user only the records that the user created. The users will have to create one record per row.
Alternatively you could create an agent in the database that reads the data from an Excel file and builds the documents (records) with the READERS field's value computed as the documents are created.
If that's the route you want to take post a reply here and I'll post some code to (i) prompt a user to select an excel file, (ii) read the excel file data into lotus notes, (iii) implement a READERS field to see that documents are kept confidential between the creator and the Admin role people.
Hope that helps.
I am working in asp.net MVC 3 Website and I need to keep track of any changes made to a table/entity. Whenever on Edit view something is modified, a list of changes will display with date, changes made columns below that Edit view. Do I need to create another table with entityHistory Name or I need to insert another record in same table for that ?
Please suggest
Depends what you want to do with the history data. If you want to show the record or object graph snapshots I have found creating a History table, with the same columns as the current table, easier to work with in building up how the complete record looked after or before a certain change. This also means that you'll have duplicated tables and data.
If your needs is a pure audit requirement it is easier to have one/two tables that holds data for entity, property, old value and new value columns.
Besides Audit options, SQL Server has now CDC (Change Data Capture in SQL2008) feature which enables developers to trace data changes on a sql table
You can build a similar logging mechanism by using triggers (refer to http://www.kodyaz.com/articles/sql-trigger-sql-server-trigger-example-to-log-changes-history.aspx for a sample)
You can also check the following article for an enhanced solution for logging data changes similar to CDC in SQL2005 http://www.kodyaz.com/articles/log-data-changes-using-change-data-capture-for-sql-server-2005.aspx