Professional Documents
Culture Documents
Ans-->
Q2.Expalin Information?
1. Define : Specifying the data type, and constraint for the data to be
stored.
Ans-->
3.A database is designed, built and populated with data for a specific
purpose
Q8. Applications of Databases?
Ans-
1. Banking
4. e-commerce
5. Education Organization
--------------------------------------------------------------------------------------------
RDBMS:
Mysql
oracle
Ms Access
SQLite
SQL SERVER
Sysbase
DB2
2. un structured data:
Example: MongoDB
-----------------------------------------------------------------------------------------------
RDBMS(SQL)
Oracle
Mysql
DB2
Sysbase
Sql Server
SqLite
MS Access
-------------------------------------------------------------------------------------------
Q1. Explain SQL?
1. MySql
2.Oracle
3. Sql Server
4. Sqlite
5. DB2
Ans-->
-----------------------------------------------------------------------------------------------
Example:
1. create
2. Alter
3. drop
4. truncate
5.rename
The Sql Commands that deals with the manipulation of data present in
the database belong to DML or data manipulation.
1. insert
2. update
3. delete
4. select
1. grant
2. revoke
2. rollback
3. save point
Q1. Explain How to create Database in mysql?
Syntax:
Syntax:
Syntax:
)
emp
in Mysql
__________
empno int,
name varchar(30),
sal float,
deptno int
use lnctdemo;
Q5. How to display structure of the table?
Ans-->
Syntax:
desc tablename;
desc emp;
describe tablename
describe emp;
emp
Syntax:
-------------------------------------------------------------------------------------------
Q6. How to change data type of existing column
Syntax:
emp
Ans->
Syntax:
employee
customer
Ans--> you can create one table from another table by adding select
statement at the end of create table statement
Syntax:
create table table_name as select * from original_table_name;
--------------------------------------------------------------------------------------------
Syntax:
-----------------------------------------------------------------------------------------------
Create--->create something
---------------------------------------------------------------------
Q4. Explain insert command?
Syntax:
Syntax:
emp
Syntax:
Syntax:
Ans-->if we want to delete data from the table then we should go for
delete(DML)
Syntax:
Ans--> if we want to retrieve data from the table then we should go for
select command
Syntax:
Syntax:
Query:
Query:
select * from emp where deptno not in (10)
Query:
Query:
Query:
Syntax:
Query:
-----------------------------------------------------------------------------------------------
Q2. Select All employee data from the emp table whose deptno is 10 or
salary > 15000.
Ans-->
Query:
-----------------------------------------------------------------------------------------------
1. sum()
2. max()
3. min(()
4. avg()
5. count()
Syntax:
sum(column name);
sum(sal)/count(sal);
Syntax:
avg(column name);
Ans--> The Sql max function is used to return the maximum value of an
expression in a select statement.
Syntax:
Q2. write a query to find max salary of employee whose deptno is 10.
Q3. write a query to find max salary of employee whose empno less
than 108.
Ans--> The min function returns the smallest value of the selected
column.
Syntax:
Q3. write a query to find min salary of employee whose deptno not 10.
Syntax:
Example :
----------------------------------------------------------------------------
Ans--> The dual is a special one row, one column table present by
default in all oracle databases.
output: 123.57
output: 123.6
output: 120
output: 130
select round(125.5678,-1) from DUAL
output: 130
Output: 127
--------------------------------------------------------------------------------------------
Q1. Explain floor function in sql?
Ans-->The floor function returns the largest integer value that is smaller
than or equal to a number.
SELECT floor(25.7)
Syntax:
trucate(number,decimal);
select truncate(345.159789,2)
----------------------------------------------------------------------------------------------
Syntax:
pow(number,power);
select pow(2,3)
output: 8
select pow(3.333,1.5555)
Q1. Explain in operator in sql?
Syntax:
T yp1
Syntax:
Ans-> The SQL between operator select values within a given range.
The values can be number, text or dates
Syntax:
select column list from table name where column name between value
1 and value 2
select * from emp where sal not between 1000 and 25000
Syntax:
Q1. write a query to sort all employee data on the basis of salary in
ascending order.
Ans
Q1. write a query to sort all employee data on the basis of salary in
descending order.
Ans
Q3. write a sql query to sort data of employee on the basis of employee
name in ascending order.
Ans-->The group by clause groups row that have the same values into
summary rows like "find the number of customers in each country"
Syntax:
select column_list
where condition
ANs-->The having clause was added to sql because the where keyword
cannot be used with aggregate function
Syntax:
from tablename
where condition
group by column
having condition
Ans-->
select column list from table name where like 'char pattern';
Q1. write a Query to display the employee whose name start with Caps
letter A from emp table;
Q3. write a query to display all employee whose name second letter is
caps A.
Q4. write a query to display all employee whose name third letter is
caps A.
Q4. write a query to display the employee who are join in the year of
81.
Q5. write a query to display the employee whose name ends with N.
Q5. write a query to display the employee whose name ends second
last char with E.
SELECT *
ON (a.deptno = b.deptno);
---------------------------------------------------------------------------------------
Q1.Explain SQL Constraint?
constraint can be specified when the table is created with the create
table command or, after table is created with the alter command
constraint are used to limit the type of data that can go into a table.
Primary key must contain unique values, and cannot contain null
values.
A table can have only on primary key, and in the table, this primary key
can consist single or multiple columns (composite primary key)