Linux базы данных firebird

Linux базы данных firebird

Утилита isql позволяет создавать базы данных более, чем одним способом. Мы же рассмотрим простой способ создания базы данных в интерактивном режиме, хотя для серьезного использования Вам, скорее всего, потребуется научиться создавать и использовать скрипты. В руководстве Using Firebird имеется отдельная глава, посвященная этому вопросу.

Запускаем isql

Для создания базы данных с использованием утилиты isql в интерактивном режиме, в командной строке перейдите в директорию bin и наберите isql (Windows) или ./isql (Linux):

C:\Program Files\Firebird\Firebird_1_5\bin>isql↵ Use CONNECT or CREATE DATABASE to specify a database

Оператор CREATE DATABASE

Теперь Вы можете создать базу данных. Предположим, что Вы хотите создать базу данных test.fdb и сохранить её в папке data на диске D:

SQL>CREATE DATABASE 'D:\data\test.fdb' page_size 8192↵ CON>user 'SYSDBA' password 'masterkey';↵

Важно

  • В отличии от оператора CONNECT , в операторе CREATE DATABASE кавычки вокруг пути к файлу, имени пользователя и пароля являются обязательными .
  • Если Вы используете Classic Server под Linux и в пути не указываете имя хоста, будет произведена попытка создать файл базы данных с Вашей учетной записью в Linux в качестве владельца. Может быть это именно то, что Вы и хотите, а может и нет (подумайте о правах доступа, если Вы хотите, чтобы к базе данных мог подключаться кто-то еще). Если же в пути указать, например, localhost:, тогда создавать и влдаеть файлом будет серверный процесс (который в Firebird 1.5 обычно работает от имени firebird).
  • В случае использования Classic Server под Windows, Вы должны указывать имя хоста (которое может быть localhost) плюс полный путь к файлу, в противном случае процесс создания закончится неудачей.

Будет создана база данных и через некоторое время вновь появится приглашение SQL. Теперь Вы подключены к новой базе данных и можете создать какие-нибудь объекты в ней.

Чтобы убедиться, что там действительно база данных, выполните запрос:

SQL>SELECT * FROM RDB$RELATIONS;↵

На экран будет выдано большое количество данных! Этот запрос извлекает все строки из системной таблицы, в которой Firebird хранит метаданные для таблиц. « Пустая » база данных на самом деле не очень-то и пустая – она содержит базу данных, которая будет расти, наполняясь метаданными, по мере создания Вами новых объектов в ней.

Читайте также:  Файловый сервер linux centos

Для возвращения в командную строку, наберите

За дополнительной информацией об isql обращайтесь к главе 10 Using Firebird: Interactive SQL Utility (isql).

Источник

Setting up Firebird on Ubuntu Linux

This article describes the process of installing and running Firebird on Ubuntu Linux. It should also work without modification in the Debian GNU/Linux distribution (testing version named Wheezy and unstable version named Sid). Ubuntu is based on Debian core packages. Installing software with Ubuntu is very straightforward and Firebird is no exception. This guide is based on Ubuntu 12.04 LTS “ The Precise Pangolin ” but it can be used with a current supported stable release.

The version of Firebird packaged with Ubuntu “ Precise Pangolin ” is 2.5.1 and is included by default . For stable Ubuntu releases there is a Firebird stable ppa repository from where you can install the stable versions latest LTS and current stable .

With administrator privileges on the target machine, issue the following command:

$ sudo su # apt-get install firebird2.5-superclassic

Apt’s dependency tracking will automatically propose all the packages required for a complete installation with the following output:

Reading package lists. Done Building dependency tree Reading state information. Done The following extra packages will be installed: firebird2.5-classic-common firebird2.5-common firebird2.5-common-doc firebird2.5-server-common libfbclient2 libfbembed2.5 libib-util Suggested packages: firebird2.5-doc The following NEW packages will be installed: firebird2.5-classic-common firebird2.5-common firebird2.5-common-doc firebird2.5-server-common firebird2.5-superclassic libfbclient2 libfbembed2.5 libib-util 0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. Need to get 3,370 kB of archives. After this operation, 14.9 MB of additional disk space will be used. Do you want to continue [Y/n]? Y

The packages will then download and install on the target machine. A new user “ firebird ” will be created to run the server, but the server will not yet be started by default:

Selecting previously unselected package firebird2.5-common-doc. Unpacking firebird2.5-common-doc (from . /firebird2.5-common-doc_2.5.2~svn+54698.ds4-1_all.deb) . Selecting previously unselected package firebird2.5-common. Unpacking firebird2.5-common (from . /firebird2.5-common_2.5.2~svn+54698.ds4-1_all.deb) . Selecting previously unselected package libfbclient2:amd64. Unpacking libfbclient2:amd64 (from . /libfbclient2_2.5.2~svn+54698.ds4-1_amd64.deb) . Selecting previously unselected package firebird2.5-server-common. Unpacking firebird2.5-server-common (from . /firebird2.5-server-common_2.5.2~svn+54698.ds4-1_amd64.deb) . Selecting previously unselected package libfbembed2.5. Unpacking libfbembed2.5 (from . /libfbembed2.5_2.5.2~svn+54698.ds4-1_amd64.deb) . Selecting previously unselected package libib-util:amd64. Unpacking libib-util:amd64 (from . /libib-util_2.5.2~svn+54698.ds4-1_amd64.deb) . Selecting previously unselected package firebird2.5-classic-common. Unpacking firebird2.5-classic-common (from . /firebird2.5-classic-common_2.5.2~svn+54698.ds4-1_amd64.deb) . Selecting previously unselected package firebird2.5-superclassic. Unpacking firebird2.5-superclassic (from . /firebird2.5-superclassic_2.5.2~svn+54698.ds4-1_amd64.deb) . Setting up firebird2.5-common-doc (2.5.2~svn+54698.ds4-1) . Setting up firebird2.5-common (2.5.2~svn+54698.ds4-1) . Setting up libfbclient2:amd64 (2.5.2~svn+54698.ds4-1) . Setting up firebird2.5-server-common (2.5.2~svn+54698.ds4-1) . Setting up libfbembed2.5 (2.5.2~svn+54698.ds4-1) . Setting up libib-util:amd64 (2.5.2~svn+54698.ds4-1) . Setting up firebird2.5-classic-common (2.5.2~svn+54698.ds4-1) . Setting up firebird2.5-superclassic (2.5.2~svn+54698.ds4-1) . Created default security2.fdb * Firebird 2.5 superclassic server not running * Not starting Firebird 2.5 superclassic server * Use `dpkg-reconfigure firebird2.5-superclassic' to enable

If you want Firebird to start automatically, run dpkg-reconfigure on the package and click the Yes button. Then you will be asked again for the SYSDBA password:

# dpkg-reconfigure firebird2.5-superclassic

If all goes well, Firebird Superserver will be started:

* Firebird 2.5 superclassic server not running * Starting Firebird 2.5 superclassic server. [ OK ] * Firebird 2.5 superclassic server already running

If you’re a seasoned Unix person but new to Ubuntu, you might be wondering where all the Firebird files are residing in the directory hierarchy. To see where all the files were installed by Apt, simply do:

# dpkg -L firebird2.5-classic-common /. /usr /usr/share /usr/share/doc /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/firebird2.5-classic-common /usr/lib /usr/lib/firebird /usr/lib/firebird/2.5 /usr/lib/firebird/2.5/UDF /usr/lib/firebird/2.5/UDF/fbudf.so /usr/lib/firebird/2.5/UDF/ib_udf.so /usr/sbin /usr/sbin/fb_lock_print /usr/bin /usr/bin/fbsvcmgr /usr/bin/gsec /usr/bin/gpre /usr/bin/gbak /usr/bin/gdef /usr/bin/fbstat /usr/bin/fbtracemgr /usr/bin/nbackup /usr/bin/isql-fb /usr/bin/qli /usr/bin/gfix /usr/share/doc/firebird2.5-classic-common

As mentioned, a new user “ firebird ” is created on the target machine.

Читайте также:  Пингвинус все о linux

Now you can switch to the firebird user with the su command if required.

Install the examples and dev files:

# apt-get install firebird2.5-examples firebird2.5-dev

The example databases will wind up in the directory tree /usr/share/doc/firebird2.5-examples/examples/empbuild/ .

Now you can test your Firebird installation by connecting to an example database. Decompress the employee.fdb example database:

# cd /usr/share/doc/firebird2.5-examples/examples/empbuild/ # gunzip employee.fdb.gz # sudo chown firebird.firebird employee.fdb # mv employee.fdb /var/lib/firebird/2.5/data/

Fire up the interactive shell and at the SQL> prompt connect to the employee database using the connect statement:

isql-fb SQL> connect "localhost:/var/lib/firebird/2.5/data/employee.fdb" user 'SYSDBA' password 'SYSDBApassword';

(replacing SYSDBApassword with the correct password for SYSDBA !)

When you manage to successfully connect to the database you will see the message:

Database: "localhost:/var/lib/firebird/2.5/data/employee.fdb", User: SYSDBA SQL>

Now, from the SQL> prompt, feel free to browse around the employee database. For instance, you can list the tables and check the server version:

SQL> show tables; COUNTRY CUSTOMER DEPARTMENT EMPLOYEE EMPLOYEE_PROJECT JOB PROJECT PROJ_DEPT_BUDGET SALARY_HISTORY SALES SQL> show version; SQL Version: LI-V2.5.2.26508 Firebird 2.5 Server version: Firebird/linux AMD64 (access method), version "LI-V2.5.2.26508 Firebird 2.5" Firebird/linux AMD64 (remote server), version "LI-V2.5.2.26508 Firebird 2.5/tcp (Lorkstation64)/P12" Firebird/linux AMD64 (remote interface), version "LI-V2.5.2.26508 Firebird 2.5/tcp (Lorkstation64)/P12" on disk structure version 11.2 SQL> quit;

If you want a GUI admin tool, you might check FlameRobin, which is included in the Ubuntu repository. It can be installed with a simple:

# apt-get install flamerobin

If you get an error message like “ Statement failed, SQLCODE = -551 no permission for read-write access to database /var/lib/firebird/2.5/data/employee.fdb ”, then the server process doesn’t have read or write access to the database file. Change the ownership of the database to the user firebird with:

# cd /var/lib/firebird/2.5/data/ # chown firebird:firebird employee.fdb

If you’ve made it this far, your Firebird installation on Ubuntu has been a success. Have a nice day!

Читайте также:  Alt linux rdp client

Источник

Оцените статью
Adblock
detector