mirror of https://github.com/tLDP/LDP
updated
This commit is contained in:
parent
f3da0577a3
commit
c961f3fcae
|
@ -42,7 +42,7 @@ Covers PostgreSQL Version 6.5.3
|
|||
<author>Al Dev (Alavoor Vasudevan)
|
||||
<htmlurl url="mailto:alavoor@yahoo.com"
|
||||
name="alavoor@yahoo.com">
|
||||
<date>v31.0, 08 Oct 2000
|
||||
<date>v33.0, 10 Oct 2000
|
||||
<abstract>
|
||||
This document is a "practical guide" to very quickly setup a SQL Database
|
||||
engine and
|
||||
|
@ -1027,6 +1027,7 @@ Now you can start <bf>rapidly BANGING away</bf> SQL commands at psql or pgaccess
|
|||
To drop the database do :
|
||||
<code>
|
||||
bash$ man dropdb
|
||||
bash$ man destroydb (for older versions of pgsql)
|
||||
bash$ dropdb <dbname>
|
||||
</code>
|
||||
It is also possible to destroy a database from within an SQL session by using:
|
||||
|
@ -1061,7 +1062,8 @@ bash$ createuser -h host -p port -i userid <username>
|
|||
|
||||
To drop a postgres user, use shell script 'destroyuser' -
|
||||
<code>
|
||||
bash$ man destroyuser
|
||||
bash$ man dropuser
|
||||
bash$ man destroyuser (older versions of pgsql)
|
||||
bash$ destroyuser
|
||||
</code>
|
||||
<!--
|
||||
|
@ -1287,6 +1289,75 @@ Tip: In psql press up/down arrow keys for history line editing or \s
|
|||
<!--
|
||||
|
||||
|
||||
*******************************************
|
||||
************ End of Section ***************
|
||||
*******************************************
|
||||
|
||||
-->
|
||||
<sect1> Creating Triggers and Stored Procedures
|
||||
<p>
|
||||
To create triggers or stored procedures,
|
||||
First run 'createlang' script to install 'plpgsql'
|
||||
in the particular database you are using. If you want
|
||||
by default then install it in 'template1' and subsequent
|
||||
created databases will be clones of template1.
|
||||
See 'createlang' web page in User guide at /usr/doc/postgresql-7.0.2/user/index.html.
|
||||
|
||||
<code>
|
||||
bash$ man createlang
|
||||
bash$ createdb mydb
|
||||
bash$ export PGLIB=/usr/lib/pgsql
|
||||
bash$ createlang plpgsql mydb
|
||||
bash$ createlang plpgsql template1
|
||||
</code>
|
||||
See also the trigger, stored procedures examples in
|
||||
<ref id="Examples RPM">. One sample code from examples RPM:
|
||||
<code>
|
||||
create function tg_pfield_au() returns opaque as '
|
||||
begin
|
||||
if new.name != old.name then
|
||||
update PSlot set pfname = new.name where pfname = old.name;
|
||||
end if;
|
||||
return new;
|
||||
end;
|
||||
' language 'plpgsql';
|
||||
|
||||
create trigger tg_pfield_au after update
|
||||
on PField for each row execute procedure tg_pfield_au();
|
||||
</code>
|
||||
Another trigger example sample code:
|
||||
<code>
|
||||
create trigger check_fkeys_pkey_exist
|
||||
before insert or update on fkeys
|
||||
for each row
|
||||
execute procedure
|
||||
check_primary_key ('fkey1', 'fkey2', 'pkeys', 'pkey1', 'pkey2');
|
||||
</code>
|
||||
|
||||
You must also install the TEST package - postgresql-test-7.0.2-2.rpm
|
||||
and read the example sql scripts at - /usr/lib/pgsql/test/regress/sql
|
||||
|
||||
To see the list of triggers in database do -
|
||||
<code>
|
||||
bash$ psql mydb
|
||||
psql=> \?
|
||||
psql=> \dS
|
||||
psql=> \d pg_trigger
|
||||
psql=> select tgname from pg_trigger order by tgname;
|
||||
</code>
|
||||
|
||||
To see the list of functions and stored procedures in database do -
|
||||
<code>
|
||||
bash$ psql mydb
|
||||
psql=> \?
|
||||
psql=> \dS
|
||||
psql=> \d pg_proc
|
||||
psql=> select proname, prosrc from pg_proc order by proname;
|
||||
psql=> \df
|
||||
</code>
|
||||
<!--
|
||||
|
||||
|
||||
*******************************************
|
||||
************ End of Section ***************
|
||||
*******************************************
|
||||
|
@ -2400,8 +2471,30 @@ containing load libpgtcl.so and to load pgaccess.tcl not with wish, but
|
|||
with pgwish (or wishpg) that wish that was linked with libpgtcl library.
|
||||
|
||||
If you get crypt not found during compilation pgaccess source tree then use -lcrypt.
|
||||
|
||||
<!--
|
||||
|
||||
*******************************************
|
||||
************ End of Section ***************
|
||||
*******************************************
|
||||
-->
|
||||
<sect1>GtkSQL Graphical Query Tool for PostgreSQL
|
||||
<p>
|
||||
GtkSQL is a graphical query tool (like PostgreSQL's psql). It is
|
||||
released under the GNU GPL license, and was developped
|
||||
using Gtk+ 1.2.3 and PostgreSQL 6.3.
|
||||
The main site of GtkSQL is at <url url="http://gtksql.sourceforge.net">
|
||||
|
||||
Its main features are :
|
||||
<enum>
|
||||
<item> multiple SQL buffers
|
||||
<item> SQL keywords, table names and fields autocompletion
|
||||
<item> easy displaying of table definition
|
||||
<item> PostgreSQL and MySQL support (and easy addition of other databases)
|
||||
</enum>
|
||||
The current version is GtkSQL v. 0.3. You can get the source from
|
||||
<url url="https://sourceforge.net/project/?form_grp=533">
|
||||
<!--
|
||||
|
||||
*******************************************
|
||||
************ End of Section ***************
|
||||
*******************************************
|
||||
|
@ -3742,6 +3835,27 @@ It is at
|
|||
name="linus@epact.se">
|
||||
</itemize>
|
||||
See the section - <ref id="Testing ecpg" name="Testing Embedded SQL/C interface to PostgreSQL">
|
||||
|
||||
To use Vim color editor to edit 'ecpg' files (*.pgc), you must do the following:-
|
||||
<code>
|
||||
bash$ su - postgres
|
||||
bash$ mkdir $HOME/vim
|
||||
And create a file '$HOME/vim/myfilestypes.vim' which has these lines
|
||||
|
||||
" myfiletypefile
|
||||
au! BufRead,BufNewFile *.pgc set filetype=esqlc
|
||||
</code>
|
||||
You should have $HOME/.gvimrc file. If not create one, refer to Vim howto doc at
|
||||
<url url="http://metalab.unc.edu/LDP/HOWTO/Vim-HOWTO.html">
|
||||
Put the following line in $HOME/.gvimrc file
|
||||
<code>
|
||||
let myfiletypefile = "~/vim/myfiletypes.vim"
|
||||
</code>
|
||||
Now, if you edit with
|
||||
<code>
|
||||
bash$ gvim sample.pgc
|
||||
</code>
|
||||
you will get the color syntax highlighted.
|
||||
<!--
|
||||
*******************************************
|
||||
************ End of Section ***************
|
||||
|
|
Loading…
Reference in New Issue