100% found this document useful (1 vote)
211 views

LO1 Write An SQL Statement To Retrieve and Sort Data

SQL is a standardized language used to manage data in relational database management systems. It allows users to retrieve, insert, update, and delete data as well as create databases, tables, stored procedures, and views. Some popular RDBMS that use SQL include Microsoft SQL Server, Oracle, MySQL, and IBM DB2. These systems implement their own versions of the SQL language and are used for a variety of applications across many industries.

Uploaded by

Galaxy teck
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
211 views

LO1 Write An SQL Statement To Retrieve and Sort Data

SQL is a standardized language used to manage data in relational database management systems. It allows users to retrieve, insert, update, and delete data as well as create databases, tables, stored procedures, and views. Some popular RDBMS that use SQL include Microsoft SQL Server, Oracle, MySQL, and IBM DB2. These systems implement their own versions of the SQL language and are used for a variety of applications across many industries.

Uploaded by

Galaxy teck
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

LO1 Write an SQL Statement to retrieve and sort data

1.1 Introduction to SQL


1.1.1 What is SQL?
SQL (Structured Query Language) is a database computer language designed for managing data
in relational database management systems (RDBMS).

Most Relational Database Management Systems like MS SQL Server, Microsoft Access, Oracle,
MySQL, DB2, Sybase, PostgreSQL and Informix use SQL as a database querying language.
Even though SQL is defined by both ISO and ANSI there are many SQL implementation, which
do not fully comply with those definitions.

SQL, is a standardized computer language that was originally developed by IBM for querying,
altering and defining relational databases, using declarative statements. SQL is relatively simple
language, but it’s also very powerful.
SQL is pronounced SEQUEL. SQL was developed during the early 70’s at IBM.

1.1.2 Categories of SQL Application


What can SQL do?
 SQL can execute queries against a database
 SQL can retrieve data from a database
 SQL can insert records in a database
 SQL can update records in a database
 SQL can delete records from a database
 SQL can create new databases
 SQL can create new tables in a database
 SQL can create stored procedures in a database
 SQL can create views in a database
 SQL can set permissions on tables, procedures, and views

Even if SQL is a standard, many of the database systems that exist today implement their own
version of the SQL language.

1.2 Installing DBMS software


1.2.1 Introduction:- DBMS is a Set of programs to access the data or software system
designed to store, manage, and facilitate access to databases.
 Collection of interrelated data
 DMBS contains information about a particular enterprise
 DBMS provides an environment that it both convenient and efficient to use
Database Applications:
 Banking:- all transactions
 Airlines:- reservations, schedules
 Universities:- registrations. Grade
 Sales:- customers, products, purchase
 Human resource:- employee records, salaries, tax deduction
 Manufacturing: production, Inventory, orders, supply chain
Purpose of Database Systems
Database management systems were developed to handle the following difficulties of typical
file-processing systems supported by conventional operating systems:
 Data redundancy and inconsistency
 Difficulty in accessing data
 Data isolation – multiple files and formats
 Integrity problems
 Atomicity of updates
 Concurrent access by multiple users
 Security problems
There are lots of different database systems, or DBMS- Database Management Systems, such as:
1. Microsoft SQL Server
 Enterprise, Developer versions, etc.
 Express version is free of charge
MS SQL Server is a Relational Database Management System developed by Microsoft Corp. MS
SQL Server is an enterprise level database competing with products like Oracle and DB2. MS
SQL Server cost much less than its comparable competitors products, hence its popularity.

MS SQL Server is a paid database server, but it has a free limited version called MSDE
(Microsoft SQL Server Desktop Engine). MSDE version of MS SQL Server is free for re-
distribution with desktop applications. As we mentioned MSDE has certain restrictions, like:
 The maximum size of a database is 2 GB
 MSDE comes with no administration tools.
 MSDE has has a governor which will slower the db server response once you exceed 5
concurrent connections to it.
MS SQL Server uses SQL as its standard database language. The SQL dialect used by MS SQL
Server is called T-SQL.
The latest MS SQL Server version available on the market is MS SQL Server 2008.

2. Oracle
Oracle is aObject- relational database management system developed by Oracle Corporation.The
Oracle RDBMS is used in many database applications on sevarl OS platforms, including Unix
and Windows.
 Founding of Oracle
In 1977, Larry Ellison, Bob Miner, and Ed Oates started the consultancy Software Development
Laboratories, which became Relational Software, Inc. (RSI). In 1983, RSI became Oracle
Systems Corporation and then later Oracle Corporation.
 First commercially available RDBMS
In 1979, RSI introduced Oracle V2 (Version 2) as the first commercially available SQL-based
RDBMS, a landmark event in the history of relational databases.
 Objects and partitioning
Oracle8 was released in 1997 as the object-relational database, supporting many new data types.
Additionally, Oracle8 supported partitioning of large tables.
The Oracle database was the first commercial RDBMS that became available on Linux during
the summer of1999. The Oracle datatabase is more expensive compared to MS SQL Server.

 PL/SQL stored program units


PL/SQL short for Procedural Language/Structured Query Language is Oracle's server-based
extension to the SQL language.
 Portable version of Oracle Database

3. MySQL (Oracle, previously Sun Microsystems) –


MySQL can be used free of charge (open source license), MySQL is an open source relational
database management system released under GNU General Public License. The Swedish
company called MySQL AB develops MySQL. This is partly because it is completely free but
also very powerful.

MySQL is most commonly used for Web applications and for embedded applications and has
become a popular alternative to proprietary database systems because of its speed and reliability.
MySQL can run on UNIX, Windows and Mac OS. MySQL is developed, supported and
marketed by MySQL AB.

4. Microsoft Access
it’s one of the most popular Microsoft products. MS Access comes with the professional edition
of MS Office package. MS Access is a paid product and runs only on Windows platform.

MS Access has easy to use intuitive graphical interface, which makes it one of the most popular
database software among small business.

5. IBM DB2
DB2 is relational database management system developed by IBM. DB2 is the first database
product that used SQL language. DB2 was first available on the mainframe and later moved to
UNIX, Linux and Windows platforms.

DB2 has the ability to handle millions of transactions and huge sets of data. DB2 is very scalable
and can handle serious workloads.DB2’s main competitor is Oracle. DB2 is a low cost
alternative to MS SQL Server and Oracle databases. DB2 is usually administered through multi-
platform java client GUI.

DBMS Terminologies and Definations

1. Data Definition Language (DDL)


The DDL manages table and index structure. Specification notation for defining the database
schema. DDL compiler generates a set of tables stored in a data dictionary and Data dictionary
contains metadata (data about data). DDL statements are used to define the database structure or
schema.

Data storage and definition language – special type of DDL in which the storage structure and
access methods used by the database system are specified.
The most basic items of DDL are the CREATE, ALTER, RENAME and DROP statements:
 CREATE creates an object (a table, for example) in the database.
 DROP deletes an object in the database, usually irretrievably.
 ALTER modifies the structure an existing object in various ways—for example, adding a
column to an existing table
 TRUNCATE - remove all records from a table, including all spaces allocated for the records
are removed
 COMMENT - add comments to the data dictionary
 RENAME - rename an object
2. Data Manipulation Language (DML)
The DML Language for accessing and manipulating the data organized by the appropriate data
model. It is the subset of SQL used to add, update and delete data and statements are used for
managing data within schema objects.

The acronym CRUD refers to all of the major functions that need to be implemented in a
relational database application to consider it complete. Each letter in the acronym can be mapped
to a standard SQL statement:

Operation SQL Description


Create INSERT INTO inserts new data into a database
Read (Retrieve) SELECT extracts data from a database
Update UPDATE updates data in a database
Delete (Destroy) DELETE deletes data from a database
MERGE UPSERT operation (insert or update)
CALL call a PL/SQL or Java subprogram
EXPLAIN PLAN explain access path to data
LOCK TABLE control concurrency
3. Data Control Language (DCL)
DCL is a subset of the Structured Query Lanaguge (SQL) that allows database administrators
to configure security access to relational databases. Some examples:
 GRANT - to allow specified users to perform specified tasks
 REVOKE - to cancel previously granted or denied permissions.
 DENY - may be used to explicitly prevent a user from receiving a particular permission.
This is helpful when a user may be a member of a role or group that is granted a
permission and you want to prevent that user from inheriting the permission by creating
an exception.
4. Transaction Control Laguage (TCL)
TCL are used to manage the changes made by DML statements. It allows statements to be
grouped together into logical transactions. used to control transactional processing in a database.
 COMMIT - save work done. To apply the transaction by saving the database changes
 SAVEPOINT - identify a point (breakpoints) for a transaction to which you can later
rollback or to allow partial rollbacks.
 ROLLBACK - restore database to original since the last COMMIT or to undo all
changes of a transaction
 SET TRANSACTION - used to specify characteristics for the transaction that follows.
For example, you can specify a transaction to be read only or read write.
 RELEASE SAVEPOINT- used to remove a SAVEPOINT that you have created.

1.2.2 Hardware Requirements: - Minimum Hardware Requirements

Table 5.3 outlines SQL Server 2008 hardware requirements.

Minimum Hardware Requirements Minimum Hardware Minimum Hardware


Hardware
32-Bit Requirements x64 Requirements IA64
Pentium III-compatible processor or Any Intel EMT64 or AMD x64 Itanium processor.
CPU faster. 1GHz minimum. Recommended chip. Minimum 1.4GHz. Recommended 1GHz or
2GHz or faster. Recommended 2GHz or faster. faster.
512MB minimum, 2GB or more 512MB minimum, 2GB or
512MB minimum, 2GB or more
Memory recommended. Report Server will use a more recommended.
recommended. Maximum is the
(RAM) maximum of 3GB (with /3GB switch in Maximum is the OS-
OS-specified maximum.
boot.ini). specified maximum.
Total will vary depending on Total will vary depending
Hard disk Total will vary depending on selected
selected components. See Table on selected components.
space components. See Table 5.2.
5.2. See Table 5.2.
VGA or higher resolution.
VGA or higher resolution. 1024x768 VGA or higher resolution.
1024x768 recommended
Monitor recommended for SQL Server graphical 1024x768 recommended for SQL
for SQL Server graphical
tools. Server graphical tools.
tools.
Microsoft mouse or
Pointing Microsoft mouse or compatible Microsoft mouse or compatible
compatible pointing
device pointing device. pointing device.
device.
CD or DVD Drive as needed
CD or DVD drive as needed for given CD or DVD drive as needed for
CD/DVDROM for given installation
installation media. given installation media.
media.
The following is the terminology used in relation to the 64-bit platform:
 IA64 refers to Itanium-compatible hardware architecture. This architecture can run IA64 software
and 32-bit software using the Windows-On-Windows (WOW64) software emulator. The
Itanium CPU cannot natively run 32-bit x86-compatible instructions and uses instruction
emulation as a part of WOW64 processing.
 x64 refers to Extended Memory Technology support-compatible architecture and includes
systems based on Opteron, Athlon 64, Intel Xeon EM64T, and Intel Pentium EM64T. x64
architecture can run classic 32-bit x86-compatible instructions natively on the CPU. One of the
advantages of this architecture is an ability to support both 32- and 64-bit code. To ease an
adoption of the 64-bit platform and optimize a hardware purchase, some companies might first
deploy a 32-bit operating system and software on x64 hardware and then upgrade to 64-bit
software on the same hardware requirements.
NOTE
System Configuration Check blocks setup from running if the CPU type (Pentium III or higher)
requirement is not met. Setup issues a warning, but allows you to proceed, if the CPU speed or
minimum memory requirement is not met.

1.2.3 Operating System Requirements: Software Requirements


We recommend installing Reporting Services on Windows 2008. Although Windows 2003 SP2
is a fully supported platform, Windows 2008 reflects the latest technological advances, including
enhanced coverage in the areas of security and high availability.

Windows Server 2008 also provides the Hyper-V virtualization systems. SQL Server 2008 and
all of its components, including SSRS, are supported in virtual environments created using
Hyper-V, provided of course sufficient CPU and RAM resources are allocated to the virtual
machine and that the virtual machine runs an operating system supported by SQL Server
Reporting Services (SSRS).

Tables 5.4, 5.5, and 5.6 list operating system requirements and additional software requirements
for installation of Reporting Services on 32- and 64-bit platforms.

TABLE 5.4 Operating Systems That Can Run 32-Bit Versions of Report Server

Enterprise Enterprise Developer Standard Workgroup


 
Edition Evaluation Edition Edition Edition Edition
Windows XP Professional SP2 No Yes Yes Yes Yes
Windows XP SP2 Media Center
No Yes Yes Yes Yes
Edition
Windows Vista Ultimate No Yes Yes Yes Yes
Windows Vista Business No Yes Yes Yes Yes
Windows Vista Enterprise No Yes Yes Yes Yes
Windows Vista Home Premium No Yes Yes No No
Windows 2003 SP2 Standard Yes Yes Yes Yes Yes
Windows 2003 SP2 Enterprise Yes Yes Yes Yes Yes
Windows 2003 SP2 Data Center Yes Yes Yes Yes Yes
Windows 2008 Standard Yes Yes Yes Yes Yes
Windows 2008 Enterprise Yes Yes Yes Yes Yes
Windows 2008 Data Center Yes Yes Yes Yes Yes

NOTE
Systems that are not explicitly listed in Table 5.4 are not supported by Reporting Services. For
example, Reporting Services 32-bit is not supported on Windows 2003 64-bit Itanium.
For situations with heavy memory or I/O requirements, such as heavy graphics and PDF
rendering, customers can benefit from deploying SSRS on a 64-bit platform. Table 5.5 outlines
SSRS support on a 64-bit platform.

TABLE 5.5 Operating System Requirements, 64-Bit

Express
  Enterprise x64 Standard x64 Workgroup x64 Web x64
x64
Windows XP Pro x64 No Yes Yes Yes No
Windows Server 2003 Standard x64 Yes Yes Yes Yes Yes
Windows Server 2003 Data Center
Yes Yes Yes Yes Yes
x64
Windows Server 2003 Enterprise x64 Yes Yes Yes Yes Yes
Windows Vista x64 Ultimate No Yes Yes Yes Yes
Windows Vista x64 Home Premium No No Yes No Yes
Windows Vista x64 Home Basic No No Yes No Yes
Windows Vista x64 Enterprise No Yes Yes Yes Yes
Windows Vista x64 Business No Yes Yes Yes Yes
Windows Server 2008 Standard x64 Yes Yes Yes Yes Yes
Windows Server 2008 Data Center
Yes Yes Yes Yes Yes
x64
Windows Server 2008 Enterprise x64 Yes Yes Yes Yes Yes

The following operating systems are supported by SQL Server Enterprise/Developer Edition
IA64:

 Windows Server 2008 64-bit Itanium


 Windows Server 2003 SP2 64-bit Itanium Data Center
 Windows Server 2003 SP2 64-bit Itanium Enterprise

Note that with any 64-bit operating system, management tools may be supported in WOW64.
WOW64 allows native 32-bit code to execute natively on non-32-bit systems.

NOTE
Development tools such as Business Intelligence Development Studio (BIDS) are neither
installed nor supported on the IA64 platform. For IA64 deployments, use development tools
installed on a separate 32-bit or x64 workstation.

Table 5.6 outlines additional software requirements for both 32- and 64-bit platforms and
optional software that can be installed to benefit Reporting Services.

TABLE 5.6 Additional Software Requirements, 32- and 64-Bit


Sofware Requirement Notes

.NET Framework Windows 2003 IA63 requires .NET Framework 2.0 SP1.

  Every other version of requires the .NET Framework 3.5.

Microsoft Data Access Components (MDAC) All versions require MDAC 2.8 SP1 or higher.

Windows Installer All versions require Windows Installer 4.5 or later.

1.2.4 Install DBMS (SQL Server)


Download SQL Server 2008 Express Edition with tools (around 230 MB) and run the setup file.
If you are using windows XP SP3
 Remark: Microsoft regularly updates SQL Express, so screens could change a little over time.
1. Choose between 32 bits version (XP, Vista) or 64 Bits version (Seven)
Launch installer : the installer extracted the data

2. SQL Server installation Center opens.


Click on "System configuration Checker" to check for conditions that prevents a successful SQL
Server Installation

3. Setup Support Rules opens. Click on "show details to ensure that all the tests passed
successfully
Then click on OK

If you have some tests failures:


- click on the test to have more information’s about the error
- Ensure you have uninstalled correctly all previous versions of SQL Server (2000, 2005) and
rebooted your computer before
- Refer to online documentation on Microdoft SQL Server website
- refer to Octopus users forum

4. Go Back to SQL Server installation Center


On the left column, click on "Installation"
Then click on the first link : "new SQL Server stand-alone installation" (Unless you want to
make a specific network installation)

5.  Setup support rules reopen. 


Once all operations completed, click OK

6. The SQL Server 2008 Setup opens with a first "product key" tab
As we use a specific free version of SQL Serveur, no activation key is needed. 
Simply click "next"
7. Read the licence terms
Check the box "I accept the licence terms"
Click on "Next"

8. The "setup support files" tab opens.


Click on "install"

9. Once installed, the Setup Support Rules reopen.


Check that all operation passsed, then click "next"

10.  On the "features selection" tab choose "Data Engine Services" and "Management tools" (this
is the Management Studio Express)
check the features directory (no need to change normally) click "next"

11. On the "instance Configuration" check that the parameters are like the screenshot on the left
(nothing to change normally)
Click "Next"

12. Disk space requirements tap


-> Click Next

13. Server Configuration:


For the first service "SQL Server Database Engine", on the account name, choose the first result
of the listbox
(in our case NT AUTHORITY\NETWORK)
Then click "Next".

14. Database Engine Configuration:


- Chose "Mixed mode"
- Enter the  password octopus
- Specify SQL Server administratir : Click on "add current user"
- Click "Next"

15. Error and Usage Reporting


Click next

16. Installation Rules :


Once Operation completed, click "Next"

17. Ready to install:


Click "Install"

18. Installation Progress


- Wait until Installation is finished
- Ensure "Database Engine Services" and "Management Tools Basic" are successfully installed
- Click "Next"
19. Complete:
Once installed, click on "Close"

20. To ensure SQL Express is running correctly, run "SQL Server Configuration Manager"
On the left column click on "SQL Server Services
On the right column, ensure that SQL Server (SQLEXPRESS) is running correctly (otherwise
right-click on the device to start it)

21. Browse the new directory "Microsoft SQL Server 2008" and open the SQL Server
Management Studio to ensure it has been correctly installed

22. If you used to work with SQL Server 2000 our SQL Server 2005 before, you will probably
obtain this message
"Do you want to import your customized user settings...". Simply click Yes (or no as you prefer
it doesn't matters concerning Octopus)

23. The SQL Server Connation Windows appears.


Choose the following parameters:
- Server Type: Database Engine
- Server Name: (Name of your computer)\SQLEXPRESS*
- Authentication: SQL Server Authentication (if you can only see windows authentication, you
probably missed to choose
"Mixed Mode" at the Database Engine Configuration step 
- Login: sa (by default)
- Password: the password you defined at the Database Engine Configuration step (octopus in our
case)

* You can find the name of your computer on the control panel>System
 
Does it opens ? -> Congratulations, you can now go to the next step: Install Octopus

You might also like