Skip to content
Activities · Activity 9.6
Q.

Write SQL statements to insert the remaining 3 rows of table 9.6 in table GUARDIAN.

GUIDGNameGPhoneGAddress
444444444444Amit Ahuja5711492685G-35, Ashok Vihar, Delhi
111111111111Baichung Bhutia3612967082Flat no. 5, Darjeeling Appt., Shimla
101010101010Himanshu Shah472630921226/77, West Patel Nagar, Ahmedabad
333333333333Danny Dsouza(no phone)S-13, Ashok Village, Daman
466444444666Sujata P.3801923168HNO-13, B-block, Preet Vihar, Madurai

Table 9.6: GUARDIAN — the first record (Amit Ahuja) and the record without GPhone (Danny Dsouza) are already inserted in the chapter text; insert the remaining 3.

West Bengal WbchseTextbookSubjective· 3mImportance★★★★★est
13% · 12/95 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Amit Ahuja's row and Danny Dsouza's (phone-less) row are inserted in the chapter text, so the three rows still to be added are Baichung Bhutia, Himanshu Shah and Sujata P. Each needs one INSERT INTO GUARDIAN (GUID, GName, GPhone, GAddress) VALUES (…); statement, with the string columns in single quotes and the 12-digit GUID as a numeric literal.

Which rows are still missing?

Table 9.6 has five guardians. The chapter already inserts two of them.

GUIDGNameGPhoneGAddressAlready inserted?
444444444444Amit Ahuja5711492685G-35, Ashok Vihar, DelhiYes — in the chapter
111111111111Baichung Bhutia3612967082Flat no. 5, Darjeeling Appt., ShimlaNo
101010101010Himanshu Shah472630921226/77, West Patel Nagar, AhmedabadNo
333333333333Danny Dsouza(no phone)S-13, Ashok Village, DamanYes — in the chapter (the NULL-phone example)
466444444666Sujata P.3801923168HNO-13, B-block, Preet Vihar, MaduraiNo

So exactly three INSERT statements are required.

Note

The GUID column holds Aadhaar-style 12-digit identifiers. All three values needed here are printed in full in Table 9.6 and are used below — including Sujata P.'s, 466444444666.

The table

CREATE TABLE GUARDIAN (
    GUID     BIGINT PRIMARY KEY,     -- 12 digits: too large for INT
    GName    VARCHAR(30),
    GPhone   CHAR(10),
    GAddress VARCHAR(60)
);
Important

A phone number is stored as CHAR(10), not as a number. Phone numbers are never used in arithmetic, and a numeric type would silently strip a leading zero.

The three INSERT statements

INSERT INTO GUARDIAN (GUID, GName, GPhone, GAddress)
VALUES (111111111111, 'Baichung Bhutia', '3612967082',
        'Flat no. 5, Darjeeling Appt., Shimla');

INSERT INTO GUARDIAN (GUID, GName, GPhone, GAddress)
VALUES (101010101010, 'Himanshu Shah', '4726309212',
        '26/77, West Patel Nagar, Ahmedabad');

INSERT INTO GUARDIAN (GUID, GName, GPhone, GAddress)
VALUES (466444444666, 'Sujata P.', '3801923168',
        'HNO-13, B-block, Preet Vihar, Madurai');

MySQL replies to each statement with:

Query OK, 1 row affected (0.01 sec)

MySQL also allows all three rows in one statement, which is faster because the table is opened once:

INSERT INTO GUARDIAN (GUID, GName, GPhone, GAddress) VALUES
 (111111111111, 'Baichung Bhutia', '3612967082', 'Flat no. 5, Darjeeling Appt., Shimla'),
 (101010101010, 'Himanshu Shah',   '4726309212', '26/77, West Patel Nagar, Ahmedabad'),
 (466444444666, 'Sujata P.',       '3801923168', 'HNO-13, B-block, Preet Vihar, Madurai');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

Explaining the key parts

ElementWhy
INSERT INTO GUARDIAN (col, col, …)naming the columns makes the statement independent of the physical column order — the safe form
'Baichung Bhutia'strings and dates go in single quotes
111111111111GUID is numeric — no quotes (if the column were CHAR(12), it would need quotes)
Address with a comma inside the quotescommas inside a quoted string are ordinary characters, not value separators

Verifying the result

SELECT * FROM GUARDIAN;

Output

GUIDGNameGPhoneGAddress
444444444444Amit Ahuja5711492685G-35, Ashok Vihar, Delhi
333333333333Danny DsouzaNULLS-13, Ashok Village, Daman

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.