Creating Data in SQL
Here in this SQL cheat sheet we have listed down all the cheat sheet that help to create, insert, alter data in table.
5. CREATE: Create a New Table, Database, or Index
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
department VARCHAR(50),
salary DECIMAL(10, 2)
);
This command creates a table named “employees” with columns for employee ID, first name, last name, department, and salary. The employee_id column is set as the primary key.
6. INSERT INTO: Add New Records To A Table
INSERT INTO employees (employee_id, first_name, last_name, department, salary)
VALUES
(1, 'John', 'Doe', 'HR', 50000.00),
(2, 'Jane', 'Smith', 'IT', 60000.00),
(3, 'Alice', 'Johnson', 'Finance', 55000.00),
(4, 'Bob', 'Williams', 'IT', 62000.00),
(5, 'Emily', 'Brown', 'HR', 48000.00);
This command inserts sample data into the “employees” table with values for employee ID, first name, last name, department, and salary.
7. ALTER TABLE: Modify An Existing Table’s Structure
ALTER TABLE employees
ADD COLUMN new_column INT;
This command adds a new column named “new_column” of integer type to the existing “employees” table.
8. DROP TABLE: Delete A Table And Its Data
DROP TABLE employees;
This command deletes the entire “employees” table along with all its data.
SQL Cheat Sheet
In this article, we will explore the ultimate SQL cheat sheet with the PDF, covering a wide range of SQL commands, Joins in SQL, CRUD Operations, SQL Trigger, SQL Transactions, and advanced topics to help master SQL effectively.
SQL (Structured Query Language) is a Query language used for managing and manipulating relational databases databases. It allows users to interact with databases. SQL allows users to perform various tasks such as querying data, updating data, inserting new records, deleting records, creating and modifying database schemas, and managing permissions.
Table of Content
- Create a Database in SQL
- Creating Data in SQL
- Reading/Querying Data in SQL
- Updating/Manipulating Data in SQL
- Deleting Data in SQL
- Filtering Data in SQL
- SQL Operator
- Aggregation Data in SQL
- Constraints in SQL
- Joins in SQL
- SQL Functions
- Subqueries in SQL
- Views in SQL
- Indexes in SQL
- Transactions in SQL
- Advanced Mixed Data in SQL
- SQL Cheat Sheet PDF
Contact Us