Snowflake Gui - Just Shows Tables and Views - database

On the left part of the web interface for Snowflake, it shows me databases, schemas, tables, and views.
Is there a way to show functions that were created in a schema, or does it just show tables and views?

the new snowsight has this :-)

You have to run the various "SHOW ..." commands to see these objects

Alternatively, you can view the definition of a function by using either of the following commands in the query interface:
SELECT GET_DDL('function', <function_name(argument_datatype)>');
or:
DESC FUNCTION <function_name(argument_datatype)>;

Related

Dependency Checks in Snowflake

I have below requirement.
I want to drop table : DIM_SALES_DETAILS
Before dropping, I want to run a query which will provide me all those object names (Views, Materialized Views, Stored Procedures, Tasks etc.) where this table has been used.
Is there a way we can get this ?
Thank You.
Have you tried to query the OBJECT_DEPENDENCIES view in the Account Usage schema of the shared SNOWFLAKE database?
https://docs.snowflake.com/en/user-guide/object-dependencies.html#impact-analysis-find-the-objects-referenced-by-a-table
There are some sample queries to find out the dependent objects.

Is there a way in Snowflakes to get the list of tables used from given set of views

I'm looking for a SQL script or some metadata table for views which have the source info.
You can use the function GET_OBJECT_REFERENCES to return the list of objects referenced by a view.
Please review the below documentation for more information and example:
https://docs.snowflake.com/en/sql-reference/functions/get_object_references.html#get-object-references

Unable to get definition for Sales.vw_CustomerOrders view in AdventureWorks2017 sample database

Looking at the AdventureWorks2017 database I ran across a view called Sales.vw_CustomerOrders. Wondering where it was getting its data I tried to query the object definition and the results came back NULL
SELECT definition
FROM sys.sql_modules
WHERE object_id = Object_id('Sales.vw_CustomerOrders')
I noticed the icon is slightly different from the other views and SSMS won't allow you to generate a create statement either (only a drop). What is this particular view? Why can't you generate a create statement for it? How can I find out how it gets its data?
TIA
As #MeyssamToluie mentioned in comments, view Sales.vw_CustomerOrders is not part of the out-of-box AdventureWorks database.
The different SSMS icon indicates the object is encrypted. When a view is created using WITH ENCRYPION option, the definition is obfuscated, not visible in the sys.sql_modules system view, and the CREATE cannot be scripted via normal methods. You'll find undocumented/unsupported ways to get the clear text definition of obfuscated objects with an internet search.
Use OBJECTPROPERTY to identify the encryption status of the view:
SELECT OBJECTPROPERTY(object_id, 'IsEncrypted') AS IsEncrypted, *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'Sales.vw_CustomerOrders');

What is the best way to cross reference two SQL Views in Report Builder?

I'm new to SQL queries and need to build a custom report in Microsoft SQL Report Builder 3.0. The data source is a SCCM database. I need help with understanding the best approach to achieve the following:
We need to cross reference if a computer exist in two Views, if so show that name in the report.
InputParameter1 = "Please select a View"
InputParameter2 = "Cross reference with this other View"
If I know the names of the Views beforehand I have a query to get what I need from the SQL server, but I need to create a parameter-based report where you select two Views dynamically and the report cross reference them for you and present which computers exists in both Views.
This is the query I can use for a static result. v_CM_RES_COLL_CMS0020B and v_CM_RES_COLL_CMS000D1 are examples of names of possible Views, until I can solve the parameter issue in Report Builder:
SELECT v_GS_SYSTEM.Name0
FROM v_GS_SYSTEM
WHERE Name0 IN
(SELECT Name from v_CM_RES_COLL_CMS0020B)
AND Name0 IN
(SELECT Name from v_CM_RES_COLL_CMS000D1)
I don't know how to proceed in how to make the above query into a parameter report in Report Builder. Somehow I need to change v_M_RES_COL_CMS00### to what ever the user inputs to the parameters. Does anyone know how? Any help is greatly appreciated.

How do you find out which database links are used in queries for the Oracle RDBMS?

I would like to find out if any and which database links are being used, for a schema, and in which tables. Is it possible via the data dictionary somehow?
Is this possible with the Oracle RDBMS?
I know the answer by Dougman is accepted and accurate. But here is some more information.
If the user is not a DBA user, it will not have access to DBA_DB_LINKS. Also, USER_DB_LINKS will display the db links created by the current user, so that won't list all the DB links that the user has access to.
You can use ALL_DB_LINKS to get the links that the user has access to.
select * from all_db_links;
This will show you any database links set up on the database:
select * from dba_db_links;
You would then have to search for any queries or objects using the db link by doing a text search of them for the link syntax <tablename>#<dblink name>
You can first edit all sql code of a schema:
ex:
SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner)
FROM all_OBJECTS
WHERE (OWNER = 'your schema name');
and then search in the result the pattern of the db_link, which looks like #dblink_name.

Resources