Author: sqlschool

What is PL/SQL?

What is PL/SQL?

PL/SQL stands for Procedural Language extension of SQL.

PL/SQL is a combination of SQL along with the procedural features of programming languages.

It was developed by Oracle Corporation in the early 90’s to enhance the capabilities of SQL.

The PL/SQL Engine:

Oracle uses a PL/SQL engine to processes the PL/SQL statements. A PL/SQL language code can be stored in the client system (client-side) or in the database (server-side).



The @@ROW COUNT variable returns the number of rows read by the last executed statement. If any statement does not return any rows, then value of @@ROWCOUNT variable is set to zero.



Using @@ implies that it is a global variable. Also @@ROWCOUNT returns the value of int type i.e. the maximum no of rows @@ ROWCOUNT can return is 231 (2,147,483,647). For returning rows greater than this limit, ROWCOUNT_BIG function is used.

More Information visit:



DCL commands are used to enforce database security in a multiple user database environment. Two types of DCL commands are GRANT and REVOKE. Only Database Administrator’s or owner’s of the database object can provide/remove privileges on a database object.


SQL GRANT is a command used to provide access or privileges on the database objects to the users.

The Syntax for the GRANT command is:

GRANT privilege_name
ON object_name
TO {user_name |PUBLIC |role_name}

  • privilege_name is the access right or privilege granted to the user. Some of the access rights are ALL, EXECUTE, and SELECT.
  • object_name is the name of an database object like TABLE, VIEW, STORED PROC and SEQUENCE.
  • user_name is the name of the user to whom an access right is being granted.
  • user_name is the name of the user to whom an access right is being granted.
  • PUBLIC is used to grant access rights to all users.
  • ROLES are a set of privileges grouped together.
  • WITH GRANT OPTION – allows a user to grant access rights to other users.

For Example:

GRANT SELECT ON employee TO user1;

This command grants a SELECT permission on employee table to user1.

You should use the WITH GRANT option carefully because for example if you GRANT SELECT privilege on employee table to user1 using the WITH GRANT option, then user1 can GRANT SELECT privilege on employee table to another user, such as user2 etc.

Later, if you REVOKE the SELECT privilege on employee from user1, still user2 will have SELECT privilege on employee table.

SQL LIKE Operator

The LIKE operator is used to list all rows in a table whose column values match a specified pattern. It is useful when you want to search rows to match a specific pattern, or when you do not know the entire value. For this purpose we use a wildcard character ‘%’.

For example: To select all the students whose name begins with ‘S’

SELECT first_name, last_name
FROM student_details
WHERE first_name LIKE ‘S%’;

The output would be similar to:

first_name          last_name
————-          ————-
Stephen                 Fleming
Shekar                   Gowda

The above select statement searches for all the rows where the first letter of the column first_name is ‘S’ and rest of the letters in the name can be any character.

Create a Database by Script

SQL Server accepts Transact-SQL (which is an extended version of the SQL standard), so you could create the database by running the following SQL script.

USE master;

To do this, open a new query by clicking New Query in the toolbar and run an SQL CREATE DATABASE statement.

Just as you can specify certain properties when creating a database via the GUI, you can include those same properties when creating a database by script. Here’s an example of specifying settings for the data and log files.

USE master ;
( NAME = Music_dat,
FILENAME = ‘C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\Music.mdf’,
SIZE = 10,
( NAME = Music_log,
FILENAME = ‘C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\Music_log.ldf’,

What is a NULL Value?

A field with a NULL value is a field with no value.

If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value.

Note: It is very important to understand that a NULL value is different from a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation!

What is the difference between various types of joins? For instance, there’s inner join, left join, right join, full join, cross join, natural join, equi-join, and semi-join?

Different types of joins are required depending on the type of data wrangling one needs to do. Let’s work with an example here. In this toy example, we have 2 tables-

  1. Married- This contains the name and social security number ( SSN) of the people who are married.
  2. Home Owners- This contains the name and social security number ( SSN) of the people who own a home

SSN is unique for each person and will be used as a primary key to merge two tables.

Let’s now look at the types of joins using the above 2 tables and which group they would provide the information on from both or either tables.

  1. Inner Join- If we want to find out people who are both married and home owners- Mia, Liz, Benjamin, Ava.
  2. Left Join- All married folks, whether or not home owners- John, James, Harper, Amy, Mia, Liz, Benjamin, Ava.
  3. Right Join– All home owners, whether or not married- Mia, Liz, Benjamin, Ava, Sophia, William, Jacob, Michael
  4. Full Join- Everyone from both tables- Mia, Liz, Benjamin, Ava, Sophia, William, Jacob, Michael, John, James, Harper, Amy.


Use keys from left frame only


Use keys from right frame only


Use union of keys from both frames


Use intersection of keys from both frames

What are the typical uses of service accounts in running SQL Server components?

Service accounts are all about security and access. So, for example, SQL Agent runs as a service and it can be configured (should be) to run under a service account. Let’s assume that you use Agent to run backups. Let’s also assume you backup to a shared file location on your network that’s not local to the machine you’re running SQL Agent on. You’ll need to ensure that the account configured for SQL Agent has access to that shared file location. While this may seem like work, what it in fact is doing is following the method of least access. That service account has to have access to that share, but it doesn’t need access to other file locations on your system, so you only give it what it needs and nothing more. Same thing applies to the other services and service accounts.

For More Information

How to Connect to SQL Server after Installation

This video explains on “How to Connect to SQL Server after Installation”

Applicable for SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 2014 and SQL Server 2016

T0 resolve possible connection issues at basic level, ensure the following:

1. Verify and ensure correct server name is provided

2. Go to Run then services.msc then ensure SQL Server service for the respective instance is started.

Any clarifications: Please email to

For Real-time Trainings and Projects, Placements on SQL Server, please visit

Or call us on +91 9666440801 (INDIA) or +1 510-400-4845 (USA/CANADA)

What is the difference between SQL Server and SQL?

SQL stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. It is used to perform operations on the data present in database. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system. However, the standard SQL commands such as “Select”, “Insert”, “Update”, “Delete”, “Create”, and “Drop” can be used to accomplish almost everything that one needs to do with a database. SQL commands are divided into several different types, among them data manipulation language (DML) and data definition language (DDL) statements, transaction controls and security measures.

Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc.

SQL Server is a relational database management system (RDBMS) developed by Microsoft. This product is built for the basic function of storing retrieving data as required by other applications. It can be run either on the same computer or on another across a network. It is platform dependent. It is both GUI and command based software.

SQL Server is available in various editions. Some of the editions are:

  • Enterprise
  • Standard
  • Workgroup
  • Web
  • Developer
  • Express
  • Compact
  • Datacenter
  • Business Intelligence
  • Enterprise Evaluation

So, different enterprises like web development companies, mobile app development companies, banks, outsourcing companies and many other uses RDBMS like (SQL server, Oracle) for smooth functioning of their business.