Basic Concepts Flashcards
Difference between primary key and unique key?
- PK is used to uniquely identify a row, can only have 1
UK is used when want to enforce unique constraints on a column/a group of columns, can have several - PK does not allow NULL, UK allows
- PK auto have a clustered index
UK have a non-clustered index
Clustered Index and non Clustered index
CI - is a special type of index that reorders the way records in the table are physically stored. … The leaf nodes of a clustered index contain the data pages.
NON-CI is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk
Index and partition
Local partitioned index -
1) Index within each individual partition
2) Are best suited to data warehouse application 0 used can extract that partition for analysis
3) Add/delete partition will not impact the index
4) Index are not have partition column information, not helping much when used want to certain range of data regardless of partition, the engine will need to search in every partition for the rows.
Global index - index cross the whole table
Global partitioned index - index have a different partition scheme than the whole table partition
1) Engine will only need to search the partition that the index range includes
2)will go invalid when the partition changes.
How does partition help?
- Using partition key on where clause, only search in that partition which is much faster
Range Partitioning
List Partitioning
Composite Partitioning
What is a View?
- searchable object(a virtual table) in a database that is defined by a query
- Can be created from 1 table/multiple tables
- contains all/subset of the tables based on the query condition
- View from 1 table can be updated, from multiple tables are usually read only
Adv: 1.Simplyfy complex queries 2. restrict user to certain data Disadv: 1. Performance issue: every time view is used the back query will be invoked. 2.Structure tightly associated with underlying table EXAMPLE - CREATE VIEW view_name AS SELECT column1, column2..... FROM table_name WHERE condition;
DB server - Tablespaces and data files
Oracle stores data logically in tablespaces and physically in datafiles associated with the corresponding tablespace
https://docs.oracle.com/cd/A57673_01/DOC/server/doc/SCN73/ch4.htm
Schema
A schema is a collection of schema objects. Examples of schema objects include tables, views, sequences, synonyms, indexes, clusters, database links, procedures, and packages