Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual training week 4 structured query language (SQL)

Similar presentations


Presentation on theme: "Virtual training week 4 structured query language (SQL)"— Presentation transcript:

1 Virtual training week 4 structured query language (SQL)

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19 Categories of SQL Statements 1.Data manipulation language (DML) 1.Data manipulation language (DML) statements begin with INSERT, UPDATE, DELETE, or MERGE and are used to modify the table by entering new rows, changing existing rows, or removing existing rows. 2.Data definition language (DDL) statements set up, change, and remove data structures from the database. The keywords CREATE, ALTER, DROP, RENAME, and TRUNCATE begin DDL statements. 3.Transaction control (TCL) statements are used to manage the changes made by DML statements. Changes to the data are executed using COMMIT, ROLLBACK, and SAVEPOINT. TCL changes can be grouped together into logical transactions. 4.Data control language (DCL) keywords GRANT and REVOKE are used to give or remove access rights to the database and the structures within it.

20

21 a SELECT statement must include the following: SELECTA SELECT clause, which specifies the columns to be displayed FROM A FROM clause, which specifies the table containing the columns listed in the SELECT clause Select ………...[column name] From …….……..[table name]

22 A SELECT statement can do the following: ProjectionProjection: Used to choose columns in a table SelectionSelection: Used to choose rows in a table JoinJoin: Used to bring together data that is stored in different tables by creating a link between them (you will learn about this later!)

23

24

25

26

27

28 Aliases "friendly" name Column aliases let you rename columns in the output Why column Alias - Renames a column heading - Is useful with calculations - Immediately follows the column name - May have the optional AS keyword between the column name and alias - Requires double quotation marks if the alias contains spaces or special characters or is case-sensitive

29

30 Concatenation (||) Concatenation means to connect or link together in a series Select columnname || columnname From tablename Select first_name || last_name From empolyees You cane use column alias to rename the connected columns.

31

32 DESCRIBE display the structure of a table. Why describe? DESCRIBE returns the table name, table schema, tablespace name, indexes, triggers, constraints, and comments as well as the data types, primary and foreign keys, and which columns can be nullable. DESC[RIBE] tablename; as DESCRIBE departments;

33

34 DISTINCT Used to eliminate duplicate rows. DISTINCT DISTINCT automatically displays the output in alphabetical order.

35 Limiting rows selected Used to limit the number of rows retrieved from the quarry note note : An alias cannot be used in the WHERE clause! A WHERE clause contains a condition that must be met, and it directly follows the FROM clause in a SQL statement. Where clause

36

37 SELECT*|{[DISTINCT] column|expression [alias],...} FROM table [WHEREcondition(s)]; Select * From employees Where salary = 1500 Note/ conditions in where clause is case sensitive

38

39 comparison operators used with where clause = equal to > greater than >= greater than or equal to < less than <= less than or equal to <> not equal to can be (!= or ^ =(

40

41

42

43

44 The default sort order is ascending. - Numeric values are displayed lowest to highest. - Date values are displayed with the earliest value first. - Character values are displayed in alphabetical order. - Null values are displayed last in ascending order and first in descending order.

45 aliasIt is also possible to order data by using a column alias. The alias used in the SELECT statement is added to the ORDER BY clause. SELECT title, year AS "Recording Date" FROM d_cds ORDER BY "Recording Date"

46 What does this order by mean? Select first_name, last_name, salary, job_id From employees Where job_id = 10 Order by 3

47 GOOD LUCK SEE YOU NEXT MEETING Raafat Rashad


Download ppt "Virtual training week 4 structured query language (SQL)"

Similar presentations


Ads by Google