Got it 👍 You want the exact SQL commands that you can type and run in your SQL editor (like Oracle SQL, MySQL, or PostgreSQL). I’ll give you both DDL and DML commands properly written.
---
🔹 Data Definition Language (DDL)
1. Create a table
CREATE TABLE employees (
emp_id NUMBER PRIMARY KEY,
name VARCHAR2(50),
salary NUMBER(10, 2),
hire_date DATE
);
2. Alter table
👉 Add a new column:
ALTER TABLE employees ADD (department_id NUMBER);
👉 Modify column datatype:
ALTER TABLE employees MODIFY (name VARCHAR2(100));
3. Drop table
DROP TABLE employees;
4. Truncate table
TRUNCATE TABLE employees;
5. Rename table
RENAME employees TO staff;
---
🔹 Data Manipulation Language (DML)
1. Insert data
INSERT INTO employees (emp_id, name, salary, hire_date)
VALUES (101, 'Alice Johnson', 55000, TO_DATE('2022-01-15', 'YYYY-MM-DD'));
2. Select data
SELECT name, salary
FROM employees
WHERE salary > 50000;
3. Update data
UPDATE employees
SET salary = salary * 1.10
WHERE emp_id = 101;
4. Delete data
DELETE FROM employees
WHERE emp_id = 101;
---
⚡ Notes:
If you’re using MySQL, replace VARCHAR2 with VARCHAR, and remove TO_DATE (use '2022-01-15' directly).
If you’re using Oracle, the above works as written.
---
Do you want me to give you a ready-to-run sequence (create
→ insert → select → update → delete) so you can copy-paste and test directly?
Comments
Post a Comment