0% found this document useful (0 votes)
2 views3 pages

Essential SQL Commands and Functions Guide

The document provides an overview of databases, specifically focusing on relational databases and the differences between DBMS and RDBMS. It outlines key SQL commands for creating, modifying, and managing data, along with filtering, sorting, and using various SQL functions. Additionally, it includes terminology and important command differences, along with exam tips for mastering SQL queries.

Uploaded by

ksharma84288
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Essential SQL Commands and Functions Guide

The document provides an overview of databases, specifically focusing on relational databases and the differences between DBMS and RDBMS. It outlines key SQL commands for creating, modifying, and managing data, along with filtering, sorting, and using various SQL functions. Additionally, it includes terminology and important command differences, along with exam tips for mastering SQL queries.

Uploaded by

ksharma84288
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Introduction

Database: Organized collection of data in tables (rows = records or tuples, columns = fields or
attributes).

Relational Database: Stores data in tables called relations.

DBMS vs. RDBMS: DBMS stores data; RDBMS organizes data into related tables.

Key SQL Commands

CREATE: Create database or table.

Example: CREATE TABLE student (rollno INT, name CHAR(30));

INSERT: Add records to a table.

Example: INSERT INTO student VALUES (101, 'Rohit', 9876543210);

SELECT: Retrieve data.

Example: SELECT * FROM student; or SELECT name, contact FROM student;

UPDATE: Modify existing data.

Example: UPDATE student SET contact=999999999 WHERE rollno=101;

DELETE: Remove records.

Example: DELETE FROM student WHERE rollno=101;

DROP: Delete an entire table.

Example: DROP TABLE student;

ALTER: Modify table structure.

Example: ALTER TABLE student MODIFY address VARCHAR(60);

DESCRIBE: Show table structure.


Example: DESC student;

Filtering & Sorting

WHERE: Filter rows based on condition.

ORDER BY: Sort results ascending or descending.

GROUP BY: Group rows to apply aggregate functions.

SQL Functions

Single-row (Scalar) Functions: Operate on individual values, return one result.

Aggregate Functions: Operate on multiple rows, summarize data.

Important Numeric Functions

POWER(x, y): Calculates x raised to power y.

Example: POWER(2, 3) returns 8.

ROUND(x, n): Rounds number x to n decimal places.

Example: ROUND(95.9) returns 96.

TRUNCATE(x): Returns integer part of x.

Example: TRUNCATE(98.9) returns 98.

String Functions

Change case: UCASE(), LCASE().

Concatenate strings: CONCAT().

Get string length: LENGTH().


Date/Time Functions

Extract year, month, day: YEAR(), MONTH(), DAY().

Terminology

Table = Relation

Row = Tuple or Record

Column = Field or Attribute

Important Command Differences

ALTER: Change table structure.

UPDATE: Change data in rows.

DELETE: Remove specific rows.

DROP: Delete entire table.

Exam Tips

End queries with semicolon (;).

Master SELECT command.

Know ALTER vs UPDATE difference.

Practice writing and running common queries.

You might also like