• Examples
  • Sample Database
#1
CREATE TABLE contacts (
	contact_id integer PRIMARY KEY,
	first_name text NOT NULL,
	last_name text NOT NULL,
	email text NOT NULL UNIQUE,
	phone text NOT NULL UNIQUE
);
#2
CREATE TABLE groups (
	group_id integer PRIMARY KEY,
	name text NOT NULL
);
#3
CREATE TABLE contact_groups (
	contact_id integer,
	group_id integer,
	PRIMARY KEY (contact_id, group_id),
	FOREIGN KEY (contact_id) REFERENCES contacts (contact_id) 
			ON DELETE CASCADE ON UPDATE NO ACTION,
	FOREIGN KEY ([ group_id ]) REFERENCES groups (group_id) 
			ON DELETE CASCADE ON UPDATE NO ACTION
);
albums artists customers employees genres invoice_items invoices media_types playlist_track playlists tracks
  • SQL Query
Enter a query, then click the execute button or press F9 to run it.
  • Result
Loading