SQL-Commands DML Flashcards

1
Q

DML - Data Manipulation Language

A

statements are managing data within schema

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

Select

A

Retrieve data from the dB

Select commands from 1 table:
SELECT (select & from are the only 2 required keywords)
* : all
column_name
distinct column_name : specified & non-duplicated columns
FROM table_name
count(*): total number of rows

WHERE (optional ,but must be in the specific order) - conditions
=,>,=,<>(not equal)
And (both condition)
OR(one or another, or both)
IN(specify multiple values)
BETWEEN(select a range of data between two values)
LIKE (search for a specified pattern in a column:% or_(one character )
Remove some or all (no WHERE clause) rows from a table

Some:
Delete from table 1
Where column_name = ‘student’

All:
Delete from table 1

Delete a table

DROP TABLE table_name

IS NULL/NOT NULL

GROUP BY - column-list
HAVING - conditions for number (aggregate’s WHERE)
SUM, MAX, MIN, AVG

ORDER BY column_list ASC or DESC (ASC is the default)

Select commands for more than one table:
Select all tables:
Select*
from all_tables

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

Insert - how do you add record to the table

A

Insert data into a table
INSERT into table_name
Values (1,2,3,’a’)

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

Update - how do you change value of the field?

A

Update existing data within a table

UPDATE table_name
SET field1=200
        field 2='ABC'
        field 3=to_date(2006-03-04 09:29, 'yyyy-mm-dd')
WHERE field = 'CD'(Condtion)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Delete

A

deletes all (no where) or specific (+where) records from a table

Specific:
Delete from table 1
Where column_name = ‘student’

All:
Delete from table 1

  • Delete a table

DROP TABLE table_name

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

Select - count

How do you find the number of rows in a table?

A
Select count (*) 
From table_name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Select - ROWNUM

Give each result a number

A

Select FirstName, LastName, Salary, ROWNUM

From Table_name

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