Delphi 7 - InterBase Tutorial.pdf

(745 KB) Pobierz
InterBase 5 Tutorial
Teach Yourself
InterBase
This tutorial takes you step-by-step through the process of creating and using a database using the
InterBase Windows ISQL dialog. You learn to create data structures that enforce referential integrity
constraints and maintain security. You populate your tables, create triggers and stored procedures,
and learn a number of techniques for retrieving the data with precision.
There are five parts in this tutorial.
g In Part I, you learn how to use this tutorial, you start the InterBase server and log in to it, and you
create a user and a database.
g In Part II, you learn the fundamentals of database design and how to work in the InterBase Windows
ISQL environment; you create the data structures for your database, and you learn a little about how
to recover from errors.
g In Part III, you put data into the database (you populate it).
g In Part IV, you get the data out again (you access or retrieve it).
g In Part IV, you work with database security, and create some triggers and stored procedures to
automate some of your database tasks.
INTERBASE 5 TUTORIAL
1
 
28844849.004.png
PART I GETTING STARTED
n
T opic: USING THIS TUTORIAL
Part I Getting Started
In Part I, you perform the following actions:
g
Check whether the Local InterBase server is running
g
Start the Local InterBase server
g
Log on to a server from the InterBase Server Manager and create a new user on the server
g
Open InterBase Windows ISQL and create a new database on a server
Using this tutorial
Throughout this tutorial, you are instructed to enter SQL statements manually at the beginning of each
new topic in order to give you hands-on experience with it. Then you are instructed to read in one of
the SQL scripts that accompany this tutorial document. Following these steps allows you to create a
database that is complex enough to be interesting without excessive keyboarding. The database that
you create in this tutorial is, in fact, the EMPLOYEE database that is used as the Example database for
InterBase and that is referenced throughout the InterBase document set.
Finding the files you need
As you reach the places in this tutorial that tell you to read in a script file, use the script files (*. sql )
that are in the \ doc\Tutorial \ directory on your InterBase CDROM.
This tutorial document and the accompanying SQL script files are also available on the InterBase web
Typographic conventions
This tutorial document and the SQL scripts that accompany it use the following typographic
conventions:
· Database names, keywords, and domain names are in ALL CAPS .
· Table names have initial caps and are in italic .
· Names of columns, indexes, stored procedures, and triggers are lowercase italic .
· File and path names are in italic .
INTERBASE 5 TUTORIAL
3
28844849.005.png
PART I GETTING STARTED
n
T opic: STARTING THE LOCAL INTERBASE SERVER
Reading and typing capitals
Type of entry
Case sensitivity
SQL statements
When you’re entering SQL statements into InterBase Windows ISQL, you can ignore the
capitalization. The conventions listed above are to make it easy to read and understand the
examples. You can enter the exercises in all lower case if you prefer.
Strings
Strings (anything inside of quotation marks) are case sensitive. There are a lot of strings in single
quotes in this tutorial, and you must enter the case exactly as it’s shown.
External references When you refer to something outside of InterBase, such as a filename, the reference is case sensitive.
TABL E 1
Line breaks
g
Line breaks are added within example statements to make them easy to read and understand. They
are not required.
g
When you’re entering statements in InterBase Windows ISQL you don’t have to follow the line breaks
in the examples. Enter ones that make it easy for you to keep track of what you’re doing. InterBase
ignores line breaks within input SQL statements.
Understanding which parts to do
This tutorial contains some code examples that you are not supposed to enter into the TUTORIAL
database. In other places, it gives the text of code that you are supposed to enter: these are your action
items. To make things clear, parts that you are supposed to actually enter are all preceded by headings
with a
4
symbol, as in the following example:
4
Example of an action item head
Actions that you are supposed to perform are always preceded by a head like the one above. Don’t
enter examples that are not preceded by this type of heading.
Starting the Local InterBase server
Only one instance of the InterBase server can run at a time, so to work on this tutorial, you need to
check whether InterBase is running and start it if necessary.
4
Start the server
To check whether InterBase is running On Windows 95 platforms, an icon appears in the tray when
InterBase is running. This is also true when InterBase is running as an application on Windows NT.
When InterBase running as a service on Windows NT platforms, there is no icon. To check whether
InterBase is running as a service on NT, right-click on a blank area of the Windows Taskbar, choose
Task Manager from the menu, and look for ibguard.exe or ibserver.exe in the Processes pane.
To start the Local InterBase server To start the Local InterBase server running as an application on
either Windows 95 or Windows NT, choose InterBase Guardian from the InterBase folder of the Start
menu. To start Local InterBase as a service on Windows NT platforms, double-click Services in the
Control Panel, highlight the InterBase Guardian entry, and click Start.
INTERBASE 5 TUTORIAL
4
28844849.006.png
PART I GETTING STARTED
n
T opic: CONNECTING TO A SERVER FROM SERVER MANAGER
Connecting to a server from Server Manager
The text of this tutorial assumes that you are working on the Local InterBase server. If you want to
work on a remote server, you must have the password for a valid InterBase user on that server.
Note In this part of the tutorial, you connect to a server using the InterBase Server Manager, because
your next task is to create a new user on that server. You must be working in Server Manager to create
a user. Throughout the rest of this tutorial, you will connect to a server from the InterBase Windows
IQSL dialog, since that’s where you do most of the work of creating, populating, using, and
maintaining a database.
In this exercise, you connect as the SYSDBA user, since that is the only user who can create new user
accounts. You create a user called TUTOR , which is the account you will use for the rest of these
exercises.
4
Log in to a server from Server Manager
1. Open the InterBase Server Manager by choosing it from the InterBase folder on the Start
menu.
Server Login
button
2. To log in to the Local InterBase server, click the Server Login button or choose File | Server
Login to display the InterBase Login dialog.
3. Click the Local Engine radio button and fill in the password for the SYSDBA user. By default,
this password is masterkey . If you have changed the password (highly recommended!),
use the current password. Click OK. In either case, you must log on as SYSDBA in order to
create a new user account.
INTERBASE 5 TUTORIAL
5
28844849.001.png 28844849.002.png 28844849.003.png
Zgłoś jeśli naruszono regulamin