KnowledgeBoat Logo
|
LoginJOIN NOW

Informatics Practices

Mr. Malhotra is working on a MySQL table named Stud with the following table schema:

FieldTypeNullKeyDefaultExtra
regnointNOPRINULL
namevarchar(30)YESNULL
marksintYES0
dobdateNONULL

(i) Which command is used to get the given table schema as output?

(ii) Write the query to create table Stud.

(iii) Write a command to add a column address varchar(20) in table Stud.

(iv) Write a command to delete the column dob from the table Stud.

(v) Can Mr. Malhotra create more than one table in a database?

SQL Queries

1 Like

Answer

(i)

DESCRIBE Stud;

(ii)

CREATE TABLE Stud (
  regno int NOT NULL PRIMARY KEY,
  name varchar(30) DEFAULT NULL,
  marks int DEFAULT 0,
  dob date NOT NULL
);

(iii)

ALTER TABLE Stud 
ADD address varchar(20);

(iv)

ALTER TABLE Stud 
DROP COLUMN dob;

(v) Yes, Mr. Malhotra can create more than one table in a database. In fact, a database can have multiple tables, each with its own schema and data. There is no limit to the number of tables that can be created in a database.

Answered By

3 Likes


Related Questions