0% found this document useful (0 votes)
2 views1 page

SQL Queries

The document outlines various SQL operations including creating, inserting, selecting, updating, deleting, and modifying tables and their data. It provides specific SQL queries for each operation along with brief descriptions of their functions. Key operations include creating tables, filtering data, and managing table structures.

Uploaded by

surbhisharmaa749
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 views1 page

SQL Queries

The document outlines various SQL operations including creating, inserting, selecting, updating, deleting, and modifying tables and their data. It provides specific SQL queries for each operation along with brief descriptions of their functions. Key operations include creating tables, filtering data, and managing table structures.

Uploaded by

surbhisharmaa749
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
You are on page 1/ 1

Operation SQL Query Description

Create Table CREATE TABLE table_name (id INT, Creates a new table
name VARCHAR(100));
Insert Data INSERT INTO table_name (id, name) Inserts a new row into the
VALUES (1, 'Alice');
table
Select All Rows SELECT * FROM table_name; Retrieves all rows and
columns
Select Specific SELECT name FROM table_name; Retrieves specific column(s)
Columns
Select with SELECT * FROM table_name WHERE id Filters rows based on a
= 1;
Condition condition
Update Data UPDATE table_name SET name = 'Bob' Updates existing data
WHERE id = 1;
Delete Row DELETE FROM table_name WHERE id = Deletes a row based on
1;
condition
Drop Table DROP TABLE table_name; Deletes the entire table
Truncate Table TRUNCATE TABLE table_name; Removes all rows but keeps
the table structure
Rename Table ALTER TABLE old_name RENAME TO Renames a table
new_name;
Add Column ALTER TABLE table_name ADD age Adds a new column to the
INT;
table
Modify Column ALTER TABLE table_name MODIFY age Modifies column data type
VARCHAR(3); (MySQL)
Drop Column ALTER TABLE table_name DROP COLUMN Removes a column from the
age;
table
Create Index CREATE INDEX idx_name ON Speeds up lookups using the
table_name(name);
name column
Order Results SELECT * FROM table_name ORDER BY Sorts the results
name ASC;
Count Rows SELECT COUNT(*) FROM table_name; Counts the number of rows
Group By SELECT age, COUNT(*) FROM Groups rows by column
table_name GROUP BY age;
Join Tables SELECT * FROM t1 JOIN t2 ON t1.id Joins rows from two tables
= t2.t1_id;

You might also like