Tolal:50 Click:
1
2 3
SUB Interview Questions And Answers
Page 1
Ques: 1 How You create the Table ?
Ans:
For the create Table firstly we use 'CREATE TABLE' command with name and data-type of each table field. We can also specify PRIMARY KEY and any other constraint like NOT NULL. For example:
CREATE TABLE employer
(NAME VARCHAR(80) PRIMARY NOT NULL,DSGN VARCHAR(5),AGE INTEGER,PAY INTEGER);
Ques: 2 How can I Insert some data into the created table.
Ans:
When i would like to insert the data then we use to the 'INSERT INTO' command followed by table name and values to be inserted.
> If we need to insert a row with values for all columns, then use the following command :
INSERT INTO employer VALUES('Ram','MGR',25,25000);
> If we need to insert values for selected columns only, then we need to specify those column names also in the command as shown :
INSERT INTO employer (NAME) VALUES (\'Ramesh\');
Ques: 3 How can I Update the table?
Ans:
We have a two ways for upadating the table, Which is shown here :
> Use UPDATE command with SET and name-value pairs like:
UPDATE Employer SET pay=40000;
> For updating a particular row, Then We use WHERE clause in UPDATE command like :
UPDATE Employer SET pay = 25000 WHERE NAME= 'Ram';
Ques: 4 How can I see the whole Table ?
Ans:
When we would like to see our table then we Use SELECT command to retrieve the data.
SELECT * FROM employer;
Ques: 5 How can i short list to the table with resect to the column?
Ans:
When we would like to get the sorted listed of the data with respect to any coulmns , Then we can use ORDER BY clause :
For the example We can shortlist of the table with respect to columns Name as shown :
SELECT * FROM employer ORDER BY name;
Ques: 6 How can I retrieve few columns of all rows?
Ans:
To retrieve few columns of all rows:
SELECT name FROM employer;
Ques: 7 How can I retrieve all columns of a particular row ?
Ans:
To retrieve all columns of a particular row:
SELECT * FROM employer where name = 'Ramesh';
Ques: 8 How can I retrieve selected columns of a particular row?
Ans:
To retrieve selected columns of a particular row:
SELECT pay FROM employer WHERE name = 'Ram';
Ques: 9 How can I retrieve a row with columns having a particular pattern?
Ans:
To retrieve a row with columns having a particular pattern. For the Example pay of all those employees whose name starts with A :
SELECT pay FROM Employer WHERE name like 'A%';
Ques: 10 How can I count number of records in the table?
Ans:
To count number of records in the table .
For example we want to know How many employers are in the table :
SELECT COUNT(*) FROM employer;
Ques: 11 How can I get the sum of a column?
Ans:
To get the sum of a column .
For example we want to know total pay to be paid :
SELECT SUM(PAY) FROM employer;
Ques: 12 How can I Use AND/OR in WHERE clause to retrieve data based on multiple condition?
Ans:
Use AND/OR in WHERE clause to retrieve data based on multiple condition :
Ex. SELECT * FROM employer WHERE name LIKE 'A%' AND pay > 10000;
Ques: 13 How can I got group the results?
Ans:
To group the results, use GROUP BY as in following:
Ex.
SELECT * FROM employer GROUP BY dsgn;
Ques: 14 How can I Having Clouse?
Ans:
HAVING cause is using for the show groups satisfying a criteria,
Ex. SELECT * FROM employer GROUP BY dsgn HAVING pay > 10000;
Ques: 15 How Can I use IN Clause?
Ans:
IN clause uses when we would like to get results if a field has any of the given value :
Ex. SELECT * FROM employer where name IN ('Ramesh','Ram');
Ques: 16 How can I Add a column to the table?
Ans:
When we add a columns in the table we can done through ALTER command like :
Ex. ALTER TABLE employer ADD exp INTEGER;
Ques: 17 How can I set an alias for person table using few columns only?
Ans:
For this query we can use AS command as defined below:
Ex.
SELECT NAME,DSGN FROM Employer AS employees;
Ques: 18 How can I delete a particular record in the Table ?
Ans:
For delete a particular record, use DELETE command with WHERE clause like:
Ex.
DELETE * FROM employer WHERE name='Ram';
Ques: 19 How can I delete all records of the table ?
Ans:
For delete all records, We can use :
Ex.
DELETE FROM Employer;
Ques: 20 How can I delete all records for using TRUNCATE command?
Ans:
We can also delete all records using TRUNCATE command such as :
Ex.
TRUNCATE TABLE employer;
Goto Page:
1
2 3
SUB Objective
SUB Objective Questions And Answers
SUB Interview Questions And Answers
SUB Interview Questions And Answers
SUB Interview Questions And Answers
SUB Subjective Questions And Answers
R4R,SUB Objective, SUB Subjective, SUB Interview Questions And Answers,SUB,SUB Interview,SUB Questions ,SUB Answers