Atikh's DBA blog
  • Home
  • Oracle
  • MySQL
  • MongoDB
  • PostgreSQL
  • Snowflake
  • About Me
  • Contact Us
Showing posts with label Snowflake. Show all posts
Showing posts with label Snowflake. Show all posts

Snowflake : System defined roles in Snowflake

 Atikh Shaikh     Snowflake     No comments   

There are a total 5 default system-defined roles in snowflake, those are

ACCOUNTADMIN

SYSADMIN

SECURITYADMIN

USERADMIN

PUBLIC

Below is a graphical hierarchy of these roles in snowflake

system defined roles snowflake



ACCOUNTADMIN is a top-level role in snowflake architecture, it has privileges of both SYSADMIN and SECURITYADMIN

PUBLIC is a lower-level role in snowflake and USERADMIN role inherits all the privileges of PUBLIC and passes them on to SECURITYADMIN

 

Here we will discuss, what users can do when these roles are assigned.

 

ACCOUNTADMIN

inherits privilege of SYSADMIN and SECURITYADMIN

It should be granted to very limited users, and users with this role can do anything with snowflake objects

 

SECURITYADMIN 

USERADMIN role is granted to SECURITYADMIN role

user with this role can manage users and roles in snowflake architecture

user can manage any object grants globally

 

SYSADMIN 

user with this role can create data warehouses and databases 

once custom roles are created, need to assign it to SYSADMIN role

 

USERADMIN

user level role and assigned to individual users 

user with this role can create users and roles

 

PUBLIC

this role is automatically assigned to every user

user will be able to create their own objects

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Snowflake : show databases command optimized

 Atikh Shaikh     Snowflake     No comments   

In snowflake, we use the "show databases" command to see details about default and created databases, this command shows a lot of details about databases, what if we just need the names of the database not whole details about them, after digging out I found this "databases" is table present in INFORMATION_SCHEMA schema, so we can query the details from "databases" tables. 

To fetch details you need to select the data warehouse, database, and schema 

 

technosnow#(no warehouse)@(no database).(no schema)>use WAREHOUSE TECHNO_WS;

+----------------------------------+

| status                           |

|----------------------------------|

| Statement executed successfully. |

+----------------------------------+

1 Row(s) produced. Time Elapsed: 0.644s

technosnow#TECHNO_WS@(no database).(no schema)>use SNOWFLAKE;

+----------------------------------+

| status                           |

|----------------------------------|

| Statement executed successfully. |

+----------------------------------+

1 Row(s) produced. Time Elapsed: 0.810s

technosnow#TECHNO_WS@SNOWFLAKE.(no schema)>use schema INFORMATION_SCHEMA;

+----------------------------------+

| status                           |

|----------------------------------|

| Statement executed successfully. |

+----------------------------------+

1 Row(s) produced. Time Elapsed: 0.313s

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>desc databases;

+----------------+-------------------+--------+-------+---------+-------------+------------+-------+------------+-----------------------------------------------------------------+-------------+

| name           | type              | kind   | null? | default | primary key | unique key | check | expression | comment                                                         | policy name |

|----------------+-------------------+--------+-------+---------+-------------+------------+-------+------------+-----------------------------------------------------------------+-------------|

| DATABASE_NAME  | VARCHAR(16777216) | COLUMN | N     | NULL    | N           | N          | NULL  | NULL       | Name of the database                                            | NULL        |

| DATABASE_OWNER | VARCHAR(16777216) | COLUMN | N     | NULL    | N           | N          | NULL  | NULL       | Name of the role that owns the schema                           | NULL        |

| IS_TRANSIENT   | VARCHAR(3)        | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | Whether this is a transient table                               | NULL        |

| COMMENT        | VARCHAR(16777216) | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | Comment for this database                                       | NULL        |

| CREATED        | TIMESTAMP_LTZ(9)  | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | Creation time of the database                                   | NULL        |

| LAST_ALTERED   | TIMESTAMP_LTZ(9)  | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | Last altered time of the database                               | NULL        |

| RETENTION_TIME | NUMBER(9,0)       | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | Number of days that historical data is retained for Time Travel | NULL        |

+----------------+-------------------+--------+-------+---------+-------------+------------+-------+------------+-----------------------------------------------------------------+-------------+

7 Row(s) produced. Time Elapsed: 0.402s

 

Here you see the columns for the "databases" table, now you can fetch anything you want

 

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>select database_name from databases;

+-----------------------+

| DATABASE_NAME         |

|-----------------------|

| EXERCISE_DB           |

| SNOWFLAKE_SAMPLE_DATA |

| TECHNODB              |

+-----------------------+

3 Row(s) produced. Time Elapsed: 1.093s

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>


[Also Read - Different Editions of Snowflake]

[Also Read - How to Undrop database]

 

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Snowflake : spool output in log file

 Atikh Shaikh     Snowflake     No comments   

In almost all databases features, we have a spool file option, we will discuss the same spool option in snowflake
Assume, you need to execute the script which is a little long and the output can not be captured in a single screenshot, so we can make use of spooling the output in the log file. 

once you are ready to execute the script, browse to the location where you want to save a log file, in the snowsql command prompt use the below option (!spool on/off)

C:\Users>cd C:\Users\database

C:\Users\database>
C:\Users\database>snowsql -a **** -u technosnow

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>!spool snowflake_first_log.log
technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>SELECT CURRENT_DATABASE();
+--------------------+
| CURRENT_DATABASE() |
|--------------------|
| SNOWFLAKE          |
+--------------------+
1 Row(s) produced. Time Elapsed: 0.503s

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>SELECT CURRENT_SCHEMA();
+--------------------+
| CURRENT_SCHEMA()   |
|--------------------|
| INFORMATION_SCHEMA |
+--------------------+
1 Row(s) produced. Time Elapsed: 0.509s
technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>!spool off;
technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>

In this way, you can re-direct the output of scripts executed in the snowflake database
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Snowflake : Undrop database command

 Atikh Shaikh     Snowflake     No comments   

Snowflake database has a lot of features and benefits over the traditional database, one of the features is undrop database, assume you changed your mind after dropping a database, you can undo it using undrop database command,

let's see how exactly it works. this particular feature is based on the time travel feature of the snowflake, a schema, database or table can be restored within the parameter value of "data retention period", the default value of the same is 24 hours or 1 day, and it can set up to 90 days for the enterprise edition.

Undrop feature can be applied to the table, schema or database, here we will discuss database example 

 

+-----------------------+----------------+----------------+

| DATABASE_NAME         | DATABASE_OWNER | RETENTION_TIME |

|-----------------------+----------------+----------------|

| EXERCISE_DB           | ACCOUNTADMIN   |              1 |

| SNOWFLAKE_SAMPLE_DATA | ACCOUNTADMIN   |              1 |

| TECHNODB              | ACCOUNTADMIN   |              1 |

+-----------------------+----------------+----------------+

 

These are the current databases in the snowflake instance, now I will drop the technodb snowflake database

 

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>drop database TECHNODB;

+--------------------------------+

| status                         |

|--------------------------------|

| TECHNODB successfully dropped. |

+--------------------------------+

1 Row(s) produced. Time Elapsed: 0.610s

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>select database_name , database_owner, retention_time from databases;

 

+-----------------------+----------------+----------------+

| DATABASE_NAME         | DATABASE_OWNER | RETENTION_TIME |

|-----------------------+----------------+----------------|

| EXERCISE_DB           | ACCOUNTADMIN   |              1 |

| SNOWFLAKE_SAMPLE_DATA | ACCOUNTADMIN   |              1 |

+-----------------------+----------------+----------------+

2 Row(s) produced. Time Elapsed: 0.639s

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>

 

Here I have dropped a database technodb, you can from the above logs, now we have only two databases instead of three 

 

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>undrop database TECHNODB;

+------------------------------------------+

| status                                   |

|------------------------------------------|

| Database TECHNODB successfully restored. |

+------------------------------------------+

1 Row(s) produced. Time Elapsed: 0.491s

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA> select database_name , database_owner, retention_time from databases;

 

+-----------------------+----------------+----------------+

| DATABASE_NAME         | DATABASE_OWNER | RETENTION_TIME |

|-----------------------+----------------+----------------|

| EXERCISE_DB           | ACCOUNTADMIN   |              1 |

| SNOWFLAKE_SAMPLE_DATA | ACCOUNTADMIN   |              1 |

| TECHNODB              | ACCOUNTADMIN   |              1 |

+-----------------------+----------------+----------------+

3 Row(s) produced. Time Elapsed: 0.783s

technosnow#TECHNO_WS@SNOWFLAKE.INFORMATION_SCHEMA>

 

Here we see, that the database has been restored back with the undrop database command, In this way, we can do it for table and schema as well. 

 

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Snowflake : Using snowsql for snowflake database

 Atikh Shaikh     Snowflake     No comments   

A snowflake data warehouse is the latest addition to the trending database technology, In this article, we will be discussing snowsql, a command line tool used to access the snowflake database, there is another way as well to access the database i.e. web-based portal. still, there are many DBA's who love working on the command line instead of a web-based portal. 

Snowsql is supported on the below platforms 

  •             Red Hat Enterprise Linux or a compatible operating system.
  •             macOS (64-bit).
  •             Microsoft Windows (64-bit).

snowsql installer can be downloaded using the below link

download snowsql

follow the traditional approach to install snowsql i.e. next, next and finish 

once the installation is complete, execute the below command, if it gives output instead of error then your snowsql installation is successful

C:\Users>snowsql -v

Version: 1.2.23

C:\Users>

we can see, that snowsql is installed and the version is 1.2.23 

in order to login into the snowflake database, you need to have an account name, username, and password

also read know your snowsql account name

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Snowflake : Different editions of snowflake

 Atikh Shaikh     Snowflake     No comments   

 As we know, the snowflake is a very hot data warehouse technology today. we will see a different aspect of a snowflake in different articles, here we will discuss its different editions available for use. 

The below image gives an idea about different editions of snowflake

different editions of snowflake

so basically, there are a total of 4 editions of snowflake, in the trail account setup, snowflake won't show you about the fourth edition i.e. Virtual Private, as this is the very highest level of secure edition and is available for paid versions only. 

Standard Edition: This is a basic, introductory edition, standard features are available, not available for large-scale companies, and is enough for small-scale industries and educational institutes

Features (not limited to this) 

 

  • automatic data encryption, 
  • data warehouse support, 
  • time travel up to 1 day 
  • disaster recovery up to 7 days
  • secure data share, 
  • premium support 24/7

 

Enterprise Edition:  This is designed for large-scale industries with all features of the standard level edition 

Features

  • All benefits of the standard edition 
  • Multi-cluster data warehouse
  • time travel- up to 90 days
  • materialized views support
  • column level security 

[Also read: Snowflake account name]

Business Critical:  with all the features of the enterprise edition, this business-critical edition is designed for the highest data protection and is good for industries with very highly sensitive data such as banking 

 

Features 

  • All enterprise features 
  • extended support

Virtual Private large: This level of edition comes with the highest level of protection and security
Features 

  • All business-critical level features
  • dedicated virtual servers 
[Also Read -Snowflake: Introduction and Architecture]

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Snowflake : Introduction and Architecture

 Atikh Shaikh     Snowflake     No comments   

Snowflake is a very trending data warehouse technology due to its benefits and features over traditional database technology, here we will have a brief introduction to snowflake data warehouse and its architecture 

Snowflake is true software as a service provided with an advanced data platform.    

snowflake does not use traditional database technology; it is designed with a new SQL engine with innovative architecture designed for the cloud.

snowflake is a completely cloud-based data warehouse technology 

 

Now we will see why snowflake is a true SaaS (Software as Service) 

  • There is no hardware to select, install, configure or manage 
  • No software to install, configure or manage
  • maintenance, upgrade, and patching all is handled by snowflake itself

 

Snowflake cannot be run on an on-premise or hosted server

There are two main parts of the snowflake 

  • Compute - to fulfill the need for resources to compute or to perform operations
  • Storage - service to store data

  

Snowflake Architecture 

Snowflake architecture consists of three key layers  

  1. Storage 
  2. Query processing
  3. Cloud services 

 

snowflake introduction and architecture


Database Storage 

The database storage layer is basically to store and manage snowflake data, snowflake reorganizes data into internally optimized, compressed, and columnar formats. snowflake stores data in cloud storage such as AWS, GCP, or Azure.

data objects managed and stored by snowflake not are directly visible or accessible by customers of snowflake

 [Also read -How to get account name in snowflake ]

Query Processing (muscle of the system)

The query processing layer performs the execution of queries, this layer consists of virtual warehouses, Virtual warehouse is a virtual compute resource, that can be used to process all of the queries.

each virtual house is independent of the other, so the performance of one virtual warehouse does not impact the other's performance 

 

Cloud Services (the brain of the system) 

This cloud service layer is the combination of different services that are carried out across snowflake. 

Below are the services managed by this cloud service layer

  • access and authentication
  • infrastructure management
  • metadata management
  • query parsing and optimization
  • security
[Also read -Setting AWS demo account]

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit

Snowflake- what is account name in snowflake login

 Atikh Shaikh     Snowflake     No comments   

Snowflake is a really hot topic in 2021 and 2022 due to its benefits over traditional database offerings, Here I will show you, to check the account name in the snowflake portal, for login to snowflake you can use the link https://app.snowflake.com/, this is how the login page looks like and the first thing it will ask to enter the account name 

snowflake login page accountname

Once you enter the account name, it will ask for your username and password, the username is the one you have entered during creating the demo account for snowflake

snowflake login page

and once you enter your username and password, it will go to the main portal of snowflake, now click on the left bottom corner, you will see the below screen


snowflake account name




Now just click on highlighted part, it will give you one URL, which looks like below 

https://i****3.ap-southeast-1.snowflakecomputing.com

 The highlighted part is your account name that can be used for login purposes

[Also read -Introduction and Architecture of Snowflake]


Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit
Older Posts Home

Author

Atikh Shaikh
View my complete profile

Categories

  • MongoDB (18)
  • Oracle 12c (30)
  • Oracle12cR2 New Feature (3)
  • PostgreSQL (20)
  • RMAN (10)
  • Snowflake (8)
  • mysql (23)
  • oracle (73)

Blog Archive

  • ►  2018 (38)
    • ►  November (25)
    • ►  December (13)
  • ►  2019 (33)
    • ►  January (15)
    • ►  February (6)
    • ►  March (2)
    • ►  April (5)
    • ►  May (5)
  • ►  2020 (5)
    • ►  April (1)
    • ►  May (2)
    • ►  July (2)
  • ►  2021 (8)
    • ►  June (3)
    • ►  July (3)
    • ►  August (1)
    • ►  December (1)
  • ►  2022 (33)
    • ►  May (3)
    • ►  June (10)
    • ►  July (3)
    • ►  August (4)
    • ►  September (8)
    • ►  October (3)
    • ►  November (2)
  • ►  2023 (14)
    • ►  February (1)
    • ►  April (5)
    • ►  May (2)
    • ►  June (1)
    • ►  September (1)
    • ►  October (1)
    • ►  December (3)
  • ►  2024 (5)
    • ►  January (2)
    • ►  March (3)
  • ▼  2025 (5)
    • ►  March (1)
    • ►  April (3)
    • ▼  May (1)
      • Oracle 23ai : The all new Hybrid Read-Only for plu...

Popular Posts

  • ORA-29283: invalid file operation: unexpected "LFI" error (1509)[29437]
    I was trying to export the schema in my windows PC, it got stuck with below error    C:\Users\shaik\Videos\technodba exp>expdp userid...
  • Oracle Dataguard Broker Configuration (DGMGRL)
    Data Guard Broker is a command-line interface that makes managing primary and standby databases easy. DBA can use a single command to switch...
  • ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
    In previous articles, we have learned about user creation and grants  in MySQL in detail, but there are a few privileges called global priv...
  • PostgreSQL : How to get data directory location for PostgreSQL instance
    Sometimes, you start working on a PostgreSQL instance but forget about the data directory, here we will discuss different methods to know th...
  • Oracle 23ai : The all new Hybrid Read-Only for pluggable databases (PDBs)
      The latest Oracle database version, Oracle 23ai, introduced a new open mode called Hybrid Read-Only for pluggable databases (PDBs). Local ...

Labels

oracle Oracle 12c mysql PostgreSQL MongoDB oracle 19c Oracle23c oracle19c Orale PDB-CDB oracle12c python AWS Oracle ASM Virtualbox pluggable database storage engine

Pages

  • Disclaimer
  • Privacy Policy

Follow TechnoDBA

Copyright © Atikh's DBA blog | Powered by Blogger