SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Create employee table CREATE TABLE employee ( id INT PRIMARY KEY, name VARCHAR(50), age INT, CONSTRAINT chk_age CHECK (age >= 18) ); -- Add a column and constraint ALTER TABLE employee ADD salary DECIMAL(10,2), ADD CONSTRAINT chk_salary CHECK (salary >= 0); -- Drop a column and constraint ALTER TABLE employee DROP COLUMN age, DROP CONSTRAINT chk_age; -- Modify a column ALTER TABLE employee ALTER COLUMN name VARCHAR(100); -- Rename a column and table ALTER TABLE employee RENAME COLUMN name TO full_name; ALTER TABLE employee RENAME TO employee_info; -- Insert 2 records INSERT INTO employee_info (id, full_name, salary) VALUES (1, 'John Doe', 50000), (2, 'Jane Smith', 60000); -- Truncate table TRUNCATE TABLE employee_info; -- Drop table DROP TABLE employee_info;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear