Difference Between Varchar and Varchar2 Data Types?: Salary Decimal (9,2) Constraint Sal - CK Check (Salary 10000)
Difference Between Varchar and Varchar2 Data Types?: Salary Decimal (9,2) Constraint Sal - CK Check (Salary 10000)
Varchar can store upto 2000 bytes and varchar2 can store upto 4000 bytes. Varchar will occupy space
for NULL values and Varchar2 will not occupy any space. Both are differed with respect to space.
Coalesce ( ) function can take N number of arguments and as a result it returns the first not null
parameter from the argument list. If in case all the arguments are evaluated as null then this function
returns NULL as a result.
1. Ease of use: A view hides the complexity of the database tables from end users.
Essentially we can think of views as a layer of abstraction on top of the database
tables.
2. Space savings: Views takes very little space to store, since they do not store actual
data.
3. Additional data security: Views can include only certain columns in the table so that
only the non-sensitive columns are included and exposed to the end user. In addition,
some databases allow views to have different security settings, thus hiding sensitive
data from prying eyes.
This “Analyze” command is used to perform various functions on index, table, or cluster. The
following list specifies the usage of ANALYZE command in Oracle:
Analyze command is used to identify migrated and chained rows of the table or a cluster.
It is used to validate the structure of an object.
This helps in collecting the statistics about the object used by the user and are then stored on
to the data dictionary.
It also helps in deleting statistics that are used by an object from the data dictionary.
A database index is a data structure that provides a quick lookup of data in a column
or columns of a table. It enhances the speed of operations accessing data from a
database table at the cost of additional writes and memory to maintain the index
data structure.
A database cursor is a control structure that allows for the traversal of records in a
database. Cursors, in addition, facilitates processing after traversal, such as retrieval,
addition, and deletion of database records. They can be viewed as a pointer to one
row in a set of rows.
You cannot use a function with Data Manipulation queries. Only Select queries are allowed
in functions.
You can use DML queries such as insert, update, select etc… with procedures.
Stored Procedures are pre-compiled objects which are compiled for the first
time and its compiled format is saved, which executes (compiled code)
whenever it is called.
Performance :
Choose an Advantageous Join Order
Join order can have a significant effect on performance. The main objective of
SQL tuning is to avoid performing unnecessary work to access rows that do not
affect the result. This leads to three general rules:
Avoid a full-table scan if it is more efficient to get the required rows through
an index.
Avoid using an index that fetches 10,000 rows from the driving table if you
could instead use another index that fetches 100 rows.
Choose the join order so as to join fewer rows to tables later in the join order
Tables should be arranged from smallest effective number of rows to largest effective
number of rows.
Normally optimizer picks the best execution plan, an optimal order of tables to be
joined. In case the optimizer is not producing a good execution plan you can control
the order of execution using the HINTS feature SQL. For more information see the
Oracle Database Lite SQL Reference.
For example, if you want to select the name of each department along with the name
of its manager, you can write the query in one of two ways. In the first example which
follows, the hint /*+ordered*/ says to do the join in the order the tables appear in
the FROM clause.