SQL_introdoc
SQL_introdoc
1. Create a table using SQL which should have a table name, list of columns and
respective names, data type of each column and a set of constraints, also retrieve the
data from the table created.
Sol:
Problem Statement:
To create a table using SQL with specified information such as table name, column names,
data types, and constraints, and retrieve the data from the created table.
Description:
→ Open the mysql site and create a new worksheet
→ Create a table with a name and define the entities to be used in the table
→ Define the data type that is to be used, for each entity in the table.
→ Start inserting data into table in the order of the entities defined while creating the
table. Add around 10 sets of data into table.
→ Retrieve the entire data from the table.
→ Retrieve partial amounts of data, by setting some constraints on the statements.
Concepts used:
Syntaxes used for
→ Creating table:
create table table_Name( column1Name datatype, col2Name
datatype……colnName datatype);
Code:
create table student(rollNum number,fName varchar(10),lName varchar(10),branch
varchar(4));
insert into student(rollNum,fName,lName,branch) values (101,'sam','mmm','CSE');
insert into student(rollNum,fName,lName,branch) values (102,'shyam','kumar','CSE');
insert into student(rollNum,fName,lName,branch) values (103,'rinku','singh','CSE');
insert into student(rollNum,fName,lName,branch) values (104,'tulasi','ram','CSE');
insert into student(rollNum,fName,lName,branch) values (105,'vadala','laxmi','ECE');
insert into student(rollNum,fName,lName,branch) values (106,'vislavath','ganesh','ECE');
insert into student(rollNum,fName,lName,branch) values (107,'jay','sundar','ECE');
insert into student(rollNum,fName,lName,branch) values (108,'Mudigonda','deva','MECH');
insert into student(rollNum,fName,lName,branch) values (109,'keshav','komma','MECH');
insert into student(rollNum,fName,lName,branch) values (110,'gupta','omkar','MECH');
select * from student;
select rollNum from student;
select fname from student where rollNum=107;
select * from student where branch='ECE';
Output: