dnms prac 2 Flashcards

1
Q

query to update the values from existing column of table

A

update table_name set coloumn_name=value where condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

query to delete certain records ( rows ) from employee table

A

delete from table_name where condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

delete all rows from table_name

A

delete from table_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

query to permanently delete

A

drop table table_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to use aggregate function avg()

A

select avg(column_name) from table_name where condition ;

where condition optional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how to use concat()
function

A

select concat(col1, col2, ..) from table_name where condition

where condition is optional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is use of like and tell it’s syntax

A

used to substring in string

ex name%, %ter%, %man

synatx :

select col1,…,* from table_name like ‘%substring%’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

use of in and syntax

A

in is used to check if certain value belongs in certain set of values or result of some query

select col1, … , * from table_name where col in (query / set of values);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

tell 5 aggregate functions

A

max(col) , avg(col) , count (col) , concat (col1,col2,…, coln), max(col) , min(col) , ucase (col) , lcase(col), length(col)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

use and syntax of using between

A

used to specify values between certain values

syntax :

select col1, … , coln from table_name where col between ‘val1’ and ‘val2’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what are set operator in sql

A

union , union all , intersect , minus or except

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what does union do ? Syntax

A

combines result sets of two or more select statements into single result and removes duplicate rows

select column_name1 from table1
UNION
select column_name2 from table2
UNION
select column_name3 from table 3
.
.
.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

rules to use set operation

A
  1. Every select statement must have same number of columns
  2. Columns must also have similar datatypes
  3. The columns in select statement must also be in the same order.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what does union all do ?

A

to combine the result sets of two or more select statements into a single result set
including duplicate record;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what does except/minus operator do and syntax?

A

returns all records in query 1 which are not present in query 2

query1

minus / except

query2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

intersect operator does what and syntax?

A

return common records in two queries

17
Q

take care of what in where while deleting certain row

A

delete should uniquely identify tha t row