Professional Documents
Culture Documents
• Single-row subqueries: Queries that return only one row from the inner SELECT statement
• Multiple-row subqueries: Queries that return more than one row from the inner SELECT
statement
What is a table?
The data in an RDBMS is stored in database objects which are called as tables. This table
is basically a collection of related data entries and it consists of numerous columns and
rows
What is a NULL value?
A NULL value in a table is a value in a field that appears to be blank, which means a field
with a NULL value is a field with no value.
It is very important to understand that a NULL value is different than a zero value or a
field that contains spaces. A field with a NULL value is the one that has been left blank
during a record creation
SQL Constraints
Constraints are the rules enforced on data columns on a table. These are used to limit the
type of data that can go into a table. This ensures the accuracy and reliability of the data
in the database.
Data Integrity
The following categories of data integrity exist with each RDBMS:
Entity Integrity: There are no duplicate rows in a table.
Domain Integrity: Enforces valid entries for a given column by restricting the
type, the format, or the range of values.
Referential integrity: Rows cannot be deleted, which are used by other records.
User-Defined Integrity: Enforces some specific business rules that do not fall
into entity, domain or referential integrity.
SQL ─ Data Types
SQL Data Type is an attribute that specifies the type of data of any object. Each column,
variable and expression has a related data type in SQL. You can use these data types while
creating your tables. You can choose a data type for a table column based on your
requirement.
Restoring is the process of copying data from a backup and applying logged transactions
to the data. Restore is what you do with backups. Take the backup file and turn it back
into a database
Advantages of Instances
To install different versions in one machine.
To reduce cost.
To maintain production, development, and test environments separately.
To reduce temporary database problems.
To separate security privileges.
To maintain standby server.
Developer: This is similar to Enterprise, but licensed to only one user for
development, testing and demo. It can be easily upgraded to Enterprise without
reinstallation.
Express: This is free entry level database. It can utilize only 1 CPU and 1 GB
memory, the maximum size of the database is 10 GB.
Datacenter: The major change in new SQL Server 2008 R2 is Datacenter Edition.
The Datacenter edition has no memory limitation and offers support for more than
25 instances.
Business Intelligence: Business Intelligence Edition is a new introduction in SQL
Server 2012. This edition includes all the features in the Standard edition and
support for advanced BI features such as Power View and PowerPivot, but it lacks
support for advanced availability features like AlwaysOn Availability Groups and
other online operations.
Enterprise Evaluation: The SQL Server Evaluation Edition is a great way to get a
fully functional and free instance of SQL Server for learning and developing
solutions. This edition has a built-in expiry of 6 months from the time that you
install it.
Pages
It is the fundamental unit of data storage in MS SQL Server. The size of the page is 8KB.
The start of each page is 96 byte header used to store system information such as type of
page, amount of free space on the page and object id of the object owning the page. There
are 9 types of data pages in SQL Server.
Data - Data rows with all data except text, ntext and image data.
Index - Index entries.
Test\Image - Text, image and ntext data.
GAM - Information about allocated extents.
SGAM - Information about allocated extents at system level.
Page Free Space (PFS) - Information about free space available on pages.
Index Allocation Map (IAM) - Information about extents used by a table or
index.
Bulk Changed Map (BCM) - Information about extents modified by bulk
operations since the last backup log statement.
Differential Changed Map (DCM) - Information about extents that have changed
since the last backup database statement.
Windows Mode
Mixed Mode
Modes can be changed by selecting the tools menu of SQL Server configuration properties and
choose security page.
SQL Profiler is a tool which allows system administrator to monitor events in the SQL server.
This is mainly used to capture and save data about each event of a file or a table for analysis.
What is a Trigger?
Triggers are used to execute a batch of SQL code when insert or update or delete
commands are executed against a table. Triggers are automatically triggered or executed
when the data is modified. It can be executed automatically on insert, delete and update
operations
Insert
Delete
Update
Instead of
What is a Database?
Database is nothing but an organized form of data for easy access, storing, retrieval and
managing of data. This is also known as structured form of data which can be accessed in
many ways
What is a join?
This is a keyword used to query data from more tables based on the relationship between
the fields of the tables. Keys play a major role when JOINs are used.
What is a View?
A view is a virtual table which consists of a subset of data contained in a table. Views are
not virtually present, and it takes less space to store. View can have data of one or more
tables combined, and it is depending on the relationship.
1. One-to-One Relationship
2. Many-to-One Relationship
3. Many-to-Many Relationship.
What is pl sql?
PL SQL stands for Procedural language constructs for Structured Query Language. PL SQL
was introduced by Oracle to overcome the limitations of plain sql. So, pl sql adds in
procedural language approach to the plain vanilla sql.
Command Description
What is OLAP?
OLAP stands for Online Analytical Processing. And a class of software programs which are
characterized by relatively low frequency of online transactions. Queries are often too complex
and involve a bunch of aggregations.
What is a schema?
A schema is a collection of database objects in a database for a particular user/owner. Objects can be
tables, views, indices and so on
Both Varchar & Varchar2 are the Oracle data types which are used to store character
strings of variable length. To point out the major differences between these,
Varchar Varchar2
Can store characters up to 2000 bytes Can store characters up to 4000 bytes.
It will hold the space for characters defined
during declaration even if all of them are It will release the unused space
not used