INT — SQL Technical Interview Questions & Answers

INT

INT

  • INT is a whole number. TINYINT, SMALLINT, MEDIUMINT, BIGINT differ by range. INT UNSIGNED cannot be negative (good for ids). AUTO_INCREMENT is usually INT or BIGINT.
  • Marks 0–100: INT or TINYINT. Don’t INT(11) as ‘max 11 digits’ — the display width is a leftover, not a limit (deprecated).
  • Trap: INT for phone. Trap: INT(1) as boolean — use TINYINT(1) by habit, still 0/1.
  • On the example next to this theory: INT: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Technical Interview Tip: roll INT PRIMARY KEY, marks INT

Code Examples for INT

INT — sample query

-- INT
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

INT: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

How to Explain INT to an Interviewer

Phone as INT?

No — VARCHAR Leading zeros and +91