PL/SQL provides three collection types: associative arrays, nested tables, and variable-size arrays. Associative arrays use keys to access unbounded elements, nested tables are like one-dimensional arrays with an arbitrary number of elements, and variable-size arrays store a fixed number of elements in sequential order. Both associative arrays and nested tables can have object types as elements, but only nested tables can be stored in database columns.
The document discusses various SQL concepts like database and tables, RDBMS terminology, SQL commands categories, data types, creating and manipulating tables. It explains concepts like primary key, foreign key, aggregate functions like MAX(), MIN(), AVG(), SUM(). Examples are provided for queries using SELECT, WHERE, ORDER BY, UPDATE and DELETE statements. Logical and relational operators used for filtering data in WHERE clause are also explained.
This document provides an overview of Chapter 3 from the textbook "Database System Concepts, 7th Ed." by Silberschatz, Korth and Sudarshan. It covers the history and components of SQL, data definition and manipulation languages, basic query structure, predicates, null values, and set operations in SQL. Key topics include the CREATE TABLE statement, data types, integrity constraints, SELECT statements, joins, ordering results, and aggregate functions.
1. The document describes experiments related to SQL DDL, DML commands and SELECT statements.
2. It discusses commands like CREATE TABLE, ALTER TABLE, DROP TABLE, INSERT, SELECT, UPDATE, DELETE and provides syntax and examples for each.
3. Queries are provided at the end of each experiment to create tables, insert data, modify structure, retrieve and manipulate data using the studied commands.
This document provides an overview of database concepts including creating, altering, and dropping databases and tables. It discusses data definition language (DDL) commands like CREATE, ALTER, DROP as well as data manipulation language (DML) commands like INSERT, SELECT, UPDATE, DELETE. It also covers database constraints, joins, functions for aggregation, strings, numbers, dates and more. The document is an introduction to core SQL concepts for a course on data management and database design.
The document summarizes topics that will be covered in an advanced SQL training seminar, including SQL statement types, data types, aggregate functions, NULL handling, comparison operators, mathematical functions, joins, subqueries, views, materialized views, inline views, and optimizing SQL queries. Techniques for data sharing between databases are also mentioned. The seminar aims to provide in-depth knowledge of SQL concepts through explanations, examples, exercises and discussion.
This document discusses various data definition language (DDL) statements in SQL. It describes DDL statements to create, modify, and delete database objects like schemas, tables, views, and indexes. Specifically, it covers the CREATE, ALTER, and DROP statements for schemas, tables, views, indexes, and constraints. Examples are provided for each statement type.
The document discusses SQL DML statements like SELECT, INSERT, UPDATE, and DELETE. It provides examples of using each statement to manipulate data in tables. It also covers additional SQL clauses and functions like WHERE, ORDER BY, GROUP BY, JOIN, and aggregate functions that can be used with the SELECT statement to filter, sort, group, and perform calculations on the result set.
Hello people this is first time in the history when somebody has take a pain to create such a large ppt it is almost my 5 months laborious work..
although i know ppt cannot b more than 30 slides but at the same time i dont want my readers to to feel the lack of knowledge
THIS PPT BELONGS TO TECHNICALS PERSONS hope u like it thanking you ........
SQL is a standard language for accessing and manipulating databases. It allows users to perform functions like querying data, inserting records, updating records, and deleting records. The main SQL statements are SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, and DROP. SQL also includes clauses like WHERE, ORDER BY, GROUP BY and JOIN that allow users to filter and sort query results. Common data definition language statements are used to create and modify database structures like tables, indexes, and relationships.
SQL (Structured Query Language) is a standard language for accessing and manipulating databases. It allows users to execute queries against a database, retrieve data from a database, insert records into a database, update records in a database, and delete records from a database. Common SQL statements include SELECT to retrieve data, INSERT to add data, UPDATE to modify data, DELETE to remove data, and CREATE/ALTER to manage tables and databases.
The document provides information on various SQL commands used to create and manage databases and tables. It explains how to use SHOW, CREATE DATABASE, USE, SHOW TABLES, CREATE TABLE, DESCRIBE, ALTER TABLE, SELECT, UPDATE, DELETE, INSERT, CREATE VIEW commands. It also discusses table constraints like NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY and provides examples of how to implement them in CREATE TABLE and ALTER TABLE statements.
The document discusses various SQL statements and functions used for managing databases and querying data. It provides the syntax for SQL statements like CREATE TABLE, INSERT, SELECT, UPDATE, DELETE and functions like COUNT, AVG, MIN, MAX, SUM to operate on data in database tables. It also covers statements for altering tables, joining tables, filtering rows with WHERE and HAVING clauses, removing duplicates with DISTINCT, and ordering results.
The document describes various data definition language (DDL) and data manipulation language (DML) commands in MySQL. Some key commands include using CREATE to add new databases, tables, indexes, and constraints. ALTER is used to modify existing database objects. DROP removes databases, tables, columns or indexes. DML commands like SELECT are used to query data, WHERE filters rows, JOIN combines tables, and INSERT, UPDATE, DELETE modify data. COUNT, SUM, DISTINCT and other functions can be used to aggregate or transform result sets.
This document defines SQL data definition statements and basic SQL query structure. It discusses DDL statements like CREATE, ALTER, and DROP that are used to define and manage database structures. It also explains the typical components of an SQL query including the SELECT, FROM, and WHERE clauses. Finally, it outlines several set operations in SQL like UNION, UNION ALL, INTERSECT, and MINUS.
This document provides an introduction to SQL (Structured Query Language). SQL is a language used to define, query, modify, and control relational databases. The document outlines the main SQL commands for data definition (CREATE, ALTER, DROP), data manipulation (INSERT, UPDATE, DELETE), and data control (GRANT, REVOKE). It also discusses SQL data types, integrity constraints, and how to use SELECT statements to query databases using projections, selections, comparisons, logical conditions, and ordering. The FROM clause is introduced as specifying the relations involved in a query.
SQL is a standard language for storing, manipulating and retrieving data in databases. It allows users to access and manipulate data in databases. Some key functions of SQL include executing queries against a database, retrieving data from a database, inserting, updating and deleting records in a database, and creating, altering and dropping database objects like tables.
The document introduces common data types in SQL such as char, varchar, int, numeric, and date. It describes how to create databases and tables using SQL statements like CREATE DATABASE, CREATE TABLE, INSERT INTO, and ALTER TABLE. It also covers SQL queries using SELECT, FROM, WHERE, ORDER BY, LIKE and other clauses to retrieve and filter data from one or more tables.
Null values, insert, delete and update in databaseHemant Suthar
Ìý
This document discusses database concepts like null values, insertion, deletion, and updating of records in a database. It defines null as the absence of a value in a field, and explains that null values cannot be compared or included in counts. It describes how to insert new records using INSERT statements with column names and values. Deletion of records uses the DELETE statement with an optional WHERE clause to select specific rows. Updates are done with the UPDATE statement, setting new column values and an optional WHERE to select rows.
This document provides an introduction and overview of SQL (Structured Query Language). It discusses basic SQL statements for selecting, restricting, and sorting data. It also covers single-row functions for manipulating numbers, dates, characters, and returning conversion functions. Logical conditions, the ORDER BY clause, and nesting functions are explained. Finally, it demonstrates examples of SQL statements using various clauses, conditions, and functions.
The document discusses various SQL commands used for data manipulation:
1. The INSERT command is used to add rows to a table by specifying column values.
2. The SELECT command is used to retrieve data from one or more tables.
3. The UPDATE command modifies existing records in a table by changing column values.
4. The DELETE command removes rows from a table.
The document discusses how to use Oracle's Data Definition Language (DDL) to define database objects like tables, views, indexes, and sequences. It provides the syntax for creating these objects using commands like CREATE, ALTER, and DROP. Examples are given for creating a table with various constraints, altering a table, creating views with subqueries, and using sequences to generate primary keys. The key DDL commands, data types, naming conventions, constraints, and how to populate and modify tables are summarized.
This document summarizes the main DML (Data Manipulation Language) commands used for editing data in SQL: INSERT for adding new rows, UPDATE for changing existing rows, and DELETE for removing rows. It provides the syntax and examples for each command, including using default values, assigning null values, and specifying conditions with WHERE clauses.
The SELECT statement is used to retrieve data from one or more tables. It allows you to select specific columns, rows, and expressions. The general syntax includes keywords like SELECT, FROM, WHERE, and clauses for filtering, sorting, grouping, and joining results. Examples demonstrate how to select all data, particular rows and columns, use aliases, DISTINCT, comparison operators, patterns, ranges, and handle NULL values.
The document discusses how to get involved with and contribute to the Open Object community. It covers joining teams to learn, improve documentation, translate materials, develop modules, use version control, track bugs, and promote work. The community uses forums, IRC, mailing lists, blogs, and more to collaborate on the OpenERP/OpenObject project.
The document discusses SQL DML statements like SELECT, INSERT, UPDATE, and DELETE. It provides examples of using each statement to manipulate data in tables. It also covers additional SQL clauses and functions like WHERE, ORDER BY, GROUP BY, JOIN, and aggregate functions that can be used with the SELECT statement to filter, sort, group, and perform calculations on the result set.
Hello people this is first time in the history when somebody has take a pain to create such a large ppt it is almost my 5 months laborious work..
although i know ppt cannot b more than 30 slides but at the same time i dont want my readers to to feel the lack of knowledge
THIS PPT BELONGS TO TECHNICALS PERSONS hope u like it thanking you ........
SQL is a standard language for accessing and manipulating databases. It allows users to perform functions like querying data, inserting records, updating records, and deleting records. The main SQL statements are SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, and DROP. SQL also includes clauses like WHERE, ORDER BY, GROUP BY and JOIN that allow users to filter and sort query results. Common data definition language statements are used to create and modify database structures like tables, indexes, and relationships.
SQL (Structured Query Language) is a standard language for accessing and manipulating databases. It allows users to execute queries against a database, retrieve data from a database, insert records into a database, update records in a database, and delete records from a database. Common SQL statements include SELECT to retrieve data, INSERT to add data, UPDATE to modify data, DELETE to remove data, and CREATE/ALTER to manage tables and databases.
The document provides information on various SQL commands used to create and manage databases and tables. It explains how to use SHOW, CREATE DATABASE, USE, SHOW TABLES, CREATE TABLE, DESCRIBE, ALTER TABLE, SELECT, UPDATE, DELETE, INSERT, CREATE VIEW commands. It also discusses table constraints like NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY and provides examples of how to implement them in CREATE TABLE and ALTER TABLE statements.
The document discusses various SQL statements and functions used for managing databases and querying data. It provides the syntax for SQL statements like CREATE TABLE, INSERT, SELECT, UPDATE, DELETE and functions like COUNT, AVG, MIN, MAX, SUM to operate on data in database tables. It also covers statements for altering tables, joining tables, filtering rows with WHERE and HAVING clauses, removing duplicates with DISTINCT, and ordering results.
The document describes various data definition language (DDL) and data manipulation language (DML) commands in MySQL. Some key commands include using CREATE to add new databases, tables, indexes, and constraints. ALTER is used to modify existing database objects. DROP removes databases, tables, columns or indexes. DML commands like SELECT are used to query data, WHERE filters rows, JOIN combines tables, and INSERT, UPDATE, DELETE modify data. COUNT, SUM, DISTINCT and other functions can be used to aggregate or transform result sets.
This document defines SQL data definition statements and basic SQL query structure. It discusses DDL statements like CREATE, ALTER, and DROP that are used to define and manage database structures. It also explains the typical components of an SQL query including the SELECT, FROM, and WHERE clauses. Finally, it outlines several set operations in SQL like UNION, UNION ALL, INTERSECT, and MINUS.
This document provides an introduction to SQL (Structured Query Language). SQL is a language used to define, query, modify, and control relational databases. The document outlines the main SQL commands for data definition (CREATE, ALTER, DROP), data manipulation (INSERT, UPDATE, DELETE), and data control (GRANT, REVOKE). It also discusses SQL data types, integrity constraints, and how to use SELECT statements to query databases using projections, selections, comparisons, logical conditions, and ordering. The FROM clause is introduced as specifying the relations involved in a query.
SQL is a standard language for storing, manipulating and retrieving data in databases. It allows users to access and manipulate data in databases. Some key functions of SQL include executing queries against a database, retrieving data from a database, inserting, updating and deleting records in a database, and creating, altering and dropping database objects like tables.
The document introduces common data types in SQL such as char, varchar, int, numeric, and date. It describes how to create databases and tables using SQL statements like CREATE DATABASE, CREATE TABLE, INSERT INTO, and ALTER TABLE. It also covers SQL queries using SELECT, FROM, WHERE, ORDER BY, LIKE and other clauses to retrieve and filter data from one or more tables.
Null values, insert, delete and update in databaseHemant Suthar
Ìý
This document discusses database concepts like null values, insertion, deletion, and updating of records in a database. It defines null as the absence of a value in a field, and explains that null values cannot be compared or included in counts. It describes how to insert new records using INSERT statements with column names and values. Deletion of records uses the DELETE statement with an optional WHERE clause to select specific rows. Updates are done with the UPDATE statement, setting new column values and an optional WHERE to select rows.
This document provides an introduction and overview of SQL (Structured Query Language). It discusses basic SQL statements for selecting, restricting, and sorting data. It also covers single-row functions for manipulating numbers, dates, characters, and returning conversion functions. Logical conditions, the ORDER BY clause, and nesting functions are explained. Finally, it demonstrates examples of SQL statements using various clauses, conditions, and functions.
The document discusses various SQL commands used for data manipulation:
1. The INSERT command is used to add rows to a table by specifying column values.
2. The SELECT command is used to retrieve data from one or more tables.
3. The UPDATE command modifies existing records in a table by changing column values.
4. The DELETE command removes rows from a table.
The document discusses how to use Oracle's Data Definition Language (DDL) to define database objects like tables, views, indexes, and sequences. It provides the syntax for creating these objects using commands like CREATE, ALTER, and DROP. Examples are given for creating a table with various constraints, altering a table, creating views with subqueries, and using sequences to generate primary keys. The key DDL commands, data types, naming conventions, constraints, and how to populate and modify tables are summarized.
This document summarizes the main DML (Data Manipulation Language) commands used for editing data in SQL: INSERT for adding new rows, UPDATE for changing existing rows, and DELETE for removing rows. It provides the syntax and examples for each command, including using default values, assigning null values, and specifying conditions with WHERE clauses.
The SELECT statement is used to retrieve data from one or more tables. It allows you to select specific columns, rows, and expressions. The general syntax includes keywords like SELECT, FROM, WHERE, and clauses for filtering, sorting, grouping, and joining results. Examples demonstrate how to select all data, particular rows and columns, use aliases, DISTINCT, comparison operators, patterns, ranges, and handle NULL values.
The document discusses how to get involved with and contribute to the Open Object community. It covers joining teams to learn, improve documentation, translate materials, develop modules, use version control, track bugs, and promote work. The community uses forums, IRC, mailing lists, blogs, and more to collaborate on the OpenERP/OpenObject project.
Describe the Open Object Rapid Application Development framework in Python. Open Object if the framework used by the well know open source enterprise management application: Open ERP.
Richard founded a manufacturing company in 1985 that grew to 90 employees by 2006. However, the company's overhead costs increased significantly, reducing margins. Richard implemented Open ERP, an open-source ERP software, to integrate business processes across departments. This reduced costs, increased visibility and control, and allowed the company to grow efficiently while improving employees' workflows.
This document provides an introduction to Ichimoku Kinko Hyo, a technical analysis indicator. It describes the core components of Ichimoku, including the Tenkan (trigger) line and Kijun (base) line, which are moving averages used to generate buy and sell signals with crossovers. The document also introduces "the Cloud" (Kumo), which denotes the trend and acts as support/resistance. It encourages manually backtesting the trigger/base line crossover signals on historical charts to become familiar with how Ichimoku works in practice.
Open ERP is a free and open source ERP software that integrates accounting, finance, sales, purchases, and other business processes and modules. It allows users to automate tasks, avoid duplicate data entry, and access business intelligence features without needing separate software packages. The software can be installed and tested for free online or on a local server with no licensing costs.
12-HOW TO PROCESS A RECURRING INVOICE IN ORACLE R12 PAYABLES - ORAHUTORAHUT
Ìý
This document provides instructions for processing a recurring invoice in Oracle R12 Payables. It discusses how to set up a recurring invoice that can be automatically generated at regular intervals, such as monthly, to pay vendors for ongoing services or subscriptions. The document outlines the steps to define a recurring invoice template and generate invoice copies on a scheduled basis so accounts payable clerks do not have to manually recreate the same invoice each time period.
well,
This presentation gives very breif insight into SAP basics for noobs or dummies as i may call them (like me)
nevertheless i presume this is not an elegant presentation ....
PL/SQL provides a data structure called a VARRAY that can store a fixed-size sequential collection of elements of the same type. A VARRAY is used to store an ordered collection of data like an array. All VARRAYs consist of contiguous memory locations with indexes associated with each element. A VARRAY type is created using the CREATE TYPE statement by specifying the maximum size and element type. VARRAYs can be initialized, accessed, and iterated over in PL/SQL code using examples provided.
SQL commands can be classified into DDL, DML, and DCL. DDL commands allow users to define and modify database schema by creating/deleting tables and imposing constraints. DML commands allow users to manipulate data by inserting, updating, deleting, and extracting data from tables. Common DDL commands include CREATE TABLE and ALTER TABLE. Common DML commands include SELECT, INSERT, UPDATE, and DELETE. SQL also supports pattern matching using wildcards like % and _ in the LIKE operator.
SQL on Linux and its uses and application.pdfbhaveshsethi456
Ìý
SQL (Structured Query Language) in Linux is a powerful tool for managing and manipulating relational databases. SQL allows users to query, update, insert, and delete data from databases, as well as manage database structures, such as tables, views, indexes, and more. SQL is supported on various database systems, including MySQL, PostgreSQL, MariaDB, and SQLite, which can be easily installed and run on Linux systems.
### SQL and Linux Integration
On Linux, SQL databases are often used in server environments to manage data for web applications, enterprise systems, and data analysis tasks. Many popular database management systems (DBMS) such as MySQL, MariaDB, and PostgreSQL come pre-packaged in Linux distributions or can be installed via package managers like `apt` (for Debian-based distributions) or `yum` (for Red Hat-based distributions).
#### Installation
To install MySQL or PostgreSQL on Linux, users can run:
- For MySQL: `sudo apt-get install mysql-server` (Debian-based) or `sudo yum install mysql-server` (Red Hat-based)
- For PostgreSQL: `sudo apt-get install postgresql postgresql-contrib`
After installation, database services can be started using system commands like `sudo systemctl start mysql` or `sudo systemctl start postgresql`.
### Working with SQL on Linux
Once installed, users can interact with the databases via terminal using SQL commands. For example:
- To log in to MySQL: `mysql -u root -p`
- To log in to PostgreSQL: `psql -U postgres`
SQL commands can be used to:
- **Create a database:** `CREATE DATABASE dbname;`
- **Create a table:** `CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), age INT);`
- **Insert data:** `INSERT INTO users (id, name, age) VALUES (1, 'John', 25);`
- **Query data:** `SELECT * FROM users;`
### Administration and Security
Linux provides strong security features for SQL databases. Permissions can be granted to specific users with commands like `GRANT` and `REVOKE`. Databases can be protected by controlling access to users and encrypting sensitive data. Linux-based tools like `cron` can be used for scheduled backups, while firewall settings help secure databases from unauthorized access.
### Conclusion
SQL on Linux is integral to managing data efficiently in modern computing environments. With its stability, security, and powerful command-line tools, Linux provides an excellent platform for running SQL databases for a wide range of applications.
In addition to managing databases directly via the command line, Linux users can also take advantage of graphical user interfaces (GUIs) like **phpMyAdmin**, **pgAdmin**, or **DBeaver**, which make interacting with SQL databases more intuitive by providing visual tools for creating tables, running queries, and managing data. These tools can be easily installed on Linux systems and are often used in tandem with command-line operations.
Linux also supports integration with various programming languages, such as Python, PHP, and Java, allowing developers t
The document provides an overview of SQL (Structured Query Language) including its basic concepts, components, and capabilities. SQL is a non-procedural language used to query and manipulate data in relational database management systems. It allows users to select, insert, update, and delete data. The main components of SQL are the data definition language for defining database structure and the data manipulation language for retrieving and updating data.
This document provides an overview of SQL and MySQL. It discusses that MySQL is an open source relational database management system that uses SQL. SQL allows users to create, access, and manage relational databases. The document then covers relational data models and terminology used in relational databases like tables, rows, columns, primary keys, and foreign keys. It also discusses SQL commands for data definition, manipulation, and control. Finally, it provides examples of SQL queries to retrieve, insert, update and structure data from tables in a MySQL database.
Here are the SQL commands for the questions:
Q1: SELECT PNAME FROM PROJECT WHERE PLOCATION='Houston';
Q2: SELECT FNAME, LNAME FROM EMPLOYEE WHERE HOURS>20;
Q3: SELECT FNAME, LNAME FROM EMPLOYEE, DEPARTMENT WHERE MGRSSN=SSN;
This document provides guidelines for developing databases and writing SQL code. It includes recommendations for naming conventions, variables, select statements, cursors, wildcard characters, joins, batches, stored procedures, views, data types, indexes and more. The guidelines suggest using more efficient techniques like derived tables, ANSI joins, avoiding cursors and wildcards at the beginning of strings. It also recommends measuring performance and optimizing for queries over updates.
Oracle - Program with PL/SQL - Lession 05Thuan Nguyen
Ìý
This document discusses composite data types in PL/SQL including records, INDEX BY tables, and tables of records. It provides examples of how to create each type, use the %ROWTYPE attribute to define records based on database tables, and demonstrates various methods for accessing and manipulating data in INDEX BY tables including COUNT, EXISTS, DELETE and TRIM. The key concepts covered are how to define and work with composite data structures in PL/SQL to efficiently retrieve and process sets of related data.
The document provides an overview of key database concepts including:
- A database is a collection of logically related information stored and managed using database management system software.
- Relational databases organize data into tables with rows and columns and use keys to link related data across tables. Structured Query Language (SQL) is used to perform operations like data queries and manipulation.
- Database management involves tasks like defining the database structure with data definition language statements, manipulating data with data manipulation language statements, and running queries with the SELECT statement to retrieve and work with data in the database.
The document discusses Data Definition Language (DDL) commands in Oracle such as CREATE, ALTER, and DROP used to define and manipulate database objects. It provides examples of using these commands to create tables with various constraints, alter table structures, create views, sequences, and indexes. The CREATE command is used to define tables, views, indexes and sequences. ALTER modifies existing objects and DROP removes them permanently. Constraints enforce data rules. Views display data from other objects. Sequences generate numbers. Indexes improve data retrieval performance.
The document provides information about MySQL including:
1. MySQL is an open source relational database management system based on SQL that is used to add, remove, and modify information in databases.
2. It describes basic MySQL commands like CREATE TABLE, DROP TABLE, SELECT, INSERT, UPDATE, and provides syntax examples.
3. It also covers advanced commands, functions in MySQL like aggregate functions, numeric functions and string functions as well as stored procedures.
This document provides information about SQL and database management systems. It discusses:
- SQL is a standard language for querying, manipulating, and defining data in databases. It was developed by IBM in the 1970s.
- SQL can be used to perform functions like retrieving data from a database, inserting new records, updating existing records, and deleting records.
- The main components of SQL are DDL, DML, DCL, and DQL which allow creating, modifying and deleting database structures, manipulating data, controlling access to data, and querying data respectively.
- Common SQL statements are discussed including SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE TABLE, and DROP TABLE. Data types and
The document discusses MySQL and SQL concepts including relational databases, database management systems, and the SQL language. It introduces common SQL statements like SELECT, INSERT, UPDATE, and DELETE and how they are used to query and manipulate data. It also covers topics like database design with tables, keys, and relationships between tables.
Sql server ___________session 3(sql 2008)Ehtisham Ali
Ìý
This document discusses several new features in SQL Server 2008 related to data manipulation language (DML) and XML data types, including table value constructors, table-valued parameters, the MERGE statement, enhanced GROUP BY functionality using ROLLUP, CUBE, and GROUPING SETS, and improved XML data type handling. It provides examples and explanations of the syntax and usage for each feature.
This document discusses different types of composite data types in PL/SQL including collections, records, associative arrays, nested tables, and variable-size arrays. Collections include associative arrays and nested tables. Associative arrays use unique keys to access elements while nested tables use numeric subscripts. Variable-size arrays have a maximum size but can hold a varying number of elements accessed using subscripts. Records allow accessing components by name and can have different data types within.
This document provides an overview of SQL (Structured Query Language) and how it can be used to access and manipulate data within relational database management systems (RDBMS). It describes what SQL is, common SQL commands like SELECT, INSERT, UPDATE and DELETE, SQL data types, database tables, and key clauses like WHERE that are used to filter SQL queries. Examples are provided throughout to illustrate SQL syntax and usage.
An tutorial for sql learners in very easy way. It contains all the sql commands like ddl, dml, etc. with suitable examples.
at the end there are 3 sets of question with their solution with explanation. each set contains 40+ questions.
1. A collection is an ordered group of elements having the same data type. Each element is identified by a unique subscript that represents its position in
the collection.
PL/SQL provides three collection types:
Index-by tables or Associative array
Nested table
Variable-size array or Varray
Oracle documentation provides the following characteristics for each type of collections:
Collection Type
Number of
Elements
Associative array (or index-by table) Unbounded
Nested table
Unbounded
Variable-size array (Varray)
Bounded
Where
Created
Can Be
Object
Type
Attribute
Subscript
Type
Dense or
Sparse
String or
integer
Either
Only in
PL/SQL
block
No
Integer
Starts
dense,
can
become
sparse
Either in
PL/SQL
block or at
schema
level
Yes
Integer
Always
dense
Either in
PL/SQL
block or at
schema
level
Yes
We have already discussed varray in the chapter 'PL/SQL arrays'. In this chapter, we will discuss PL/SQL tables.
Both types of PL/SQL tables i.e., index-by tables and nested tables have the same structure and their rows are accessed using the subscript notation.
However, these two types of tables differ in one aspect; the nested tables can be stored in a database column and the index-by tables cannot.
Index-By Table
An index-by table (also called an associative array) is a set of key-value pairs. Each key is unique, and is used to locate the corresponding value. The
key can be either an integer or a string.
An index-by table is created using the following syntax. Here we are creating an index-by table namedtable_name whose keys will be
of subscript_type and associated values will be of element_type
TYPE type_name IS TABLE OF element_type [NOT NULL] INDEX BY subscript_type;
table_name type_name;
Example:
Following example how to create a table to store integer values along with names and later it prints the same list of names.
DECLARE
TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
salary_list salary;
name
VARCHAR2(20);
BEGIN
-- adding elements to the table
salary_list('Rajnish')
salary_list('Minakshi')
:= 62000;
:= 75000;
salary_list('Martin') := 100000;
salary_list('James') := 78000;
2. -- printing the table
name := salary_list.FIRST;
WHILE name IS NOT null LOOP
dbms_output.put_line
('Salary of ' || name || ' is ' || TO_CHAR(salary_list(name)));
name := salary_list.NEXT(name);
END LOOP;
END;
/
When the above code is executed at SQL prompt, it produces following result:
Salary of Rajnish is 62000
Salary of Minakshi is 75000
Salary of Martin is 100000
Salary of James is 78000
PL/SQL procedure successfully completed.
Example:
Elements of an index-by table could also be a %ROWTYPE of any database table or %TYPE of any database table field. The following example
illustrates the concept. We will use the CUSTOMERS table stored in our database as:
Select * from customers;
+----+----------+-----+-----------+----------+
| ID | NAME
| AGE | ADDRESS
| SALARY
|
+----+----------+-----+-----------+----------+
|
1 | Ramesh
|
32 | Ahmedabad |
2000.00 |
|
2 | Khilan
|
25 | Delhi
|
1500.00 |
|
3 | kaushik
|
23 | Kota
|
2000.00 |
|
4 | Chaitali |
25 | Mumbai
|
6500.00 |
|
5 | Hardik
|
27 | Bhopal
|
8500.00 |
|
6 | Komal
|
22 | MP
|
4500.00 |
+----+----------+-----+-----------+----------+
DECLARE
CURSOR c_customers is
select
name from customers;
TYPE c_list IS TABLE of customers.name%type INDEX BY binary_integer;
name_list c_list;
counter integer :=0;
BEGIN
FOR n IN c_customers LOOP
counter := counter +1;
name_list(counter)
:= n.name;
dbms_output.put_line('Customer('||counter|| '):'||name_list(counter));
END LOOP;
END;
/
When the above code is executed at SQL prompt, it produces following result:
Customer(1): Ramesh
Customer(2): Khilan
3. Customer(3): kaushik
Customer(4): Chaitali
Customer(5): Hardik
Customer(6): Komal
PL/SQL procedure successfully completed
Nested Tables
A nested table is like a one-dimensional array with an arbitrary number of elements. However, a nested table differs from an array in the following
aspects:
An array has a declared number of elements, but a nested table does not. The size of a nested table can increase dynamically.
An array is always dense i.e., it always has consecutive subscripts. A nested array is dense initially, but it can become sparse when elements are
deleted from it.
An nested table is created using the following syntax:
TYPE type_name IS TABLE OF element_type [NOT NULL];
table_name type_name;
This declaration is similar to declaration of an index-by table, but there is no INDEX BY clause.
A nested table can be stored in a database column and so it could be used for simplifying SQL operations where you join a single-column table with a
larger table. An associative array cannot be stored in the database.
Example:
The following examples illustrate the use of nested table:
DECLARE
TYPE names_table IS TABLE OF VARCHAR2(10);
TYPE grades IS TABLE OF INTEGER;
names names_table;
marks grades;
total integer;
BEGIN
names := names_table('Kavita', 'Pritam', 'Ayan', 'Rishav', 'Aziz');
marks:= grades(98, 97, 78, 87, 92);
total := names.count;
dbms_output.put_line('Total '|| total || ' Students');
FOR i IN 1 .. total LOOP
dbms_output.put_line('Student:'||names(i)||', Marks:' || marks(i));
end loop;
END;
/
When the above code is executed at SQL prompt, it produces following result:
Total 5 Students
Student:Kavita, Marks:98
Student:Pritam, Marks:97
Student:Ayan, Marks:78
Student:Rishav, Marks:87
Student:Aziz, Marks:92
4. PL/SQL procedure successfully completed.
Example:
Elements of an nested table table could also be a %ROWTYPE of any database table or %TYPE of any database table field. The following example
illustrates the concept. We will use the CUSTOMERS table stored in our database as:
Select * from customers;
+----+----------+-----+-----------+----------+
| ID | NAME
| AGE | ADDRESS
| SALARY
|
+----+----------+-----+-----------+----------+
|
1 | Ramesh
|
32 | Ahmedabad |
2000.00 |
|
2 | Khilan
|
25 | Delhi
|
1500.00 |
|
3 | kaushik
|
23 | Kota
|
2000.00 |
|
4 | Chaitali |
25 | Mumbai
|
6500.00 |
|
5 | Hardik
|
27 | Bhopal
|
8500.00 |
|
6 | Komal
|
22 | MP
|
4500.00 |
+----+----------+-----+-----------+----------+
DECLARE
CURSOR c_customers is
SELECT
name FROM customers;
TYPE c_list IS TABLE of customers.name%type;
name_list c_list := c_list();
counter integer :=0;
BEGIN
FOR n IN c_customers LOOP
counter := counter +1;
name_list.extend;
name_list(counter)
:= n.name;
dbms_output.put_line('Customer('||counter||'):'||name_list(counter));
END LOOP;
END;
/
When the above code is executed at SQL prompt, it produces following result:
Customer(1): Ramesh
Customer(2): Khilan
Customer(3): kaushik
Customer(4): Chaitali
Customer(5): Hardik
Customer(6): Komal
PL/SQL procedure successfully completed.
PL/SQL Array
PL/SQL programming language provides a data structure called the VARRAY, which can store a fixed-size sequential collection of elements of the
same type. A varray is used to store an ordered collection of data, but it is often more useful to think of an array as a collection of variables of the same
type.
All varrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
5. An array is a part of collection type data and it stands for variable-size arrays. We will study other collection types in a later chapter 'PL/SQL
Collections'.
Each element in a varray has an index associated with it. It also has a maximum size that can be changed dynamically.
Creating a Varray Type
A varray type is created with the CREATE TYPE statement. You must specify the maximum size and the type of elements stored in the varray.
The basic syntax for creating a VRRAY type at the schema level is:
CREATE OR REPLACE TYPE varray_type_name IS VARRAY(n) of <element_type>
Where,
varray_type_name is a valid attribute name,
n is the number of elements (maximum) in the varray,
element_type is the data type of the elements of the array.
Maximum size of a varray can be changed using the ALTER TYPE statement.
For example,
CREATE Or REPLACE TYPE namearray AS VARRAY(3) OF VARCHAR2(10);
/
Type created.
The basic syntax for creating a VRRAY type within a PL/SQL block is:
TYPE varray_type_name IS VARRAY(n) of <element_type>
For example:
TYPE namearray IS VARRAY(5) OF VARCHAR2(10);
Type grades IS VARRAY(5) OF INTEGER;
Example 1
The following program illustrates using varrays:
DECLARE
type namesarray IS VARRAY(5) OF VARCHAR2(10);
type grades IS VARRAY(5) OF INTEGER;
names namesarray;
marks grades;
total integer;
6. BEGIN
names := namesarray('Kavita', 'Pritam', 'Ayan', 'Rishav', 'Aziz');
marks:= grades(98, 97, 78, 87, 92);
total := names.count;
dbms_output.put_line('Total '|| total || ' Students');
FOR i in 1 .. total LOOP
dbms_output.put_line('Student: ' || names(i) || '
Marks: ' || marks(i));
END LOOP;
END;
/
When the above code is executed at SQL prompt, it produces the following result:
Student: Kavita
Marks: 98
Student: Pritam
Student: Ayan
Marks: 97
Marks: 78
Student: Rishav
Student: Aziz
Marks: 87
Marks: 92
PL/SQL procedure successfully completed.
Please note:
In oracle environment, the starting index for varrays is always 1.
You can initialize the varray elements using the constructor method of the varray type, which has the same name as the varray.
Varrays are one-dimensional arrays.
A varray is automatically NULL when it is declared and must be initialized before its elements can be referenced.
Example 2
Elements of a varray could also be a %ROWTYPE of any database table or %TYPE of any database table field. The following example illustrates the
concept:
We will use the CUSTOMERS table stored in our database as:
Select * from customers;
+----+----------+-----+-----------+----------+
| ID | NAME
| AGE | ADDRESS
| SALARY
|
+----+----------+-----+-----------+----------+
|
1 | Ramesh
|
32 | Ahmedabad |
2000.00 |
|
2 | Khilan
|
25 | Delhi
|
1500.00 |
|
3 | kaushik
|
23 | Kota
|
2000.00 |
|
4 | Chaitali |
25 | Mumbai
|
6500.00 |
|
5 | Hardik
|
27 | Bhopal
|
8500.00 |
|
6 | Komal
|
22 | MP
|
4500.00 |
+----+----------+-----+-----------+----------+
Following example makes use of cursor which you will study in detail in a separate chapter.
DECLARE
CURSOR c_customers is
SELECT
name FROM customers;
type c_list is varray (6) of customers.name%type;
name_list c_list := c_list();
7. counter integer :=0;
BEGIN
FOR n IN c_customers LOOP
counter := counter + 1;
name_list.extend;
name_list(counter)
:= n.name;
dbms_output.put_line('Customer('||counter ||'):'||name_list(counter));
END LOOP;
END;
/
When the above code is executed at SQL prompt, it produces the following result:
Customer(1): Ramesh
Customer(2): Khilan
Customer(3): kaushik
Customer(4): Chaitali
Customer(5): Hardik
Customer(6): Komal
PL/SQL procedure successfully completed.