SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE employees ( id_no INT AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), department VARCHAR(50) ); CREATE TABLE departments ( id_no INT AUTO_INCREMENT PRIMARY KEY, department_name VARCHAR(50), manager_name VARCHAR(50) ); CREATE TABLE projects ( id_no INT AUTO_INCREMENT PRIMARY KEY, project_name VARCHAR(50), start_date DATE, end_date DATE ); CREATE TABLE salaries ( id_no INT AUTO_INCREMENT PRIMARY KEY, employee_id INT, salary_amount DECIMAL(10, 2), FOREIGN KEY (employee_id) REFERENCES employees(id_no) ); -- Display structure of all tables SHOW TABLES; -- View schema for each table DESCRIBE employees; DESCRIBE departments; DESCRIBE projects; DESCRIBE salaries; -- Add email column to `employees` ALTER TABLE employees ADD COLUMN email VARCHAR(100); -- Optionally, add email to other tables as an example ALTER TABLE departments ADD COLUMN email VARCHAR(100); ALTER TABLE projects ADD COLUMN email VARCHAR(100); ALTER TABLE salaries ADD COLUMN email VARCHAR(100); -- Insert sample data into employees table for testing INSERT INTO employees (first_name, last_name, department) VALUES ('John', 'Doe', 'HR'); -- Update `id_no: 1` to 'Karen Nina' UPDATE employees SET first_name = 'Karen', last_name = 'Nina' WHERE id_no = 1; -- View updated record SELECT * FROM employees;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear