SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Create the database CREATE DATABASE IF NOT EXISTS user_registration; -- Use the database USE user_registration; -- Create the users table CREATE TABLE IF NOT EXISTS users ( id INT AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50) NOT NULL, email VARCHAR(100) NOT NULL, age INT NOT NULL, remarks TEXT NOT NULL, time DATETIME NOT NULL, INDEX idx_email_time (email, time) ); -- Add a unique constraint for email per month ALTER TABLE users ADD CONSTRAINT unique_email_per_month UNIQUE (email, EXTRACT(YEAR_MONTH FROM time));

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear