Blog_Banner_Asset
    Homebreadcumb forward arrow iconBlogbreadcumb forward arrow iconSoftware Development USbreadcumb forward arrow iconSQL Tutorial: List of SQL Commands With Examples

SQL Tutorial: List of SQL Commands With Examples

Last updated:
19th Nov, 2022
Views
Read Time
6 Mins
share image icon
In this article
Chevron in toc
View All
SQL Tutorial: List of SQL Commands With Examples

SQL is the short-form for Structured Query Language. Structured Query Language (SQL) is used to perform tasks on databases. A database is a collection of data that has been organized to make it simple to maintain and update. Datasets or files containing information, including transaction data, client information, financial data, and product details, are often aggregated and stored in computer databases.

Any type of data may be stored, maintained, and accessed using databases. They gather data on individuals, locations, or objects. It is collected in one location to be seen and examined. You might think of databases as a well-organized data collection.

We’ll dive deep into SQL basics in this SQL server tutorial.

What is SQL?

Database communication is made possible by the computer language known as SQL, or Structured Query Language. It may be used to create new tables for storing data or add information to existing ones. The data already available in the database may be retrieved using SQL queries. Additionally, SQL may be used to do simple-to-complex calculations on data.

Ads of upGrad blog

One of SQL’s primary benefits is its capacity to operate on massive datasets. The SQL functions as an enabler for you to deal with the information, terabytes of it if necessary, while the database offers a very high speed of computation and data processing.

SQL is used by most RDBMS(Relational Database Management Systems) out there. A few examples of RDBMS are:

  • MySQL
  • Oracle SQL
  • PostgreSQL
  • IBM
  • Microsoft SQL Server

Learn Software Development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs or Masters Programs to fast-track your career.

Getting comfortable with SQL commands

SQL is mainly used for CRUD operations on databases, i.e., Create, Read, Update and Delete. The most commonly used commands are mentioned below in this SQL tutorial –

SELECT

Example: SELECT * FROM EMPLOYEES

The command SELECT is used to extract or collect data from a database.

UPDATE

Example: UPDATE table_name

This command updates the database after setting new values for columns or rows.

DELETE

Example: DELETE FROM table_name

This command deletes the data from a database.

CREATE TABLE

Example: CREATE TABLE table_name( column1 datatype,    

     column2 datatype,

         column3 datatype,

        ….

    );

This command creates a new table in the database where the user is operating.

Popular Courses & Articles on Software Engineering

ALTER TABLE

Example: ALTER TABLE table_name

    ADD column_name datatype;

The command ALTER TABLE is used to modify a table in a database schema.

DROP TABLE

Example: DROP TABLE table_name

This command is used to delete a table from an existing database.

upGrad’s Exclusive Software Development Webinar for you –

SAAS Business – What is So Different?

What are Keys in SQL?

Individual records or rows of data in the table can be uniquely identified using keys. It helps establish and recognize links between table row rows.

The various types of keys are:

Primary Key: The primary key is used to identify each instance of an object distinctly. There is only one primary key per schema. This key can be a unique number or a unique string across the entire table.

Foreign Key: A database schema’s foreign keys are columns that refer to another table’s primary key. A foreign key can act as the primary key for another table.

Composite Key: A primary key is referred to as a composite key if it includes multiple attributes (more than one).

Candidate Key: Other than the primary key, all other attributes are considered candidate keys.

Super Key: A super key is a group of characteristics used to identify a tuple in a specific way.

Joins in SQL

To merge information from two or more tables based on a shared field, SQL allows us to make that happen with a simple command ‘JOIN’. The following list includes many join types:

  • INNER JOIN: As long as the condition is met, the INNER JOIN command selects all rows from the tables mentioned. This keyword will generate the result set by merging all the rows from the tables said that satisfy a particular requirement.
  • RIGHT JOIN: This join retrieves all records from the table on the right and matching rows from the table on the left.
  • LEFT JOIN: This join collects and displays all records from the table on the left and those that match the table on the right.
  • FULL OUTER JOIN: This join retrieves records when there is a match in the left or right table records.

Advantages of using SQL

While SQL has significant limitations, such as a simple interface and cost constraints, the benefits exceed the cons. SQL is incredibly accessible across all platforms, and its ease of use allows anybody to become adept.

One should consider the following advantages of moving to SQL:

  • SQL is an incredibly portable language: It is compatible with PCs, laptops, virtual machines, servers, and specific mobile devices. One can quickly run it on their local host ports. Any person on the same IP address can access it, provided they have the password to the database schema. Its mobility makes it an excellent alternative for consumers because they can easily share anything from one machine to another.
  • There is no requirement for coding knowledge. Coding can take a lot of experience and understanding before it can be used, making it difficult for others to understand. SQL, however, does not need coding expertise, only the usage of basic terms such as “CREATE”, “ALTER”, “FROM”, etc.
  • It offers a variety of data perspectives. When using SQL, you may construct different views of one database, offering users distinct perspectives on the structure and content of the database.
  • Its code is open source. MySQL, PostgreSQL, and most database management systems provide accessible SQL code that people may use for free. SQL is used by most major database management systems, including those from IBM, Oracle, and Microsoft. The accessibility of SQL is an important consideration.

Conclusion

SQL has long been popular in the IT industry for a while now. Every business or any computerized service has databases now. It is probably one of the most popular programming languages today, yet few realize that it helped to birth an industry, the RDBMS, which promotes efficient and structured data access.

Enhance your career with upGrad’s Executive PG Program in Software Development

Ads of upGrad blog

Software development is one of the most lucrative career options for young professionals. If you are already in the industry or looking to make a start, you must enroll in upGrad’s Executive PG Program in Software Development. The program teaches you in-demand skills and the ten highest paying coding languages and tools. You can choose from four specializations, including Blockchain Development, Full Stack Development, DevOps, and Cloud Backend Development. 

Along with learning top-paying programming languages, you can work on 30+ Case Studies and Projects. World-class faculty members take live lectures and online sessions for the course. Student support is available on a round-the-clock basis. 

Apply Now to get admission to the course at the earliest!

Profile

Pavan Vadapalli

Blog Author
Director of Engineering @ upGrad. Motivated to leverage technology to solve problems. Seasoned leader for startups and fast moving orgs. Working on solving problems of scale and long term technology strategy.
Get Free Consultation

Select Coursecaret down icon
Selectcaret down icon
By clicking 'Submit' you Agree to  
UpGrad's Terms & Conditions

Our Best Software Development Course

Frequently Asked Questions (FAQs)

1What is SQL?

Structured Query Language (SQL) is a programming language used to perform database tasks.

2What is DBMS?

A computerized data storage system is a database management system (or DBMS).

3How many hours of learning does this program offer?

upGrad’s Full Stack Developer course has more than 450 hours of learning.

Explore Free Courses

Suggested Blogs

Top 19 Java 8 Interview Questions (2023)
6085
Java 8: What Is It? Let’s conduct a quick refresher and define what Java 8 is before we go into the questions. To increase the efficiency with
Read More

by Pavan Vadapalli

27 Feb 2024

Top 10 DJango Project Ideas & Topics
12775
What is the Django Project? Django is a popular Python-based, free, and open-source web framework. It follows an MTV (model–template–views) pattern i
Read More

by Pavan Vadapalli

29 Nov 2023

Most Asked AWS Interview Questions & Answers [For Freshers & Experienced]
5676
The fast-moving world laced with technology has created a convenient environment for companies to provide better services to their clients. Cloud comp
Read More

by upGrad

07 Sep 2023

22 Must-Know Agile Methodology Interview Questions & Answers in US [2024]
5395
Agile methodology interview questions can sometimes be challenging to solve. Studying and preparing well is the most vital factor to ace an interview
Read More

by Pavan Vadapalli

13 Apr 2023

12 Interesting Computer Science Project Ideas & Topics For Beginners [US 2023]
10998
Computer science is an ever-evolving field with various topics and project ideas for computer science. It can be quite overwhelming, especially for be
Read More

by Pavan Vadapalli

23 Mar 2023

Begin your Crypto Currency Journey from the Scratch
5460
Cryptocurrency is the emerging form of virtual currency, which is undoubtedly also the talk of the hour, perceiving the massive amount of attention it
Read More

by Pavan Vadapalli

23 Mar 2023

Complete SQL Tutorial for Beginners in 2024
5560
SQL (Structured Query Language) has been around for decades and is a powerful language used to manage and manipulate data. If you’ve wanted to learn S
Read More

by Pavan Vadapalli

22 Mar 2023

Complete SQL Tutorial for Beginners in 2024
5042
SQL (Structured Query Language) has been around for decades and is a powerful language used to manage and manipulate data. If you’ve wanted to learn S
Read More

by Pavan Vadapalli

22 Mar 2023

Top 10 Cyber Security Books to Read to Improve Your Skills
5534
The field of cyber security is evolving at a rapid pace, giving birth to exceptional opportunities across the field. While this has its perks, on the
Read More

by Keerthi Shivakumar

21 Mar 2023

Schedule 1:1 free counsellingTalk to Career Expert
icon
footer sticky close icon