Oracle SQL Tutorial -2 Introduction To Oracle SQL

Hello ,

In this article, I will tell you about the expressions that form the basis of sql and how to give aliases to columns.

NULL EXPRESSION

  • Null values are unknown , unspecified .

  • When null is entered into an arithmetic operation , the result will be null .

SELECT EXPRESSION

With the SELECT statement , we select the columns to use in the table that we select , or if we use all the columns , we select all the columns in the table by using (*) . As an example of its use :

SELECT kolon_adi FROM tablo_adi or

SELECT * FROM tablo_adi used in the form .

Here I have selected all fields with SELECT * in my SH.CUSTOMERS table .

FROM EXPRESSION

The From statement specifies our table containing the specified columns .

SELECT * FROM SH.CUSTOMERS;

WHERE EXPRESSION

We use the where statement to restrict the fetch of data, and to bind them to a condition . For example , if we want to see 30-year-old workers in our worker table , we use where .

SELECT*FROM ADMIN.ISCI WHERE yas=30;

Let’s make another example .

SELECT * FROM SH.CUSTOMERS WHERE CUST_YEAR_OF_BIRTH > 1964;

In this query , we wanted to see those whose birth date is greater than 1964 , and the result of running this query below :

another example :

SELECT * FROM ADMIN.NEW_TABLE WHERE SALARY < 3000;

NAMING OF COLUMNS (ALIAS)

Nicknames given to columns do not cause any changes in our result set , we only use these names in our sql query . Alias are written just after the column name . The AS statement can be written between the column name and the alias we give to the column , but it is not mandatory . AS is used here as “as” . If you want to use as # , $ , , uppercase and lowercase letters and Turkish characters , Alias is written in double quotes .

SELECT CUST_FIRST_NAME "ADI" FROM SH.CUSTOMERS;

JOINING OPERATOR

  • Used to merge columns and strings.

  • Pipe = ‘| | ‘ .

  • The CONCAT command can be used for merge operations .

 

SELECT DISTINCT CUST_FIRST_NAME | | ' ' | | CUST_LAST_NAME AS "AD SOYAD" FROM SH.CUSTOMERS;

REPEATING LINES

  • We use the DISTINCT command to combine multiple but identical lines into a single row . In our example below , we ran this query because we don’t want to see duplicate values in the cust_first_name column .

SELECT DISTINCT CUST_FIRST_NAME FROM SH.CUSTOMERS;

VIEWING TABLE STRUCTURE

  • The DESCRIBE command is used to display the table structure . Usage :

DESC[RIBE] table_name ;

DESC SH.COSTS;

 

This is the structure of the sh.costs table you see above .

another example :

DESC ADMIN.NEW_TABLE;


See you in my next post.

About Melike Duran

Leave a Reply

Your email address will not be published. Required fields are marked *