Presentation is loading. Please wait.

Presentation is loading. Please wait.

BY SATHISH SQL Basic. Introduction The language Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model.

Similar presentations


Presentation on theme: "BY SATHISH SQL Basic. Introduction The language Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model."— Presentation transcript:

1 BY SATHISH SQL Basic

2 Introduction The language Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model. SEQUEL later became SQL (still pronounced "sequel"). In1979, Relational Software, Inc. (now Oracle) introduced the first commercially available implementation of SQL. Today, SQL is accepted as the standard RDBMS language. SQL allows users to access data in relational database management systems, such as Oracle, Sybase, Informix, Microsoft SQL Server, Access, and etc

3 Creating New Tables All tables within a database must be created at some point in time...let's see how we would create the Employee : CREATE TABLE Employee (Employee_id number(6),name varchar(20)NotNull); The NOT NULL means that the column must have a value in each row. If NULL was used, that column may be left empty in a given row.

4 Adding Data To insert rows into a table, do the following: INSERT INTO Employee VALUES (21, ‘umesh’) or INSERT INTO Employee VALUES(“&Employee_id”,”&name”); SQL>>enter employee_id:40 name:Raje 1 row inserted successfully

5 Deleting Data Let's delete this new row back out of the database: DELETE FROM Employee WHERE name = ‘Umesh'; But if there is another row that contains ‘Umesh', that row will be deleted also. Let's delete all rows (one, in this case) that contain the specific data we added before: DELETE FROM Employee WHERE Name = ‘Umesh' AND Employee_id =21;

6 SELECT STATEMENT The general form for a SELECT statement, retrieving all of the rows,columns in the table syntax: SELECT columnname,columnname2,.. FROM TableName; SELECT (*) from TableName; SELECT * FROM annual_summaries WHERE sd_duration_code = ‘1’ ;

7 ORDER BY STATEMENT It defines How the Records are to be Sorted Defines Sorted Must be in the SELECT statement to be ORDER BY Default is to order in ASC (Ascending) order. You Can Sort in Reverse (Descending) Order with ““DESC””After the Column Name. EXAMPLE SELECT * FROM student ORDER BY name;

8 Using LIKE SELECT employee_id FROM employee WHERE lastname LIKE ‘s%’; In the above Query is exequte the percent sign (%) is used to represent any possible character (number, letter, or punctuation) or set of characters that might appear after the "S". To find those people with LastName's ending in "S“. SELECT employee_id FROM employee WHERE lastname LIKE ‘%s’;

9 Using keys A primary key is a column or set of columns that uniquely identifies the rest of the data in any given row. For example, in the Owners table, the OwnerID column uniquely identifies that row. This means no two rows can have the same OwnerID. A foreign key is a column in a table where that column is a primary key of another table, which means that any data in a foreign key column must have corresponding data in the other table where that column is the primary key.

10 Aggregate Functions The five important aggregate functions: SUM, AVG, MAX, MIN, and COUNT. They are called aggregate functions because they summarize the results of a query, rather than listing all of the rows. SUM () gives the total of all the rows. AVG () gives the average of the given column. MAX () gives the largest figure in the given column. MIN () gives the smallest figure in the given column. COUNT(*) gives the number of rows satisfying the conditions.

11 Example SELECT SUM(SALARY), AVG(SALARY)FROM EMPLOYEE; (This query shows the total of all salaries in the table, and the average salary of all of the entries in the table.) SELECT MIN(BENEFITS)FROM EMPLOYEE WHERE POSITION = 'Manager'; (This query gives the smallest figure of the Benefits column, of the employees who are Managers) SELECT COUNT(*) FROM EMPLOYEE WHERE POSITION = 'Staff'; (This query tells you how many employees have Staff)

12 THANK YOU


Download ppt "BY SATHISH SQL Basic. Introduction The language Structured English Query Language (SEQUEL) was developed by IBM Corporation, Inc., to use Codd's model."

Similar presentations


Ads by Google