Docsity

MySQL - Enum and Set, Study notes of Computer Engineering and Programming

Partial preview of the text

Download MySQL - Enum and Set and more Study notes Computer Engineering and Programming in PDF only on Docsity!

ENUM

  • Accepts only certain / declared values inside the ENUM parenthesis.
  • Below example will accept only values that are Low, Medium, and High.
  • SQL will map the values inside Enum to 1,2,3...therefore arrangement is important.

MySQL

ENUM and SET

SET

  • Selects value inside the SET parenthesis.
  • Data inserted are bitmapped.

SAMPLE CODES FOR SETS

CREATE A TABLE TICKETS

CREATE TABLE Tickets ( ID INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(255) NOT NULL, Action_Owner SET('John','Peter','Lloyd') NOT NULL ); INSERT VALUES ONTO THE TABLE INSERT INTO Tickets VALUES(null,'Bug','John'); INSERT INTO Tickets VALUES(null,'Tableau Error','Peter'); INSERT INTO Tickets VALUES(null,'Excel Error','Lloyd'); INSERT INTO Tickets VALUES(null,'No Internet',1); INSERT INTO Tickets VALUES(null,'Inaccessible Site',2); INSERT INTO Tickets VALUES(null,'Automatic Shutdown',3); INSERT INTO Tickets VALUES(null,'No Internet',4); INSERT INTO Tickets VALUES(null,'Inaccessible Site',5); INSERT INTO Tickets VALUES(null,'Automatic Shutdown',6); INSERT INTO Tickets VALUES(null,'Automatic Shutdown',7); SELECT * FROM Tickets;