You are on page 1of 21

Week-2

1. Create a database:
Lets create a database.
Create a database using CREATE statement.
Syntax: create database cricket;
Output:

2. Next, verify that the database was created by showing a list of all
databases. Use the SHOW statements.

Syntax:-show databases;
Output:

3. Select the database to make changes to it by using USE statement

Syntax:use database_name;

Output:
DDL COMMANDS:

1. CREATE COMMAND:

Syntax: create database databasename;

Create table tablename(col1 datatype1,col2 datatype2,…,column


datatypeN);

Output:

Syntax:-

2. INSERT DATA INTO TABLE:


OUTPUT:-
ALTER COMMAND:

Syntax:
ALTER TABLE TableName ADD ColumnNameData_Type;
ALTER TABLE TableName DROP ColumnName;
ALTER TABLE TableName MODIFY COLUMN ColumnName Data_Type;
3. DROP COMMAND:
Syntax: Drop table tablename;

4. TRUNCATE COMMAND
Syntax:Truncate table tablename;
Output:

DELETE STATEMENT

The DELETE statement is used to delete existing records in a table.

Syntax :

DELETE FROM table_name WHERE condition;

Note: The WHERE clause specifies which record(s) should be deleted. If you omit the WHERE
clause, all records in the table will be deleted!

Example : delete from student where name = march;


Output:-
1. AND: TRUE if both Boolean expressions are TRUE.

2. OR: TRUE if one of the Boolean expressions is TRUE.

3. NOT: Reverses the value of any other Boolean operator.


The Logical Operators are used to compare two conditions to check whether a row (or
rows) can be selected for the output.

Logical AND Operator


The Logical AND operator compares two conditions and returns TRUE if both of the
conditions are TRUE and returns FALSE when either is FALSE. If you want to select
rows that must satisfy all the given conditions, then in such cases you need to use the
AND operator.
Syntax to use AND Operator:
Note: Returns ‘True’ if both component conditions are true. Returns ‘False’ if any one
component condition or Both Component conditions are False.
Output:-
False Condition Example using AND Operator:
Logical NOT Operator :

Logical OR Operator:
The OR operator in Oracle is useful to add multiple conditions in a single SQL
statement. It displays the data rows if any one of the multiple conditions is TRUE. If
all the conditions are false the SQL statement won’t return any result set.

Let’s modify the SQL statement so that both conditions become FALSE.
Logical NOT Operator:
Output:-
Nested Logical Operators:
We can also use multiple logical operators in a single SQL statement. When we
combine the logical operators in a SELECT statement, the order in which the statement
is processed is
1. NOT
2. AND
3. OR
Nested Logical Operators Example:

Output:-

In this case, the rows that satisfy at least one of the above conditions are returned.

IN Operator:
Returns true if the value is available in the given list of values. Supports with all types
of data (data types).

Output:-
Between Operator Example:
If you want to fetch all the employees from the yar table where the employee age is
between 20 and 22, then we need to write the SELECT SQL Query using the Between
Operator.
Output:-

Like Operator Using %


The percent (%) means it will search for zero or more characters after the “%”. Here
‘%’ is the wildcard character that we will use before or after characters to search for
the required matched string of characters.
Example: Fetch all the yar whose names start with the letter r.

Output:-
Equal (=) Relational Operator
The Equal (=) Operator is used to check whether the two expressions are equal or not.
If both the expressions are equal then the condition becomes true and will return the
matched rows.

Not Equal (!=) Relational Operator


The Not Equal (!=) Operator is just the opposite of the equal operator. That means
this operator is used to check whether the two expressions are equal or not.

Not Equal (<>) Relational Operator


The Not Equal (<>) Operator is the same as the Not Equal (!=) operator. That means
it is also used to check whether the two expressions are equal or not.
Greater Than (>) Relational Operator
The Greater Than (>) Operator is used to check whether the left-hand expression
value is higher than the right-hand expression value.
This operator is used for the Greater than test.

Less Than (<) Relational Operator


The Less Than (>) Operator is used to check whether the left-hand expression value
is lower than the right-hand expression value. If the left-hand expression .
This operator is used for less than test.

Greater Than or Equal To (>=) Operator


The Greater than or Equal To (>=) Operator is used to check whether the left-hand
expression value is higher than or equals to the right-hand expression value or not.

Less Than or Equal To (<=) Operator


The Less than or Equal To (<=) Operator is used to check whether the left-hand
expression value is lower than or equal to the right-hand expression value or not.
This operator is used for Less than or Equal to test.

SELECT * FROM YAR ORDER BY Name DESC;


When you execute the above SELECT Query, you will get the following result set
which is sorted based on the Name column in Descending order

ORDER BY Clause along with WHERE Clause:


Let us see an example of how to use the ORDER BY Clause along with the WHERE
clause in Oracle.
SELECT * FROM YAR WHERE City = ‘London’ ORDER BY Name ASC;
Once you execute the above SELECT Query, you will get the following result set
which includes the employees of London city and the employees are sorted in
ascending order by name.

Order by Clause with Multiple Columns in Oracle:


Once you execute the above query, you will get the following output.
Sorting Data in Oracle by the Relative Position
We can also use the ORDER BY clause to sort the data by relative position .

SELECT Name, age, Gender, , salary,City FROM Employee ORDER BY 2 ASC;


Once you execute the above query, you will get the following output.

ABS() Function:
Syntax: ABS(number)

2) CEIL() Function:
Syntax: CEIL(NUMBER);
Output:-
3) FLOOR( ) Function:

Syntax: FLOOR(NUMBER)

Output:-

4) MOD() Function:

Syntax: MOD(m, n)

5) POWER() Function:
Syntax: POWER(m, n).
Output:-

6) ROUND() Function:-
Syntax: ROUND(NUMBER,[DECIMAL PLACES])

Output:-

COUNT() Function:
The COUNT function is used to count the data rows returned in the result set.
Syntax:
SELECT COUNT(*) FROM tablename;
Example:
The table which is created to perform aggregate functions is shown below.

Syntax:-

SUM Function:
The SUM Function is used to return the total sum of a given numeric column. The
SUM function will only work on numeric data types.
Syntax:

SELECT SUM(column) FROM TableName;SELECT SUM(Salary) As


TotalSalary FROM yar;

Output:-
MIN() Function in Oracle
The MIN function in Oracle is used to return the smallest value of the given column.
The MIN function works on numeric columns as well as string columns.
Syntax:
SELECT MIN(columnname) FROM tablename;

MAX() Function
The MAX function is used to return the largest value of the given column. The MAX
function works on numeric columns as well as string columns.
Syntax:
SELECT MAX(columnname) FROM tablename;

AVG Function

The AVG or AVERAGE function is used to return the average value of the given
numeric column. The AVG function will only work on numeric columns.

Syntax:
SELECT AVG(columnname) FROM tablename;
WEEK-3

Installation of cloudera
Aim: To install the cloudera and performing various hdfs file systems. Listing of files and
exploring dictionaries.
1. Download cloudera quickstart vm and extract the zip into a particular folder.And now
click as shown in below.

2. Configure the VM settings include the amount of ram cpu and etc.And after click on
import button.
3. After click on the import button; it will start to importing the files to oracle virtual
box.

4. Now click on cloudera-quickstart-vm-5.13.0.0-virtualbox and click on start.


Week-4

Exploring hdfs
Aim:- performing various hdfs file systems. Listing of files andexploring dictionaries.
1.After you can see your cloudera interface as shown in below image.
Listing files using ls and creating directory using mkdir command.

Copying files from local using copyfromlocal command

Copying files to local using copytolocal command

You might also like