Views are virtual tables based on the result-set of SQL statements.
create of replace view schema_name.view_name as select a, b .. from schema_name.table_name where 1=1 group by 1,2,3... ;
- Easy creation of alias and using them
- Store calculation logics and add abstractions.
- To improve securities - limit data access of a table.
- Migrate from one table to another
- Run time of query needs to be less.
- When column names of the views are not finalized.
- When you are planning to create multiple views on top of it and this view might change often.
They are lookup table which enhances the SQL engine's performance in data retrieval.
create index index_name on table (col_1, col_2,.....);
- Dataset is really big.
- Very often filter based on few columns with a high number of classes.
- Often joined with other tables on few columns.
- When you are using replica of production tables.
- Storage cost is not an issue.
- Columns do not update very frequently.
- When you are using the table for production writes.
- Tables is going to be of minimal rows.
- When increasing the storage would be costly.
- Columns switch classes very frequently.
- Not planning to use where clause or aggregations.
A SQL transaction is a grouping of one or more SQL statements that interact with a database and maintains database integrities (ACID Properties) before and after it has interacted with the database.
BEGIN; SQL Statements SAVEPOINT savepoint_name; SQL Statements ROLLBACK TO savepoint_name; SQL Statements COMMIT;