You are on page 1of 8

Types of Subqueries

• 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.

Backup is a copy of data/database, etc. Backing up MS SQL Server database is essential


for protecting data. MS SQL Server backups are mainly three types - Full or Database,
Differential or Incremental, and Transactional Log or Log
Database is a collection of objects such as table, view, stored procedure, function, trigger,
etc.
In MS SQL Server, two types of databases are available.
 System databases
 User Databases

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

SQL Server Components


SQL Server works in client-server architecture, hence it supports two types of components:
(a) Workstation and (b) Server.
 Workstation components are installed in every device/SQL Server operator’s
machine. These are just interfaces to interact with Server components. Example:
SSMS, SSCM, Profiler, BIDS, SQLEM etc.
 Server components are installed in centralized server. These are services.
Example: SQL Server, SQL Server Agent, SSIS, SSAS, SSRS, SQL browser, SQL
Server full text search etc.

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.

SQL Server – Editions


What are the various editions of SQL Server 2019 that are available in the market?
SQL Server is available in various editions. This chapter lists the multiple editions with its
features.

 Enterprise: This is the top-end edition with a full feature set.


 Standard: This has less features than Enterprise, when there is no requirement of
advanced features.
 Workgroup: This is suitable for remote offices of a larger company.
 Web: This is designed for web applications.

 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.

 Compact: This is free embedded database for mobile application development.


The maximum size of the database is 4 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.

What are the two authentication modes in SQL Server?


There are two authentication modes –

 Windows Mode
 Mixed Mode

Modes can be changed by selecting the tools menu of SQL Server configuration properties and
choose security page.

What Is SQL Profiler?

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 are the types of sub query?


There are three types of sub query –

 Single row sub query which returns only one row


 Multiple row sub query which returns multiple rows
 Multiple column sub query which returns multiple columns to the main query. With that
sub query result, Main query will be executed.

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

What are the types of Triggers?


There are four types of triggers and they are:

 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 unique key?


 A Unique key constraint uniquely identified each record in the database. This provides
uniqueness for the column or set of columns.
A Primary key constraint has automatic unique constraint defined on it. But not, in the
case of Unique Key.
There can be many unique constraint defined per table, but only one Primary key
constraint defined per table.

What is a foreign key?


 A foreign key is one table which can be related to the primary key of another table.
Relationship needs to be created between two tables by referencing foreign key with the
primary key of another table.

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.

What is TCL in SQL Server?


 Answer: TCL is Transaction Control Language Commands which are used to manage
the transactions in the SQL Server.

Which TCL Commands are available on the SQL Server?


Answer: There are 3 TCL Commands in the SQL Server. These are as follows:
 Commit: This command is used to save the transaction permanently in the database.
 Rollback: This is used to roll back the changes that are done i.e. to restore the database
in the last committed state.
 Save Tran: This is used for saving the transaction to provide the convenience that the
transaction can be rolled back to the point wherever required.

How do you create a table in SQL?

What are relationships in SQL Server database?


Relationships are created by linking the column in one table with the column in another table.
There are four different types of relationships that can be created.

The relationships are listed below:

1. One-to-One Relationship
2. Many-to-One Relationship
3. Many-to-Many Relationship.

How to delete a row in SQL?


We will be using the DELETE query to delete existing rows from the table:
DELETE FROM table_name
WHERE [condition];

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.

What is the update command in SQL?


The update command comes under the DML(Data Manipulation Langauge) part of sql and is
used to update the existing data in the table.
UPDATE employees
SET last_name=‘Cohen’
WHERE employee_id=101;

What are the types of SQL Queries?

We have four types of SQL Queries:

 DDL (Data Definition Language): the creation of objects


 DML (Data Manipulation Language): manipulation of data
 DCL (Data Control Language): assignment and removal of permissions
 TCL (Transaction Control Language): saving and restoring changes to a
database

Let’s look at the different commands under DDL:

Command Description

CREATE Create objects in the database

ALTER Alters the structure of the database object

DROP Delete objects from the database

TRUNCATE Remove all records from a table permanently

COMMENT Add comments to the data dictionary

RENAME Rename an object

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

How to start SQL Server


Launch the SQL Server Management Studio from the START menu. Login using Windows
Authentication. In the Object Explorer window pane, you can view the list of databases and
corresponding objects.

What are Datafiles?


The datafiles contain all the database data. The data of logical database
structures, such as tables and indexes, is physically stored in the datafiles
allocated for a database.
What is data blocks ?
Data Blocks are the base unit of logical database space. Each data block
represents a specific number of bytes of database space on a disk.The data
blocks can be 4 K,8 K size depending on the requirement.

How will you differentiate between Varchar & Varchar2?

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

You might also like