TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Oracle

Introduction to SQL(Structured Query Language)

Introduction

SQL(Structured Query Language) pronounced either as “sequel” or S.Q.L is a query language used to access, interact and manipulate relational databases. A good understanding of SQL will help us to access and manipulate data in different databases like Oracle, MySQL, MS SQL Server, MS Access, IBM DB2, etc.

SQL has rules of grammar and syntax like normal English and can be easily understood. SQL is an ANSI standard. (American National Standards Institute) .

Features of SQL

SQL is a standard language to access and manipulate relational databases. It is not merely a query language. It can also be used to create, update and delete database objects.

SQL usage is extremely flexible and uses a free-form syntax. ( The same SQL query can be written in a variety of ways)

The SQL statements can be embedded in other high-level programming languages. like C, Java, etc.

SQL Statements

Most of the actions that we need to perform on a database are done with SQL statements. Some database systems require a semicolon(;) at the end of each SQL statement. The semicolon (;) is the standard way to separate each SQL statement.

The SELECT statement is used to select data from a database. For example, the following SQL SELECT statement will select all the records in the emp database table:

SELECT * FROM emp;

SQL is not case-sensitive. For example, both the SQL queries are the same.

SELECT * FROM emp;

select * from emp;

Example SQL Query

We can specify the exact columns that we want in the SQL statement. Let’s write a simple query to retrieve empno, name, salary, and job details for the employees from the emp table.

The table structure of the emp table is shown below:

SQL> DESC emp;
 Name Null? Type
 ----------------------------------------- -------- ----------------------------
 EMPNO NOT NULL NUMBER(4)
 ENAME VARCHAR2(10)
 JOB VARCHAR2(9)
 MGR NUMBER(4)
 HIREDATE DATE
 SAL NUMBER(7,2)
 COMM NUMBER(7,2)
 DEPTNO NUMBER(2)

Table Structure

SQL> SELECT empno,ename,job,sal FROM emp;

Query result:

SQL> SELECT empno,ename,job,sal FROM emp;

 EMPNO ENAME JOB SAL
---------- ---------- --------- ----------
 7369 SMITH CLERK 800
 7499 ALLEN SALESMAN 1600
 7521 WARD SALESMAN 1250
 7566 JONES MANAGER 2975
 7654 MARTIN SALESMAN 1250
 7698 BLAKE MANAGER 2850
 7782 CLARK MANAGER 2450
 7788 SCOTT ANALYST 3000
 7839 KING PRESIDENT 5000
 7844 TURNER SALESMAN 1500
 7876 ADAMS CLERK 1100

SELECT TABLE

 

SQL Commands

SQL commands can be divided into different types.

https://www.testingdocs.com/types-of-sql-commands/

—

Database Tutorials on this website:

https://www.testingdocs.com/oracle-database-tutorials-for-beginners/

More information about Oracle Database:

https://www.oracle.com/database/

 

Related Posts

Download SQL Developer

Oracle /

Download Oracle SQL Developer

Oracle Databse 19c Download

Oracle /

Install Oracle 19c Database On Windows 10

ORA-01109 Database Not Open

Oracle /

Fix ORA-01109: database not open Error

Oracle SQL Update Statement

Oracle /

Oracle SQL Update Statement

Oracle SQL Insert Statement

Oracle /

Oracle SQL INSERT Statement

‹ Setting Up Sample Schema in Oracle› Introduction to Oracle SQL*Plus

Recent Posts

  • Scaler Academy – An Online Learning Platform
  • Difference between PHP and JavaScript?
  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com