Skip to content
Worked Examples · Example 9

Q.Write an SQL statement to create a table named 'Student' with the fields RollNo (whole number, primary key), Name (text up to 50 characters), Class (text up to 10 characters) and Marks (whole number).

Maharashtra MsbshseTextbookSubjectiveImportance★★★★★est
85% · 11/13 Questions
✓ Free question

To create a new table we use the CREATE TABLE statement, listing each field followed by its data type. A whole number uses the type INT, and text of up to n characters uses VARCHAR(n). The field that uniquely identifies each record is marked with PRIMARY KEY.

Applying this to the requirement:

  • RollNo — whole number and primary key → RollNo INT PRIMARY KEY
  • Name — text up to 50 characters → Name VARCHAR(50)
  • Class — text up to 10 characters → Class VARCHAR(10)
  • Marks — whole number → Marks INT

The complete statement is:

CREATE TABLE Student (
    RollNo INT PRIMARY KEY,
    Name VARCHAR(50),
    Class VARCHAR(10),
    Marks INT
);

This creates an empty Student table with the four required fields, ready for records to be inserted. Note that SQL keywords are written in capitals by convention and the statement ends with a semicolon.

✓Final answer

CREATE TABLE Student (
    RollNo INT PRIMARY KEY,
    Name VARCHAR(50),
    Class VARCHAR(10),
    Marks INT
);

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.