|
||||||
Database-SQL-RDBMS HOW-TO document for Linux (PostgreSQL Object Relational Database System)Al Dev (Alavoor Vasudevan) alavoor@yahoo.comv45.0, 27 Jan 2001This document is a "practical guide" to very quickly setup a SQL Database engine and front end tools on an Unix system. It also discusses the International standard language ANSI/ISO SQL and reviews the merits/advantages of the SQL database engine developed by the world-wide internet in an "open development" environment. It is about HOW-TO setup a next generation Object Relational SQL Database "PostgreSQL" on Unix system which can be used as an Application Database Server or as a Web Database Server. PostgreSQL attempts to implement current and future International ISO/ANSI SQL standards. This document also gives information on the database interface programs like Front End GUIs, RAD tools (Rapid Application Development), ODBC, JDBC drivers, "C", "C++", Java, Perl programming interfaces and Web Database Tools. Information given here applies to all Unix/Windows NT platforms and to all other SQL databases. It will be very useful for people who are new to Databases, SQL language and PostgreSQL. This document also has SQL tutorial, SQL syntax which would be very helpful for beginners. Experienced people will find this document as an useful reference guide. For students, the information given here will enable them to get the source code for PostgreSQL relational database system, from which they can learn as to how a RDBMS SQL database engine is created.
1. Introduction
2. Laws of Physics apply to Software!
3. What is PostgreSQL ?
4. Which one? PostgreSQL or MySQL ?
5. Where to get it ?
6. PostgreSQL Quick-Installation Instructions
7. Quick Start Guide
8. Performance Tuning of PostgreSQL server
9. PostgreSQL Supports Extremely Large Databases greater than 200 Gig
10. How can I trust PostgreSQL ? Regression Test Package builds customer confidence
11. Security of Database
12. GUI FrontEnd Tool for PostgreSQL (Graphical User Interface)
13. Interface Drivers for PostgreSQL
14. Perl Database Interface (DBI) Driver for PostgreSQL
15. PostgreSQL Management Tools
16. CPUs for PostgreSQL
17. Setting up multi-boxes PostgreSQL with just one monitor
18. Web-Application-Servers for PostgreSQL
19. Applications and Tools for PostgreSQL
20. Database Design Tool - Entity Relation Diagram Tool
21. Web Database Design/Implementation tool for PostgreSQL - EARP
22. PHP Hypertext Preprocessor - Server-side html-embedded scripting language for PostgreSQL
23. Python Interface for PostgreSQL
24. Gateway between PostgreSQL and the WWW - WDB-P95
25. "C", "C++", ESQL/C language Interfaces and Bitwise Operators for PostgreSQL
26. Japanese Kanji Code for PostgreSQL
27. PostgreSQL Port to Windows 95/Windows NT
28. Mailing Lists
29. Documentation and Reference Books
30. Technical support for PostgreSQL
31. Economic and Business Aspects
32. List of Other Databases
33. Internet World Wide Web Searching Tips
34. Conclusion
35. FAQ - Questions on PostgreSQL
36. Other Formats of this Document
37. Copyright and LicenseAppendix
38. Appendix A - Syntax of ANSI/ISO SQL 1992
39. Appendix B - SQL Tutorial for beginners
40. Appendix C - Linux Quick Install Instructions
41. Appendix C - Midgard Installation1. IntroductionThe purpose of this document is to provide comprehensive list of pointers/URLs to quickly setup PostgreSQL and also to advocate the benefits of Open Source Code system like PostgreSQL, Linux. PostgreSQL is pronounced as Post-gres-cue-el (Postgres-QL) and not Postgre-es-cue-el. Each and every computer system in the world needs a database to store/retrieve the information. The primary reason you use the computer is to store, retrieve and process information and do all these very quickly, thereby saving you time. At the same time, the system must be simple, robust, fast, reliable, economical and very easy to use. Database is the most VITAL SYSTEM as it stores mission critical information of every company in this world. Each and every industry in this world needs a database system. Industries like telecom, automobile, banks, airlines, etc.. will not function efficiently without a database system. The most popular database systems are based on the International Standard Organisation (ISO) SQL specifications and ANSI SQL (American) standards. The current specifications widely used in the industry are ISO/ANSI SQL 1992. Upcoming standard is the SQL 1998/99 which is also called SQL-3 is still under development. Popular database like Oracle, Sybase and Informix systems are based on these standards or are trying to implement these standards. Without a standard like ANSI/ISO SQL, it would be very difficult for the customer to develop an application once and run on all the database systems. End user wants to develop an application ONCE using ISO SQL, ODBC, JDBC and deploy on all variety of database systems in the world. The world's most popular FREE Database which implements some of the ISO SQL, ANSI SQL/98, SQL/92 and ANSI SQL/89 RDBMS is PostgreSQL. PostgreSQL is next generation Object relational database and is targeting on full compliance of SQL standards like ISO/ANSI SQL. PostgreSQL is the only free RDBMS in the world which supports Object databases and SQL. This document will tell you how-to install the database, how to set up the Web database, application database, front end GUIs and interface programs. It is strongly advised that you MUST write your database applications 100 % compliant to standards of ISO/ANSI SQL, ODBC, JDBC so that your application is portable across multiple databases like PostgreSQL, Oracle, Sybase, Informix etc. You get the highest quality, and lot many features with PostgreSQL as it follows 'Open Source Code development model'. Open Source Code model is the one where the complete source code is given to you and the development takes place on the internet by an extremely vast network of human brains. Future trend shows that most of the software development will take place on the so called "Information Super-Highway" which spans the whole globe. In the coming years, internet growth will be explosive which will further fuel rapid adoption of PostgreSQL by the industry. By applying the principles of statistics, mathematics and science to software quality, you get the best quality of software only in a 'Open Source Code System' like PostgreSQL, wherein the source code is open to a very vast number of human brains inter-connected by the information super-highway. Greater the number of human brains working, the better will be the quality of software. Open Source Code model will also prevent RE-INVENTION OF WHEELS, eliminates DUPLICATION OF WORK and will be very economical, saves time in distribution and follows the modern economic laws of optimizing the national and global resources. Once a software work is done by others, then you DO NOT need to re-do that again. You will not be wasting your valuable time on something which had already been WELL DONE. Your time is extremely precious and it must be utilized efficiently, because you have only 8 hours a day for doing work. As we will be entering the 21st century, there will be a change in the way that you get software for your use. Everybody will give first preference for the open source softwares like PostgreSQL, Linux. If you buy binaries, you will not get any equity and ownership of source code. Source code is a very valuable asset and binaries have no value. Buying software may become a thing of the past. You only need to buy good hardware, it is worth spending money on the hardware and get the software from internet. Important point is that it is the computer hardware which is doing bulk of the work. Hardware is the real work horse and software is just driving it. Computer hardware is so much more complex that only 6 nations in the world so far have demonstrated the capability of designing and manufacturing computer chips/hardware. Design and manufacturing of computer chips is an advanced technology. It is a very complex process, capital intensive, requires large investments in plant and production machines which deal with 0.18 micron (even smaller than 0.18) technology. On a single small silicon chip millions of transistors/circuits are densely packed. Companies like Applied Material, AMD, Intel, Cyrix, Hitachi, IBM and others spent significant number of man-years to master the high-technology like Chip Design, Micro-electronics and Nano-electronics. Micro means (one-millionth of meter 10^-6), Nano means (one-billionth of meter 10^-9). Current technology uses micro-electronics of about 0.35 micron using aluminum as conductors and 0.25 micron sizes using copper as conductors of electrons. In near future the technology of 0.10 micron with copper and even nano-electronics will be used to make computer chips. Aluminum conductors will be phased out by copper on computer chips, as copper is a better conductor of electrons. In photolithography process extreme ultraviolet, X-ray or electron-beam techniques will be used to etch circuits for feature size less than 0.15 micron. In about 20 years from now, silicon chips will be phased out by molecular computers and bio chips which will be billions of times faster than silicon chips. Molecules are a group of atoms. And atoms are tiny particles which makes up everything that you see in this world. Molecular computers will use the molecules of matter as ultra-fast electronic on/off switches. When the switch is ON it indicates 1, and when it is OFF it indicates 0. All the computer programs in this world are based on binary (numbers 1 and 0). Table below shows the progress and future advancement trends of computer chips.
As you can see, it is hardware that is high technology
and important and software is labor intensive but is a less difficult technology.
On other hand, each and every country in the world develops/makes software. In fact, any person in this world with a small low-cost PC can write software. Databases like Oracle, Informix, Sybase, IBM DB2 (Unix) are written using the "C" language and binaries are created by compiling the source code and then they are shipped out to customers. Oracle, Sybase, Informix databases are 100 % "C" programs!!
Since a lot of work had been done on PostgreSQL for the past 14 years, it does not make sense to re-create from scratch another database system which satisfies ANSI/ISO SQL. It will be a great advantage to take the existing code and add missing features or enhancements to PostgreSQL and start using it immediately. Prediction is that demand for "Internet products" like PostgreSQL will grow exponentially as it is capable of maintaining a high quality, low cost, extremely large user-base and developer-base. Those nations which do not use the 'Internet products' will be seriously missing "World-wide Internet Revolution" and will be left far behind other countries. The reason is "Internet" itself is the world's LARGEST "software company" and is a large software "power house"! 1.1 Quantum Computers - Quantum Physics Useful !!As you can see from above table "Advancement of chip capabilities in future" in the years after 2030, database systems like PostgreSQL will be running on Quantum Computers. Quantum Computers rely on an atomic particle's traits, such as direction of spin, for creating a state. For example, when the spin is up, a particle could be read as "one", when its spin is down, the particle would be read as "zero". Atoms and nuclei can exist in a state of superposition, where the values of one, zero and the range in between can be represented concurrently. By entangling the spins of atoms, "qubits" can become wired together, enabling them to function as a collective whole, bringing about a nonlinear computational power that far surpasses the capabilities of supercomputers available today!! At atomic level Quantum Physics comes to assistance to better understand the behaviour of atomic particles. 2. Laws of Physics apply to Software!In this chapter, it will be shown how science plays an important role in the creation of various objects like software, this universe, mass, atoms, energy and even yourself! This chapter also shows why knowledge of science is very important before you start using the products of science. The golden rule is - "You MUST not use a product without understanding how it is created!!" This rule applies to everything - database sytems, computer system, operating system, this universe and even your own human body! It means that you should have complete source code and information about the system. It is important to understand how human body and atoms inside human body works since humans are creating PostgreSQL, MS Windows95 etc.. Creation is a very important step. Persons who are using the objects of science must know how it is created. This applies to even computer systems and PostgreSQL. A majority of people do not have knowledge of science and hence do not know how systems like MS Windows NT/95, Oracle, human body and this universe are created. A vast majority of people do not know what made the universe and MS Windows 95/NT and what is inside it. Complex systems are built from very simple basic building blocks like - millions of universes are created, each universe in turn has millions of super-clusters, each super-cluster has millions of galaxies, each galaxy has millions of stars, some stars have many planets, each planet in turn is made up billions of atoms.(In the history of this world, only one universe was created by a man in ancient India eons ago, but no other case had been reported in the modern history. There is only one man-made universe) Creating an universe is a much more advanced technology and is more advanced than the atomic bomb which was dropped on Hiroshima and Nagasaki causing horrible destruction. Modern nuclear weapons are so tiny and powerful that if such a single nuclear bomb is dropped in pacific ocean then it can completely vaporise the planet earth! The total variety of weapons are infinity. There are weapons to even terminate the universes (it is not a good idea to give nuke weapons technology to every person). Nuclear weapons and other more powerful divine weapons were used in the battle field in ancient India! Nobody believed Albert Eienstein (a scientist of 1900's) when he said nuclear weapons can be made which can vaporise big cities. Software like MS Windows 95 is created simply by "C" and assembler language programs which simply uses 1 and 0 and universes like ours are created simply by dashing TWO dissimilar but proper of combination of tiny atomic particles of other dimensions. (Something interesting happened just before dashing of tiny particles) A human body is created by dashing two dissimilar but proper combination of tiny cells!! (Something interesting happened just before dashing of tiny cells) Humans inherited the properties of this universe. The universe you are currently living in was NOT there - all the atoms inside the universe was not there and not even TIME was existing!! Baby universe was born during big bang and started expanding and kept growing. Even today our universe is still expanding and is not static!! A person from another universe by name 'Brahma' created this universe you are currently living in. Knowledge is the MOTHER of this universe!! 'Brahma' loved on 'Mother knowledge' before the baby universe in which you are living was born!! It is a deal similar to how you were born! Without any 'genes' from Mother Knowledge it is not possible create even a small "C" program! At some point our universe will close down (in a big crunch) and all the atoms inside the universe will completely vanish and dissappear! All the atoms that you see inside this universe will be gone! Total number of universes that can be created is INFINITY and similarly total number of operating systems that can be created is also infinity!! It is infinite cyclic process where universes are born and then later die down. There are millions of universes, which are classified into 3 major categories. Infinite number universes and infinite variety of multi-dimensional atoms collapse down into few primary-dimensional-universe. And primary-dimensional universes collapse down into one single focus entity called 'eeshwar' (eeshara is a sanskrit word). Very advanced mathematical equations support this theory. The laws of science and statistics favour the open-source code system like PostgreSQL and Linux. As the internet speed is increasing everyday, and internet is becoming more and MORE reliable, the open-source code system will gain very rapid momentum. And, if rules of statistics and laws of physics are correct, awareness of science grows and when IGNORANT people start learning science then the closed source-code systems will eventually vanish from this planet. Developing a project like PostgreSQL requires resources like energy and time, hence PostgreSQL is a product of energy and time. Since energy and time can be explained only by science, there is a direct co-relation between physics and software projects like PostgreSQL, Linux. Laws of science (Physics) applies everywhere and at all the times, to anything that you do, even while you are developing the software projects. Physics is in action even while you are talking (sound waves), walking (friction between ground and your feet), reading a book or writing software. Every science in this world has a deep root in mathematics, including PostgreSQL. PostgreSQL uses 'Modern Algebra' which is a tiny branch of mathematics. Modern algebra deals with 'Set Theory', 'Relational Algebra', science of Groups, Rings, Collections, Sets, Unions, Intersections, Exclusions, Domains, Lists, etc... The software like PostgreSQL is existing today because of the energy and time. And mass and energy are ONE and the SAME entity. There are infinite number of methods to unlock mass and convert it into enery. Mass is a highly concentrated energy. The fact that mass and energy are same was unknown to people 100 years ago! And even today it is unknown to world population that internet is the largest software "power house" and the largest "software company" in the world! Cells in the human brains consume energy while processing (creating software), by converting the chemical energy from food into electrical and heat energy. Even while you are reading this paragraph, the cells in your brain are burning out the fuel and are using tiny amounts of energy. All of these implies that human brain is a thermodynamic heat engine. Because human brain is a thermodynamic engine, the laws of thermodynamics applies to brain and hence thermodynamics has indirect effects on software like PostgreSQL. There can be infinite number of colors, computer langauages, computer chip designs and theories but there CANNOT be ONE SINGLE PERFECT color, computer language, design or system! What you can have is only a NEAR PERFECT color(wavelength), system, database, or theory! Nature is like a KALIEDOSCOPE - there are infinite number of dimensions, infinite variety particles of other dimensions but they all combine into very few primary dimensions and vice-versa. By combining the energies of millions of people around the world via internet it is possible to achieve a NEAR PERFECT system (including a database software system). Individually, the energy of each person will be minute, but by networking a large number of people, the total energy will be huge which can be focused on a project to generate a near perfect system. The energy is measured in Joules, kiloJoules or kilograms of mass, and time is measured in seconds or hours. And power is energy divided by time and is measured in Watts or kiloWatts . Energy of each person = y Joules or in terms of mass Energy of each person = y grams The conversion factor between mass and energy is E = m * c * c where 'c' is the speed of light and 'm' is the mass. Time = 8 hours (This is constant since each person has only 8 hours a day) Power = Energy / Time = (y / (8 * 60 * 60) ) Watts Total Power of the world = n * (y / (8 * 60 * 60) ) Watts where n = number of persons working on the project. From the above equation it is clear that increasing the 'n' will greatly improve the quality of product. Greater the 'n' then greater will be the power (in KiloWatts). You can wonder how much total energy (in KiloJoules) and total power (in KiloWatts) the global internet can focus on a system like Linux and PostgreSQL! It is very clear that internet can network a vast number of people, which implies internet has a lot of energy and time which can produce much higher quality software products in much shorter time as compared to commercial companies. Even very big companies like Microsoft and IBM cannot overpower and overrule the laws of Physics but will eventually SURRENDER UNTO laws of science! Conclusion is - because of laws of science, 'open source code' system like PostgreSQL, Linux will prevail and will be always much better than 'closed source code' system and it is possible to prove this statement scientifically. Man should not waste time creating too many duplicate software products. 3. What is PostgreSQL ?PostgreSQL is a free database, complete source code is given to you and is an Object-Relational Database System targetting on ANSI ISO/SQL 1998, 92 and runs on diverse hardware platforms and Operating systems. The ultimate objective and the final goal of PostgreSQL is to become 100 % compliant to ANSI/ISO SQL and also to become the number ONE open generic Database in the world. PostgreSQL is pronounced as Post-gres-cue-el (Postgres-QL) and not Postgre-es-cue-el. Today, PostgreSQL is the most advanced system in the world and it is surprising that many commercial database systems could not match the quality, features and capabilities of PostgreSQL !! PostgreSQL is the joint effort of many nations around the globe and is a project similar to International Space Station. PostgreSQL will remain the number one database system for many decades into future since it is an open-source code system. The fundamental idea behind PostgreSQL is - once a module of code is written than you should not waste even a milli-second of your time trying to re-invent it!! Informix Universal server (released 1997) is based on earlier version of PostgreSQL because Informix bought Illustra Inc. and integrated with Informix. Illustra database was based on Postgres (earlier version of PostgreSQL). PostgreSQL is an enhancement of the POSTGRES database management system, a next-generation DBMS research prototype. While PostgreSQL retains the powerful data model and rich data types of POSTGRES, it replaces the PostQuel query language with an extended subset of SQL.
PostgreSQL development is being performed by a team of Internet developers who all subscribe to the PostgreSQL development mailing list. The current coordinator is Marc G. Fournier This team is now responsible for all current and future development of PostgreSQL. Ofcourse, the database customer himself is the developer of PostgreSQL! The development load is distributed among a very large number of database end-users on internet.The authors of PostgreSQL 1.01 were Andrew Yu and Jolly Chen. The original Postgres code, from which PostgreSQL is derived, was the effort of many graduate students, undergraduate students, and staff programmers and working under the direction of Professor Michael Stonebraker at the University of California, Berkeley. Millions of PostgreSQL is installed as Database servers, Web database servers and Application data servers. It is very sophisticated object relational database system (ORDBMS). PostgreSQL runs on Solaris, SunOS, HPUX, AIX, Linux, Irix, Digital Unix, BSDi,NetBSD, FreeBSD, SCO unix, NEXTSTEP, Unixware and all and every flavor of Unix. Port to Windows NT is done using Cygnus cygwin32 package. PostgreSQL and related items in this document are subject to the COPYRIGHT from University of California, Berkeley. 3.1 White PaperPostgreSQL details in nutshell:
PostgreSQL is pronounced as Post-gres-cue-el (Postgres-QL) and not Postgre-es-cue-el. 4. Which one? PostgreSQL or MySQL ?
4.1 PostgreSQL defeated Oracle, IBM DB2, MS SQL server and others!!PostgreSQL defeated Oracle 8 (and 8i), IBM DB2, MS SQL server, Sybase, Interbase and MySQL in standard benchmark tests in performance, speed, scalability and reliability! Read the benchmarks at http://www.aldev.8m.com or at http://aldev.webjump.com 4.2 MySQL and other duplicate RDBMSesMySQL is another open-source SQL server, but it does not support transactions. It is suitable for very small databases and does not support advanced SQL functionalities. Whereas PostgreSQL is an enterprise strength database supporting transactions and almost all SQL constructs. PostgreSQL is much more advanced than commercial databases like Oracle, Sybase and Informix. PostgreSQL supports very advanced locking mechanisms and many more advanced features which are not available in commercial database systems!! In near future development of MySQL will be dropped, since MySQL is duplicate product working towards ANSI SQL. We would take the most advanced and mature open-source SQL server and drop all others as we do not have lots of time (to deal with multiple RDBMSes)!! In fact, you do not have time to deal with just one powerful SQL server like PostgreSQL! And all the MySQL users will be migrated to PostgreSQL. Also MySQL is a 'quasi-commercial' product unlike PostgreSQL which is open-source and there is no license fee. There is no need for another SQL database system as PostgreSQL is already here in this world!! Duplicate products like MySQL confuse the user base and causes division of resources. For a "NEAR PERFECT" system there must be only one system and everybody in the world must work on it!! Duplicate products cause more harm than good and hence division of resources must be strongly discouraged. This already happened in case of commercial database systems like Oracle, Sybase, Informix and MS SQL server which caused splintering of user base and often they are incompatible. I want put the source code of SQL server under your control!!! You do not need hundreds of database systems, all you need is just one best database server which happens to be 'PostgreSQL'. WARNING: It is possible to create infinite number of database systems for a given specification like ANSI SQL!! Features which are missing in MySQL and which PostgreSQL supports are -
MySQL is at http://www.tcx.se 4.3 Limitations of MySQLPostgreSQL should be compared with systems like Oracle, both are really true ACID compliant robust systems developed over a very long time. It is very much wrong to compare MySQL with Oracle or MySQL with PostgreSQL. For more details read Why Not MySQL. Hence, it will be a very serious mistake to replace Oracle with MySQL!! If you want to replace Oracle then consider PostgreSQL. 5. Where to get it ?You can buy Redhat Linux CDROM, Debian Linux CDROM or Slackware Linux CDROM which already contains the PostgreSQL in package form (both source code and binaries) from :
PostgreSQL organisation is also selling 'PostgreSQL CDROM' which contains the complete source code and binaries for many Unix operating systems as well as full documentation.
Binaries only distribution of PostgreSQL:
WWW Web sites:
The ftp sites are listed below :-
PostgreSQL source code is also available at all the mirror sites of sunsite unc (total of about 1000 sites around the globe). It is inside the Red Hat Linux distribution in /pub/contrib/i386/postgresql.rpm file.
6. PostgreSQL Quick-Installation InstructionsPostgreSQL is pronounced as Post-gres-cue-el (Postgres-QL) and not Postgre-es-cue-el. This chapter will help you to install and run the database very quickly in less than 5 minutes.
6.1 Install and TestQuick Steps to Install, Test, Verify and run PostgreSQL Login as root. # cd /mnt/cdrom/RedHat/RPMS # man rpm # ls postgre*.rpm # rpm -qpl postgre*.rpm | less (to see list of files) # rpm -qpi postgre*.rpm (to see info of package) # cat /etc/passwd | grep postgres Note: If you see a 'postgres' user, you may need to backup and clean up the postgres home directory postgres and delete the unix user 'postgres' or rename the unix user 'postgres' to something like 'postgres2'. Install must be "clean slate" # rpm -i postgre*.rpm (Must install all packages clients, devel, data and main for pgaccess to work ) # man chkconfig # chkconfig --add postgresql (to start pg during booting) # /etc/rc.d/init.d/postgresql start (to start up postgres) # man xhost # xhost + (To give display access for pgaccess) # su - postgres bash$ man createdb bash$ createdb mydatabase bash$ man psql bash$ psql mydatabase ..... in psql press up/down arrow keys for history line editing or \s bash$ export DISPLAY=<hostname>:0.0 bash$ man pgaccess bash$ pgaccess mydatabase Now you can start rapidly BANGING away SQL commands at psql or pgaccess. bash$ cd /usr/doc/postgresql* Here read all the FAQs, User, Programmer, Admin guides and tutorials. 6.2 PostgreSQL RPMsSee also "Installation Steps" from http://www.ramifordistat.net/postgres The maintainer of PostgreSQL RPMs is Lamar Owen and is at lamar.owen@wgcr.org More details about PostgreSQL is at http://www.postgresql.org 6.3 Maximum RPMFamiliarize with RedHat RPM package manager to manage the PostgreSQL installations. Download the 'Maximum RPM' textbook from http://www.RPM.org look for the filename maximum-rpm.ps.gz And read it on linux using the gv command - # gv maximum-rpm.ps.gz There is also rpm2deb which converts the RPM packages to Debian linux packages. 6.4 Examples RPMExamples are needed to do testing of various interfaces to PostgreSQL. Install the postgresql examples directory from -
6.5 Testing PyGreSQL - Python interfaceInstall examples package, see Examples RPM and then do - bash$ cd /usr/lib/pgsql/python bash$ createdb thilo bash$ psql thilo thilo=> create table test (aa char(30), bb char(30) ); thilo=> \q bash$ /usr/bin/python >>> import _pg >>> db = _pg.connect('thilo', 'localhost') >>> db.query("INSERT INTO test VALUES ('ping', 'pong')") >>> db.query("SELECT * FROM test") eins|zwei ----+---- ping|pong (1 row) >>>CTRL+D bash$ ..... Seems to work - now install it properly bash$ su - root # cp /usr/lib/pgsql/python/_pg.so /usr/lib/python1.5/lib-dynload 6.6 Testing Perl - Perl interfaceInstall examples package, see Examples RPM and then do - root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/perl5 bash$ perl ./example.pl Note: If the above command does not work then do this. Gloabl var @INC should include the Pg.pm module in directory site_perl hence use -I option below bash$ perl -I/usr/lib/perl5/site_perl/5.005/i386-linux-thread ./example.pl .... You ran the perl which is accessing PostgreSQL database!! Read the example.pl file for using perl interface. 6.7 Testing libpq, libpq++ interfacesInstall examples package, see Examples RPM and then do - root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/libpq bash$ gcc testlibpq.c -I/usr/include/pgsql -lpq bash$ export PATH=$PATH:. bash$ a.out bash$ cd /var/lib/pgsql/examples/libpq++ bash$ g++ testlibpq0.cc -I/usr/include/pgsql -I/usr/include/pgsql/libpq++ -lpq++ -lpq -lcrypt bash$ ./a.out (Note: Ignore Error messages if you get any - as below) > create table foo (aa int, bb char(4)); No tuples returned... status = 1 Error returned: fe_setauthsvc: invalid name: , ignoring... > insert into foo values ('4535', 'vasu'); No tuples returned... status = 1 Error returned: fe_setauthsvc: invalid name: , ignoring... > select * from foo; aa |bb | -----|-----| 4535 |vasu | Query returned 1 row. > >CTRL+D bash$ .... You ran direct C/C++ interfaces to PostgreSQL database!! 6.8 Testing Java interfacesInstall examples package, see Examples RPM and also install the following -
root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/jdbc bash$ echo $CLASSPATH --> Should show CLASSPATH=/usr/lib/pgsql/jdbc7.0-1.2.jar:.:/home/java/jdk1.2.2/lib:/usr/lib/pgsql:/usr/lib/pgsql/classes.zip:/usr/lib/pgsql/pg.jar with proper jdbc*.jar version numbers. And the directories /usr/lib/pgsql and /usr/libjdk*/lib should contain *.jar files. bash$ export CLASSPATH=/usr/lib/pgsql/jdbc7.0-1.2.jar:.:/home/java/jdk1.2.2/lib:/usr/lib/pgsql:/usr/lib/pgsql/classes.zip:/usr/lib/pgsql/pg.jar Edit all psql.java file and comment out the 'package' line. bash$ javac psql.java bash$ java psql jdbc:postgresql:template1 postgres < password > [1] select * from pg_tables; tablename tableowner hasindexes hasrules pg_type postgres true false false pg_attribute postgres true false false [2] CTRL+C bash$ .... You ran direct Java interfaces to PostgreSQL database! 6.9 Testing ecpg interfacesInstall examples package, see Examples RPM and then do - root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/ecpg bash$ ecpg test1.pgc -I/usr/include/pgsql bash$ cc test1.c -I/usr/include/pgsql -lecpg -lpq -lcrypt bash$ createdb mm bash$ ./a.out .... You ran Embedded "C"-SQL to PostgreSQL database! 6.10 Testing SQL examples - User defined types and functionsInstall examples package, see Examples RPM and then do - root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/sql Under-development.. 6.11 Testing Tcl/Tk interfacesExample of Tcl/Tk interfaces is pgaccess program. Read the file /usr/bin/pgaccess using an editor - bash$ view /usr/bin/pgaccess bash$ export DISPLAY=<hostname of your machine>:0.0 bash$ createdb mydb bash$ pgaccess mydb 6.12 Testing ODBC interfaces
6.13 Testing MPSQL Motif-worksheet interfacesGet the RPMs from http://www.mutinybaysoftware.com 6.14 VerificationTo verify the top quality of PostgreSQL, run the Regression test package :- Login as root - # rpm -i postgresql*test.rpm And see README file or install the source code tree which has regress directory # rpm -i postgresql*.src.rpm # cd /usr/src/redhat/SPECS # more postgresql*.spec (to see what system RPM packages you need to install) # rpm -bp postgresql*.spec (.. this will prep the package) Regression test needs the Makefiles and some header files like *fmgr*.h which can be built by - # rpm --short-circuit -bc postgresql*.spec ( .. use short circuit to bypass!) Abort the build by CTRL+C, when you see 'make -C common SUBSYS.o' By this time configure is successful and all makefiles and headers are created. You do not need to proceed any further # cd /usr/src/redhat/BUILD # chown -R postgres postgresql* # su - postgres bash$ cd /usr/src/redhat/BUILD/postgresql-6.5.3/src/test/regress bash$ more README bash$ make clean; make all runtest bash$ more regress.out 6.15 Emergency Bug fixesSometimes emergency bug fix patches are released after the GA release of PostgreSQL. You can apply these optional patches depending upon the needs of your application. Follow these steps to apply the patches - Change directory to postgresql source directory
The patch files are located in
7. Quick Start GuideRefer also to Quick Installation chapter. 7.1 Creating, Dropping, Renaming DatabaseYou can use the user friendly GUI called 'pgaccess' to create and drop databases, or you can use the command line 'psql' utility. If you are logged in as root, switch user to 'postgres' : # xhost + (To give display access for pgaccess) # su - postgres bash$ man createdb bash$ createdb mydatabase bash$ man psql bash$ psql mydatabase ..... in psql press up/down arrow keys for history line editing or \s bash$ export DISPLAY=<hostname>:0.0 bash$ man pgaccess bash$ pgaccess mydatabase Now you can start rapidly BANGING away SQL commands at psql or pgaccess !! To drop the database do : bash$ man dropdb bash$ man destroydb (for older versions of pgsql) bash$ dropdb <dbname> It is also possible to destroy a database from within an SQL session by using: > drop database <dbname> To rename a database see Backup and Restore 7.2 Creating, Dropping usersTo create new users, login as unix user 'postgres'. You can use user friendly GUI tool called 'pgacess' to create, drop users. bash$ man pgaccess bash$ pgaccess <database_name> and click on "Users" tab and then click Object|New or Object|Delete You can also use command line scripts. Use the shell script called 'createuser' which invokes psql bash$ man createuser bash$ createuser <username> bash$ createuser -h host -p port -i userid <username> To drop a postgres user, use shell script 'destroyuser' - bash$ man dropuser bash$ man destroyuser (older versions of pgsql) bash$ destroyuser 7.3 Creating, Dropping GroupsCurrently, there is no easy interface to set up user groups. You have to explicitly insert/update the pg_group table. For example: bash$ su - postgres bash$ psql <database_name> ..... in psql press up/down arrow keys for history line editing or \s psql=> insert into pg_group (groname, grosysid, grolist) psql=> values ('posthackers', '1234', '{5443, 8261}' ); INSERT 58224 psql=> grant insert on foo to group posthackers; CHANGE psql=> The fields in pg_group are: groname The group name. This name should be purely alphanumeric; do not include underscores or other punctuation. grosysid The group id. This is an int4, and should be unique for each group. grolist The list of pg_user IDs that belong in the group. This is an int4[]. To drop the group: bash$ su - postgres bash$ psql <database_name> ..... in psql press up/down arrow keys for history line editing or \s psql=> delete from pg_group where groname = 'posthackers'; 7.4 Create, Edit, Drop a tableYou can use user friendly GUI tool 'pgaccess' or command line tool 'psql' to create, edit or drop a table in a database. bash$ man pgaccess bash$ pgaccess <database_name> Click on Table | New | Design buttons. bash$ man psql bash$ psql <database_name> ..... in psql press up/down arrow keys for history line editing or \s At psql prompt, give standard SQL statements like 'create table', 'alter table' or 'drop table' to manipulate the tables. 7.5 Create, Edit, Drop records in a tableYou can use user friendly GUI tool 'pgaccess' or command line tool 'psql' to create, edit or drop records in a database table. bash$ man pgaccess bash$ pgaccess <database_name> Click on Table | < pick a table > | Open buttons. bash$ man psql bash$ psql <database_name> ..... in psql press up/down arrow keys for history line editing or \s At psql prompt, give standard SQL statements like 'insert into table_name', 'update table_name' or 'delete from table_name' to manipulate the tables. 7.6 Switch active DatabaseYou can use user friendly GUI tool 'pgaccess' or command line tool 'psql' to switch active database. bash$ man pgaccess bash$ pgaccess <database_name> Click on Database | Open buttons. bash$ man psql bash$ psql <database_name> ..... in psql press up/down arrow keys for history line editing or \s psql=> connect <database_name> <user> 7.7 Backup and Restore databasePostgreSQL provides two utilities to back up your system: pg_dump to backup individual databases, and pg_dumpall to back up all the databases in just one step. bash$ su - postgres bash$ man pd_dump bash$ pd_dump <database_name> > database_name.pgdump To dump all databases - bash$ man pg_dumpall bash$ pg_dumpall -o > db_all.out To reload (restore) a database dumped with pg_dump: bash$ cat database_name.pgdump | psql <database_name> To reload (restore) all databases dumped with pg_dumpall: bash$ psql -e template1 < db_all.out This technique can be used to move databases to new locations, and to rename existing databases. WARNING: Every database should be backed up on a regular basis. Since PostgreSQL manages its own files in the file sysetem, it is not advisable to rely on system backups of your file system for your database backups; there is no guarantee that the files will be in an usable, consistent state after restoration. BACKUP LARGE DATABASES: Since Postgres allows tables larger than the maximum file size on your system, it can be problematic to dump the table to a file, because the resulting file likely will be larger than the maximum size allowed by your system. As pg_dump writes to stdout, you can just use standard unix tools to work around this possible problem - use compressed dumps. bash$ pg_dump <database_name> | gzip > filename.dump.gz Reload with : bash$ createdb <database_name> bash$ gunzip -c filename.dump.gz | psql <database_name> Or bash$ cat filename.dump.gz | gunzip | psql <database_name> Use split: bash$ pg_dump <database_name> | split -b 1m - filename.dump. Note: There is a dot (.) after filename.dump in the above command!! You can reload with: bash$ man createdb bash$ createdb <database_name> bash$ cat filename.dump.* | pgsql <database_name> Of course, the name of the file (filename) and the content of the pg_dump output need not match the name of the database. Also, the restored database can have an arbitrary new name, so this mechanism is also suitable for renaming databases. Backup LARGE Objects: Large objects are not handled by pg_dump. The directory contrib/pg_dumplo of the Postgres source tree contains a program that can do that. FILESYSTEM BACKUP : You can use the linux OS tools and commands to backup the entire database. But you must completely shutdown the postgresql database server before doing backup or restore with this method. The filesystem backup or restore may be 2 to 3 times faster than the pg_dump command, but only disadvantage is that you must completely shutdown the database server. It is very highly recommended that you use backup and restore tools like Arkeia, Bru which are given in Mic-Lin analogy list sub-heading "Backup and Restore Utility" at http://aldev.8m.com and mirror sites are at webjump, angelfire, geocities, virtualnet, bizland, theglobe, spree, infoseek, bcity, 50megs .The OS commands to use are - bash$ man tar bash$ tar -cvf backup.tar /usr/local/pgsql/data or using compression bash$ tar -zcvf backup.tgz /usr/local/pgsql/data INCREMENTAL BACKUP : This is in todo list and will appear in future release of PostgreSQL. 7.8 Security of databaseSee the chapter on PostgreSQL Security. 7.9 Online helpIt is very important that you should know how to use online help facilities of PostgreSQL, since it will save you lot of time and provides very quick access to information. See the online man pages on various commands like createdb, createuser, etc.. bash$ man createdb See also online help of psql, by typing \h at psql prompt bash$ psql mydatabase psql> \h Tip: In psql press up/down arrow keys for history line editing or \s 7.10 Creating Triggers and Stored ProceduresTo 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.
bash$ man createlang bash$ createdb mydb bash$ export PGLIB=/usr/lib/pgsql bash$ createlang plpgsql mydb bash$ createlang plpgsql template1 See also the trigger, stored procedures examples in Examples RPM . One sample code from examples RPM: 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(); Another trigger example sample 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'); 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 - bash$ psql mydb psql=> \? psql=> \dS psql=> \d pg_trigger psql=> select tgname from pg_trigger order by tgname; To see the list of functions and stored procedures in database do - bash$ psql mydb psql=> \? psql=> \dS psql=> \d pg_proc psql=> select proname, prosrc from pg_proc order by proname; psql=> \df 7.11 PostgreSQL DocumentationMore questions, read the fine manuals of PostgreSQL which are very extensive. PostgreSQL documentation is distributed with package. See the 'User's Guide', 'Programmer's Guide', 'Administrator's Guide' and other manuals. The release docs are at http://www.postgresql.org/users-lounge/docs. 8. Performance Tuning of PostgreSQL serverGenerally database server is standalone box connected to network. Since database server is the only unix process which runs on the CPU, you can do several optimizations to speed up the server. 8.1 OS Tuning for Database serverTo get more bang for a given CPU processing power, do the following:-
8.2 Tuning Database server processGeneral tuning tips:
Specialized tuning tips:
9. PostgreSQL Supports Extremely Large Databases greater than 200 GigPostgreSQL is already used by many companies supporting large databases. The following techniques are suggested : 9.1 CPU types - 32-bit or 64-bitPerformance of 32-bit cpu machines will decline rapidly when the database size exceeds 5 GigaByte. You can run 30 gig database on 32-bit cpu but the performance will be degraded. Machines with 32-bit cpu imposes a limitation of 2 GB on RAM, 2 GB on file system sizes and other limitations on the operating system. Use the special filesystems for linux made by SGI, IBM or HP or ext3-fs to support file-sizes greater than 2 GB on 32-bit linux machines. For extremely large databases, it is strongly advised to use 64-bit machines like Digital Alpha cpu, Sun Ultra-sparc 64-bit cpu, Silicon graphics 64-bit cpu, Intel Merced IA-64 cpu, HPUX 64bit machines or IBM 64-bit machines. Compile PostgreSQL under 64-bit cpu and it can support huge databases and large queries. Performance of PostgreSQL for queries on large tables and databases will be several times faster than PostgreSQL on 32-bit cpu machines. Advantage of 64-bit machines are that you get very large memory addressing space and the operating system can support very large file-systems, provide better performance with large databases, support much larger memory (RAM), have more capabilities etc.. 9.2 Multiple CPUsFor large databases it is recommended that you use SMP boxes which have 4, 16 or 32 CPUs. Alternatively, you can use 4 or 5 single CPU boxes and you can partition the database into 4 or 5 seperate databases and each database running on a seperate box. Each CPU will be connected with fast NIC (100MBits) ethernet card. For example - if you have 200 tables in a database, you can distribute 200 tables to 4 database each having 50 tables. In this way, you are distributing the load evenly among 4 seperate machines. This is a cheaper alternative to 4-way CPU box. You would use 'Queries across multiple databases', NFS mounts in LAN, 'CREATE VIEW' for read-only tables to accomplish this task. And each CPU "can see" all the databases i.e all the 200 tables. In future PostgreSQL may provide support for 'Queries across multiple databases' (already in the TODO list), which may appear in upcoming version 7.1. For example, queries across multiple databases using aliases a, b for table names can be like - select a.col1, a.col2, b.col4, b.col7 from database1.my_tablea a, database2.my_tableb b where a.col1 = b.col3 and a.col4 = b.col9; update my_tablea set col1 = b.col2 from database1.my_tablea a, database2.my_tableb b where a.col4 = b.col9; 9.3 Replication ServerReplication server for large enterprises/businesses is available at http://www.erserver.com and from http://www.pgsql.com. The support is sold ($$$$s) commercially by PostgreSQL Inc. You use replication server to provide redundancy and high availability. Replication server is a complex, sophisticated product. 10. How can I trust PostgreSQL ? Regression Test Package builds customer confidenceThanks to "Laws of Physics", it is possible to SCIENTIFICALLY verify whether PostgreSQL is working as per ISO/ANSI SQL specifications. To validate PostgreSQL, regression test package (src/test/regress) is included in the distribution. Regression test package will verify the standard SQL operations as well as the extensibility capabilities of PostgreSQL. The test package already contains hundreds of SQL test programs. You should use the computer's high-speed power to validate the PostgreSQL, instead of using human brain power. Computers can carry out software regression tests millions or even billions of times faster than humans can. Modern computers can run billions of SQL tests in a very short time. In the near future the speed of computer will be several zillion times faster than human brain! Hence, it makes sense to use the power of computer to validate the software. You can add more tests just in case you need to, and can upload to the primary PostgreSQL web site if you feel that it will be useful to others on internet. Regression test package helps build customer confidence and trust in PostgreSQL and facilitates rapid deployment of PostgreSQL on production systems. Regression test package can be taken as a "VERY SOLID" technical document mutually agreed upon between the developers and end-users. PostgreSQL developers extensively use the regression test package during development period and also before releasing the software to public to ensure good quality. Capablilities of PostgreSQL are directly reflected by the regression test package. If a functionality, syntax or feature exists in the regression test package then it is supported, and all others which are NOT listed in the package MAY not be supported by PostgreSQL!! You may need to verify those and add it to regression test package. 11. Security of DatabaseDatabase security is addressed at several levels:
11.1 User AuthenticationAuthentication is the process by which the backend server and postmaster ensure that the user requesting access to data is in fact who he/she claims to be. All users who invoke Postgres are checked against the contents of the pg_user class to ensure that they are authorized to do so. However, verification of the user's actual identity is performed in a variety of ways:
11.2 Host-Based Access ControlHost-based access control is the name for the basic controls PostgreSQL exercises on what clients are allowed to access a database and how the users on those clients must authenticate themselves. Each database system contains a file named pg_hba.conf, in its $PGDATA directory, which controls who can connect to each database. Every client accessing a database must be covered by one of the entries in pg_hba.conf. Otherwise all attempted connections from that client will be rejected with a "User authentication failed" error message. See online man page of pg_hba.conf(5) (man 5 pg_hba.conf). The general format of the pg_hba.conf file is of a set of records, one per line. Blank lines and lines beginning with a hash character ("#") are ignored. A record is made up of a number of fields which are separated by spaces and/or tabs. Connections from clients can be made using Unix domain sockets or Internet domain sockets (ie. TCP/IP). Connections made using Unix domain sockets are controlled using records of the following format: local database authentication method where database specifies the database that this record applies to. The value all specifies that it applies to all databases. authentication method specifies the method an user must use to authenticate themselves when connecting to that database using Unix domain sockets. The different methods are described below. Connections made using Internet domain sockets are controlled using records of the following format.
host database TCP/IP-address TCP/IP-mask authentication method The TCP/IP address is logically and'ed to both the specified TCP/IP mask and the TCP/IP address of the connecting client. If the two resulting values are equal then the record is used for this connection. If a connection matches more than one record then the earliest one in the file is used. Both the TCP/IP address and the TCP/IP mask are specified in dotted decimal notation. If a connection fails to match any record then the reject authentication method is applied (see Authentication Methods). 11.3 Authentication MethodsThe following authentication methods are supported for both Unix and TCP/IP domain sockets:
The following authentication methods are supported for TCP/IP domain sockets only:
Here are some examples: # Trust any connection via Unix domain sockets. local trust # Trust any connection via TCP/IP from this machine. host all 127.0.0.1 255.255.255.255 trust # We don't like this machine. host all 192.168.0.10 255.255.255.0 reject # This machine can't encrypt so we ask for passwords in clear. host all 192.168.0.3 255.255.255.0 password # The rest of this group of machines should provide encrypted passwords. host all 192.168.0.0 255.255.255.0 crypt 11.4 Access ControlPostgres provides mechanisms to allow users to limit the access to their data that is provided to other users.
11.5 Secure TCP/IP Connection via SSHYou can use ssh to encrypt the network connection between clients and a Postgres server. Done properly, this should lead to an adequately secure network connection. The documentation for ssh provides most of the information to get started. Please refer to http://www.heimhardt.de/htdocs/ssh.html for better insight. A step-by-step explanation can be done in just two steps. Running a secure tunnel via ssh: A step-by-step explanation can be done in just two steps.
11.6 Kerberos AuthenticationKerberos is an industry-standard secure authentication system suitable for distributed computing over a public network. Availability: The Kerberos authentication system is not distributed with Postgres. Versions of Kerberos are typically available as optional software from operating system vendors. In addition, a source code distribution may be obtained through MIT Project Athena.
Note: You may wish to obtain the MIT version even if your vendor provides a version, since some vendor ports have been deliberately crippled or rendered non-interoperable with the MIT version. Inquiries regarding your Kerberos should be directed to your vendor or MIT Project Athena. Note that FAQLs (Frequently-Asked Questions Lists) are periodically posted to the Kerberos mailing list (send mail to subscribe), and USENET news group. Installation: Installation of Kerberos itself is covered in detail in the Kerberos Installation Notes . Make sure that the server key file (the srvtab or keytab) is somehow readable by the Postgres account. Postgres and its clients can be compiled to use either Version 4 or Version 5 of the MIT Kerberos protocols by setting the KRBVERS variable in the file src/Makefile.global to the appropriate value. You can also change the location where Postgres expects to find the associated libraries, header files and its own server key file. After compilation is complete, Postgres must be registered as a Kerberos service. See the Kerberos Operations Notes and related manual pages for more details on registering services. Operation: After initial installation, Postgres should operate in all ways as a normal Kerberos service. For details on the use of authentication, see the PostgreSQL User's Guide reference sections for postmaster and psql. In the Kerberos Version 5 hooks, the following assumptions are made about user and service naming(also, see Table below):
Table: Kerberos Parameter Examples ------------------------------------------------------ Parameter Example ------------------------------------------------------ user frew@S2K.ORG user aoki/HOST=miyu.S2K.Berkeley.EDU@S2K.ORG host postgres_dbms/ucbvax@S2K.ORG ------------------------------------------------------ 12. GUI FrontEnd Tool for PostgreSQL (Graphical User Interface)Web browser will be the most popular GUI front-end in the future. It is recommended that you migrate all of your "legacy" Windows 95/NT applications to Web-based application. You should use Web-Application Servers like Enhydra (Java based) or Zope (Python based) or OpenACS . Best web-scripting (and compiling) language is PHP+Zend compiler PHP is extremely powerful as it combines the power of Perl, Java, C++, Javascript into one single language and it runs on all OSes - unixes and Windows NT/95. The best tools in the order of preference are -
Language choices in the order of preference are -
There are other tools available - PostgreSQL has Tcl/Tk interface library in the distribution called 'pgTcl'. There is an IDE (integrated development environment) for Tcl/Tk called SpecTcl.
13. Interface Drivers for PostgreSQL
13.1 ODBC Drivers for PostgreSQLODBC stands for 'Open DataBase Connectivity' established by Microsoft, is a popular standard for accessing information from various databases from different vendors. Applications written using the ODBC drivers are guaranteed to work with various databases like PostgreSQL, Oracle, Sybase, Informix etc..
13.2 UDBC Drivers for PostgreSQLUDBC is a static version of ODBC independent of driver managers and DLL support, used to embed database connectivity support directly into applications.
13.3 JDBC Drivers for PostgreSQLJDBC stands for 'Java DataBase Connectivity'. Java is a platform independent programming language developed by Sun Microsystems. Java programmers are encouraged to write database applications using the JDBC to facilitate portability across databases like PostgreSQL, Oracle, informix, etc. If you write Java applications you can get JDBC drivers for PostgreSQL from the following sites: JDBC driver is already included in the PostgreSQL distribution in postgresql-jdbc*.rpm.
The JDBC home, guide and FAQ are located at -
13.4 Java for PostgreSQLJava programmers can find these for PostgreSQL very useful.
14. Perl Database Interface (DBI) Driver for PostgreSQL
14.1 Perl interface for PostgreSQLPERL is an acronym for 'Practical Extraction and Report Language'. Perl is available on each and every operating system and hardware platform in the world. You can use Perl on Windows95/NT, Apple Macintosh iMac, all flavors of Unix (Solaris, HPUX, AIX, Linux, Irix, SCO etc..), mainframe MVS, desktop OS/2, OS/400, Amdahl UTS and many others. Perl runs EVEN on many unpopular or generally-unknown operating systems and hardware!! So do not be surprised if you see perl running on a very rarely used operating system. You can imagine the vast extent of the user base and developer base of Perl. Perl language has a very long life just like "C" language, and Perl will be in use for thousands of years in the future! Perl runs 10 times faster than Java and sometimes faster than even "C". Java is a very complex system with virtual machine and interpreter which makes it extremely slow, unstable and unreliable. Perl is very simple, fast and object oriented. Perl interface for PostgreSQL is included in the distribution of PostgreSQL. Check in src/pgsql_perl5 directory.
14.2 Perl Database Interface DBIWHAT IS DBI ?The Perl Database Interface (DBI) is a database access Application Programming Interface (API) for the Perl Language. The Perl DBI API specification defines a set of functions, variables and conventions that provide a consistent database interface independent of the actual database being used. The Database Drivers (Perl DBI) initiative has standardized the interface to a number of commercial database engines, so that you can move from, say, Oracle to PostgreSQL with a minimum of effort. DBD driver for PostgreSQLBefore you install DBD PostgreSQL (Driver) you must install DBI. Get DBI driver from
Get DBD-Pg from below
Technical support for DBI
DBI DocumentsThere are a few information sources on DBI. POD documentation: PODs are chunks of documentation usually embedded within perl programs that document the code ``in place'', providing an useful resource for programmers and users of modules. POD for DBI and drivers is beginning to become more commonplace, and documentation for these modules can be read with the following commands.
The POD for the DBI Specification can be read with the command $ perldoc DBI Users of the Oraperl emulation layer bundled with DBD::Oracle, may read up on how to program with the Oraperl interface by typing: $ perldoc Oraperl Users of the DBD::mSQL module may read about some of the private functions and quirks of that driver by typing: $ perldoc DBD::mSQL The Frequently Asked Questions is also available as POD documentation. Read this by typing: $ perldoc DBI::FAQ POD in general - Information on writing POD, and on the philosophy of POD in general, can be read by typing: $ perldoc perlpod Users with the Tk module installed may be interested to learn there is a Tk-based POD reader available called tkpod, which formats POD in a convenient and readable way. See also -
The mailing lists that users may participate in are:
Is DBI supported under Windows 95 / NT platforms?The DBI and DBD::Oracle Win32 ports are now a standard part of DBI, so, downloading DBI of version higher than 0.81 should work fine. You can access Microsoft Access and SQL-Server databases from DBI via ODBC. Supplied with DBI-0.79 (and later) is DBI 'emulation layer' for the Win32::ODBC module. It's called DBI::W32ODBC. You will need the Win32::ODBC module.
Commercial Support and TrainingPERL CLINIC : The Perl Clinic can arrange commercial support contracts for Perl, DBI, DBD::Oracle and Oraperl. Support is provided by the company with whom Tim Bunce, author of DBI, works. For more information on their services, please see :
14.3 Testing Perl interfaceSee the section - 15. PostgreSQL Management Tools
15.1 PGACCESS - A GUI Tool for PostgreSQL ManagementPgAccess is a Tcl/Tk interface to PostgreSQL. It is already included in the distribution of PostgreSQL. You may want to check out this web site for a newer copy
# man xhost # xhost + # su - postgres bash$ man pgaccess bash$ export DISPLAY=<hostname>:0.0 bash$ pgaccess mydatabase Features of PgAccess PgAccess windows - Main window, Table builder, Table(query) view, Visual query builder. Tables
Queries
Sequences
Future implementation will have
INFORMATION ABOUT LIBGTCL You will need the PostgreSQL to Tcl interface library libgtcl, lined as a Tcl/Tk 'load'-able module. The libpgtcl and the source is located in the PostgreSQL directory /src/interfaces/libpgtcl. Specifically, you will need a libpgtcl library that is 'load'-able from Tcl/Tk. This is technically different from an ordinary PostgreSQL loadable object file, because libpgtcl is a collection of object files. Under Linux, this is called libpgtcl.so. You can download from the above site a version already compiled for Linux i386 systems. Just copy libpgtcl.so into your system library director (/usr/lib). One of the solutions is to remove from the source the line 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. 15.2 GtkSQL Graphical Query Tool for PostgreSQLGtkSQL 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 http://gtksql.sourceforge.net Its main features are :
15.3 Windows Interactive Query Tool for PostgreSQL (WISQL or MPSQL)MPSQL provides users with a graphical SQL interface to PostgresSQL. MPSQL is similar to Oracle's SQL Worksheet and Microsoft SQL Server's query tool WISQL. It has nice GUI and has history of commands. Also you can cut and paste and it has other nice features to improve your productivity.
15.4 Interactive Query Tool (ISQL) for PostgreSQL called PSQLISQL is for character command line terminals. This is included in the distribution, and is called "psql". Very similar to Sybase ISQL, Oracle SQLplus. At unix prompt give command 'psql' which will put you in psql> prompt.
Very user friendly and easy to use.
Can also be accessed from shell scripts.
15.5 MPMGR - A Database Management Tool for PostgresSQLMPMGR will provide a graphical management interface for PostgresSQL. You can find it at
15.6 PgAdmin, PhpPgAdmin tools
15.7 PgBash - SQL shell toolPgBash has functionality which is similar to psql. And, PgBash provides the useful functionality in making flexible interactive operational environment using bash alias, function, the history editing, etc. The main site of PgBash is at http://www.psn.co.jp/PostgreSQL/pgbash/index-e.html PgBash is a shell which included the "direct SQL" or the "embedded SQL" interface for PostgreSQL by the improvement on the bash(current version 2.03) shell. PgBash can be used as a log-in shell, a sub-shell(the shell started from a shell) and a shell program use. Here, "Direct SQL" shows functionality which immediately outputs the result to the "standard output". And "Embedding SQL" shows functionality which sets the retrieval result into the shell variable and which deals with in shell script language. SQL statement(terminal character is a semicolon) is handled as one shell command, it is possible to execute the SQL statement with pipeline, redirection and background_job options. In addition, by using the exec_sql command, it is possible to execute SQL statement with the various options. The executive example of SQL is shown next. prompt> /usr/local/bin/pgbash .....Start of pgbash pgbash> connect to db2@xxx.com user sakaida; .....connect to database pgbash> select * from test limit 100; | more .....with pipeline pgbash> select * from test; > /tmp/sel.dat & .....with redirect+background_Job pgbash> addr='Osaka' pgbash> insert into test values( > 111,'name', .....can start new line > '$addr' .....use shell variable > ); pgbash> connect to db3@yyy.com user postgres; pgbash> set connection db2; .....set current D/B to db2 pgbash> select * from test; .....select db2's test pgbash> exec_sql -d db3 "select * from test3".....change connection to db3 pgbash> ls pgbash> begin; pgbash> declare cur cursor for select * from test; pgbash> fetch in cur into :AA,:BB; .....set shell variables pgbash> echo "AA=$AA, BB=$BB" pgbash> end; pgbash> fc fetch .....edit history and go pgbash> !echo .....retry echo pgbash> disconnect all .....disconnect all connections pgbash> exit .....End of pgbash 15.8 Webmin Tool for PostgreSQLThe webmin tool (administration of an Unix machine through a, secure if you want, webpage) has a PostgreSQL module as of the latest release (version 0.82). With this module you can add users, groups, databases, tables, view tables. You can find webmin on 16. CPUs for PostgreSQLSee the document http://metalab.unc.edu/LDP/HOWTO/CPU-Design-HOWTO.html for list of CPUs available for PostgreSQL and also this document gives details on CPU design. The following CPUs (both 64-bit and 32-bit) are available for PostgreSQL. All these CPUs run Linux.
The following is GNU/GPL open-source CPU list:
The following is commercial CPU list:
Other important CPU sites are at -
17. Setting up multi-boxes PostgreSQL with just one monitorIf you do want to spend money on hardware switches than you can use VNC (Virtual Network Computing) Technology from the telecom giant AT & T. VNC is GPLed and is a free software. Using VNC you can run PostgreSQL programs on computers without monitors and display on remote boxes with monitors!! But the boxes must be connected via ethernet Network Interface Cards. VNC is at http://www.uk.research.att.com/vnc You can stack up multiple CPU-boxes and connect to just one monitor and use the KVM (Keyboard, Video, Monitor) switch box to select the host. This saves space and avoids a lot of clutter and also eliminates monitor, keyboard and the mouse (saving anywhere from 100 to 500 US dollars per set). Using this switch box, you can stack up many PostgreSQL servers (development, test, production), Web servers, ftp servers, Intranet servers, Mail servers, News servers in a tower shelf. The switch box can be used for controlling Windows 95/NT or OS/2 boxes as well. Please check out these sites:
Search engine yahoo to find more companies with "Server Switches" or "KVM Switches". It is strongly recommended to have a dedicated unix box for each PostgreSQL data-server for better performance. No other application program/processes should run on this box. See the Business section of your local newspapers for local vendors selling only intel box, 13" monochrome monitor (very low cost monitor). Local vendors sell just the hardware without any Microsoft Windows/DOS. You do not need a color monitor for the database server, as you can do remote administration from color PC workstation. You can buy bare-bone computer hardware from online stores. You can get good rates in "Online Auctions"
Get RedHat (or some other distribution of) Linux cdrom from below -
Using KVM switch you can control many cpu boxes by just one monitor and one keyboard! 18. Web-Application-Servers for PostgreSQLSeveral Web-Application-Servers work with PostgreSQL both open-source and commercial versions. The popular open-source Web-Application-Servers are Perl based Application Servers like Mason, WIRM, Velocigen, Enhydra(Java) and Zope(Python) and commercial Web-Application-Servers are IBM Websphere, BEA Weblogic. It is recommeded that you use secure web server like Apache + mod_ssl + OpenSSL. See Redhat StrongHold secure server at http://www.c2.net/products/sh3. Web Application Servers can be classified according to the programming language which they support. You must choose a Web Application server based on the programming language which you like the most. Classifications of Web Application servers are:
18.1 PERL Web Application ServersPerl language has a very long life just like "C" language, and Perl will be in use for a long time in the future! Perl runs 3 times faster than Java for some operations (but Java runs faster than perl for some operations). Java is a very complex system with virtual machine and interpreter which makes it extremely slow, unstable and unreliable. Perl is very simple, fast and object oriented. Also Perl programs can be easily compiled for even better performance. Use Perl2Exe which is a command line utility for converting perl scripts to executable files http://www.indigostar.com/perl2exe.htm The following Web Applicaiton servers are available for PERL
Commercial Web Application Servers for Perl:
18.2 PHP Web Application ServersThe following Web Applicaiton servers are available for PHP
18.3 Lutris Corp "Enhydra Enterprise" (Java)Enhydra supports PostgreSQL database. Enhydra is an immensely popular Java/XML/J2EE Web-Application-Server created by 'Lutris Corporation'. It is the world's best Java/XML/J2EE Web-Application server. It supports EJB, Servlets, JSP, JNDI, JDBC, JTA, CORBA, XMLC/Rocks, DODS and internationalization. It is used by many large fortune 500 companies in US and Europe. Companies like "French Telecom" are directly sponsoring the Enhydra. It is written in 100% pure Java and is available from http://www.enhydra.org. Enhydra is an open source code project but is commercially sold and supported by Lutris Corp. Visit http://www.lutris.com See tutorial on setting up the PostgreSQL with Enhydra and see also Setup database with Enhydra. You would use Borland Corp's JBuilder along with Enhydra. JBuilder is at http://www.inprise.com See also Enterprise Java HOWTO at http://www.linuxdoc.org/HOWTO/Enterprise-Java-for-Linux-HOWTO.html 18.4 Zope (Python)Python is becoming immensely popular "pure" object-oriented scripting language. Zope is a Web-Application server and provides interfaces to PostgreSQL. Zope is available at http://www.zope.org Python is at http://www.python.org 18.5 OpenACS (Tcl Language)OpenACS (Open ArsDigita Community System) http://openacs.org is an advanced toolkit for building scalable, community-oriented web applications. It relies on AOLserver, a web/application server, and PostgreSQL, a true ACID-compliant RDBMS. These are two high-quality products available for free under open-source licenses. ACS is created by ArsDigita, http://www.arsdigita.com, their ACS (ArsDigita Community System) attempts to be as DB independent as possible, though it is based on Oracle (hence Open ACS have to take time out to port it). See also http://www.appserver-zone.com 18.6 C++, CORBA Web Application Servers
18.7 Pike, Roxen Web Application ServerPike is a dynamic programming language with a syntax similar to C++. It is simple to learn, does not require long compilation passes and has powerful built-in data types allowing simple and fast data manipulation. Pike is released under the GNU/GPL general public license. Pike is a very powerful object oriented scripting language and since it's syntax is identical to C++ it is expected that it's popularity will explode in coming years. Pike is at http://pike.roxen.com and Roxen web server is at http://www.roxen.com. Roxen is a modular web server that has a complete DB interface, and includes Postgres support. It has full support for SSL, and is released under the GPL. Roxen is written using Pike scripting language. 18.8 Web Application Servers DirectoryVisit Web Application Servers directory which has "Yellow Pages". 19. Applications and Tools for PostgreSQL
19.1 PostgreSQL 4GL for web database applications - AppGEN Development SystemAppGEN can be downloaded from AppGEN is a high level fourth generation language and application generator for producing World Wide Web (WWW) based applications. These applications are typically used over the internet or within a corporate intranet. AppGEN applications are implemented as C scripts conforming to the Common Gateway Interface (CGI) standard supported by most Web Servers.To use AppGEN you will need the following :- PostgresSQL, relational database management system A CGI compatible web server such as NCSA's HTTPD An ansi C compiler such as GCC AppGEN consists of the following Unix (Linux) executables :-
The author, Andrew Whaley, can be contacted on 19.2 WWW Web interface for PostgresSQL - DBENGINEdbengine a plug 'n play Web interface for PostgreSQL created by Ingo Ciechowski. It is at About DBENGINE : dbengine is an interface between the WWW and Postgres95 which provides simple access to any existing database within just a few minutes.PHP gives you a Perl like language in your documents, but no real Perl while AppGen and wdb-p95 require that you create some configuration file for each of your databases -- sound's like you'll first of all have to learn some sort of new meta language before you can get started. Unlike other tools you don't have to learn any special programming or scripting language to get started with dbengine. Also there's no configuration file for each database, so you don't have to get familiar with such a new structure. However - in case you want to gain access to the full features of dbengine it'd be a good idea to know the Perl language. The whole system can be configured by simple manipulations of an additional database that contains closer information about how to visualize your database access. You can even specify virtual Fields which are calculated on the fly right before they're displayed on the screen. 19.3 Apache Webserver Module for PostgreSQL - NeoSoft NeoWebScriptApache is a well-known Web Server. And a module to interface PostgreSQL to Apache Webserver is at - NeoWebScript is a programming language that allows both simple and complex programs to be embedded into HTML files.When an HTML page containing embedded NeoWebScript is requested, the NeoWebScript-enabled webserver executes the embedded script(s), producing a webpage containing customized content created by the program. NeoWebScript is a fast, secure, easy to learn way to do powerful, server-based interactive programming directly in the HTML code in web pages. With NeoWebScript, counters, email forms, graffiti walls, guest books and visitor tracking are all easy, even for a beginning programmer. See how well NeoWebScript holds its' own vs. PERL and JavaScript. If you'd like to install NeoWebScript on your webserver, your Webmaster needs to read our Sysop FAQ to get started. Theory of Operations will explain how NeoWebScript works, while installation will take them through the steps. Management deals with configuration issues and running the server, tests let you verify correct NeoWebScript operation, and troubleshooting deals with server problems. There is no cost to you to use NeoWebScript-2.2 for your ISP, your intranet, or your extranet. You'll see a full license when you register to download, but it costs $ 99 if you want to embed it in your own product or use it in a commerce (eg. SSL) server. NeoWebScript is a module for the Apache webserver that allows you to embed the Tcl/Tk programming language in your webpages as a scripting tool. It was invented by Karl Lehenbauer, NeoSoft's Chief Technical Officer, and documented, enhanced and extended by NeoSoft's programmers and technical writers. The Apache webserver is the world's most popular webserver, accounting for 68 % of the sites polled. Tcl/Tk is the powerful, free, cross-platform scripting language developed by Dr. John Ousterhout. In his own words "Tcl/Tk lets software developers get the job done ten times faster than with toolkits based on C or C++. It's also a great glue language for making existing applications work together and making them more graphical and Internet-aware." Karl Lehenbauer, Founder and Chief Technical Officer of NeoSoft, has been part of Tcl/Tk development from the very beginning. Together with Mark Diehkans, they authored Extended Tcl, also known as TclX or NeoSoft Tcl, a powerful set of extensions to the language. Many of the current core Tcl commands originated in Extended Tcl, and were then imported into the core language by Dr. Ousterhout. NeoSoft Inc., 1770 St. James Place, Suite 500, Houston, TX 77056 USA 19.4 HEITML server side extension of HTML and a 4GL language for PostgreSQLTool heitml is another way to interface postgres with the world wide web. For more details contact
heitml is a server side extension of HTML and a 4GL language at the same time. People can write web applications in the HTML style by using new HTML-like tags. heitml (pronounced "Hi"-TML) is an extension of HTML and a full-featured 4th generation language that enables Web-based Applications to interact with data stored in SQL databases, without resorting to complex CGI scripts. heitml extends HTML on the sever side, dynamically converting ".hei" files to HTML format and so is compatible with any web browser.It embraces the familiar, easy-to-use HTML syntax and provides a large assortment of pre-developed Tags and Libraries to take care of tasks that formerly required CGI. As XML, heitml provides user defined tags. With heitml the user defined markup can be translated to HTML and send to a browser. heitml targets both HTML designers and professional programmers alike. HTML designers can use heitml Tags to build dynamic web pages, access SQL databases, or create complete web applications. Counters, registration databases, search forms, email forms, or hierarchical menues can all be created simply by using the pre-developed HTML-like Tags found in the many Component Libraries. For programmers heitml embeds a complete forth generation language in HTML
plus powerful expression evaluation with integer, real,
boolean, string, and tuple data types. Tuples have
reference semantics as in modern object oriented languages
and are stored on a heap. heitml variables including all
complex data structures stored on the heap maintain their
values between pages using the Session Mode. It is
possible to define your own tags or environment tags and
even re-define HTML-tags.
heitml makes it possible to - - - develop Web Sites in a structured and modular way, drastically reducing maintenance overhead. - - - develop intelligent and interactive Web Sites, with content that dynamically adapts itself to user needs. - - - show the content of SQL databases with no programming other than to use our library of prefined "dba" Tags. - - - develop complex database and Catalog Shopping applications using Session Variables heitml runs on Linux with any Web Server using the CGI interface, and is especially fast (avoiding the CGI overhead) within the APACHE Web Server using the apache API. Currently MSQL (Version 1 and 2), PostgreSQL (Version 6), mysql, and the yard databases are supported). heitml also works on Linux, BSDi, Solaris and SunOS, as well as Windows NT with CGI and ISAPI and ODBC and Windows 95. heitml (on linux) is free for research, non-commercial and private usage. Commercial Web Sites must pay a licensing fee. The fully operational version of heitml is available for a trial period downloaded freely. (Note, however, that each ".hei" Web Page you develop will display a message identifying it as the version for non-commercial use. After registration, you will receive a key to switch off the message without having to re-install the program.) heitml (pronounced "Hi"-TML) significantly extends and enhances the functionality of HTML by definable tags and full programming features. This makes dynamic content and database applications possible simply within the HTML world, without CGI and without external scripting or programming languages. This means you, as an HTML author, can embed applications in your web pages, simply by using some new tags without CGI and without programming. As an advanced user or programmer on the other hand you can create and program powerful tag libraries. This approach makes heitml suitable for HTML newcomers and professional programmers alike. heitml runs on the web server and dynamically generates HTML, so heitml is compatible with the internet standards and with any web browser. It allows full access to databases while shielding the user from any unneccessary CGI complexity. heitml has been developed according to the newst research and in compiler construction and transaction systems. heitml pages are developed just the same way as HTML pages, with a text editor or HTML editor, and placed on the web server as usual. However now pages can contain dynamic heitml tags and access tag libraries. You can use these tags to access the database, to create dynamic content, to send emails, and even to create powerful applications like registration databases and shopping systems. HTML newcomers and professional programmers alike will be amazed at how quickly and easily they can design exciting applications like our Interactive Guestbook without resorting to complex and difficult to learn CGI scripts, simply by using the tools provided in our dba Library. heitml is accompanied by a wide range of tag libraries, to create guestbooks, database maintenance applications, extensible query forms, powerful email forms or structure your web site using a hierarchic menu. These tools are ready to go, just add the corresponding tags to your web site. As an experienced programmer you can make fully use of the heitml persistent dynamic tuple architecture : heitml is not just a scripting language with dynamic typing, full power expression evaluation, recursive procedures and extensive parameter passing features, but it also features persistent dynamic tuples to automatically keep session data of any size. 19.5 America On-line AOL Web server for PostgreSQLThe no-cost commercial webserver, AOLserver supports database connections to PostgreSQL for more information see
19.6 Problem/Project Tracking System Application Tool for PostgreSQLThis is at 19.7 Convert dbase dbf files to PostgreSQLThe program dbf2msql works fine with mSQL and PostgreSQL. You can find it at
This program was written by Maarten Boekhold, Faculty of Electrical Engineering TU Delft, NL Computer Architecture and Digital Technique section You can also use a python method to read dbf files and load into a postgres database. 19.8 Convert Microsoft Access MDB database files to PostgreSQLMDB Tools is a planned set of libraries and utilities to facilitate exporting data from MS Access databases (mdb files) into a multiuser database such as Oracle, Sybase, DB2, Informix, MySQL, Postgresql, or similar.
19.9 Zeos Client"Zeos" a program products for development and administration of the database applications, with use OpenSource SQL-servers - MySQL, PostgreSQL and InterBase http://www.zeos.dn.ua/eng/index.html 19.10 Report Writer in JavaGeneric Report Writer is a menu-driven report writer. It is not a drag-and-drop interface. Works with PostgreSQL, MySQL, and Access. It probably will work on any other database for which you have a Type 4 JDBC version 1 driver. It is at 20. Database Design Tool - Entity Relation Diagram Tool"DeZign for databases" ( http://www.heraut.demon.nl/dezign/index.html) is a database development tool using an entity relationship diagram. It visually supports the lay out of the entities and relationships and automatically generates SQL-schemas for most leading databases. "DeZign for databases" supports the logical and physical data-level from a single specification achieved by using automatic foreign key migration at design-time. Multiple display options include entity/primary key/attributes inclusive foreign keys/attributes exclusive foreign keys. "DeZign for databases" also supports domains (user defined datatypes). Reports generated by DeZign can be used for conveying complex designs in simplified format to managers at various management levels. You can generate reports, datadictionaries and databases by one simple click. The following databases are supported: Oracle, Interbase, IBM DB2, Sybase, MS Access (95/97/200), MS SQL Server, Paradox, dBase, Informix, SQL-Anywhere, MySQL and PostgreSQL. Heraut "DeZign for databases" is at ( http://www.heraut.demon.nl) 21. Web Database Design/Implementation tool for PostgreSQL - EARP
21.1 What is EARP ?The "Easily Adjustable Response Program" (EARP) created by David Dougherty. EARP is a Web Database Design/Implementation tool, built on top of the PostgreSQL database system. Its functionality includes:
21.2 ImplementationThe main implementation of EARP is a CGI binary which runs under the http daemon to provide access to the database server. All of the design tools are built into the driver, no design takes place over anything but the web. The tools themselves require a graphical browser, the compatibility of objects designed with the tools is implementation independent, based on designing individuals preferences. 21.3 How does it work ?One of the main features of EARP is that it uses an Object Oriented approach to producing html pages which interface to the database. Most pages will consist of several objects. Each object is produced by some sort of tool and given a name, objects are then linked together in a callable sequence by the page tool. Objects are also reusable across multiple pages. Basic tools exist for HTML, Querys, Grabbing input from forms, Extendable Formatting of Query and Input objects, and Linking together of objects into other objects. More advanced tools include the mail tool and the multithreaded query tool. Another feature of EARP is advanced security. Access to various areas of the EARP system can be limited in a variety of ways. To facilitate its advanced security, EARP performs checks for each connection to the system, determining what ids and groups the connecting agent belongs to. Access to areas is defined seperately, and the combination decides if access to a specific area of Earp is allowed. Moreover, all that is required to implement the security features is an http server that supports basic (or better) user authentication. 21.4 Where to get EARP ?EARP is available via anonymous ftp from
22. PHP Hypertext Preprocessor - Server-side html-embedded scripting language for PostgreSQLWWW Interface Tool is at - PHP also has a compiler called Zend which will vastly improve the performance. First you will write your application in PHP scripting language during development, testing and debugging. Once the project is ready for deployment you will use the Zend compiler to compile the PHP to create executable which will run very fast.Old name is Professional Home Pages (PHP) and new name is PHP Hypertext Pre-Processor
PHP is a server-side html-embedded scripting language. It lets you write simple scripts right in your .HTML files much like JavaScript does, except, unlike JavaScript PHP is not browser-dependant. JavaScript is a client-side html-embedded language while PHP is a server-side language. PHP is similar in concept to Netscape's LiveWire Pro product. If you like free fast-moving software that comes with full source code you will probably like PHP.
22.1 Major Features
22.2 PHP - Brief HistoryPHP began life as a simple little cgi wrapper written in Perl. The name of this first package was Personal Home Page Tools, which later became Personal Home Page Construction Kit. A tool was written to easily embed SQL queries into web pages. It was basically another CGI wrapper that parsed SQL queries and made it easy to create forms and tables based on these queries. This tool was named FI (Form Interpreter). PHP/FI version 2.0 is a complete rewrite of these two packages combined into a single program. It evolved to a simple programming language embedded inside HTML files. PHP eliminates the need for numerous small Perl cgi programs by allowing you to place simple scripts directly in your HTML files. This speeds up the overall performance of your web pages since the overhead of forking Perl several times has been eliminated. It also makes it easier to manage large web sites by placing all components of a web page in a single html file. By including support for various databases, it also makes it trivial to develop database enabled web pages. Many people find the embedded nature much easier to deal with than trying to create separate HTML and CGI files. Now PHP/FI is renamed as PHP. 22.3 So, what can I do with PHP ?The first thing you will notice if you run a page through PHP is that it adds a footer with information about the number of times your page has been accessed (if you have compiled access logging into the binary). This is just a very small part of what PHP can do for you. It serves another very important role as a form interpreter cgi, hence the FI part of the old name. For example, if you create a form on one of your web pages, you need something to process the information on that form. Even if you just want to pass the information to another web page, you will have to have a cgi program do this for you. PHP makes it extremely easy to take form data and do things with it. 22.4 A simple exampleSuppose you have a form:
Your display.html file could then contain something like:
It's that simple! PHP automatically creates a variable for each form
input field in your form. You can then use these variables in the ACTION
URL file.
The next step once you have figured out how to use variables is to start playing with some logical flow tags in your pages. For example, if you wanted to display different messages based on something the user inputs, you would use if/else logic. In our above example, we can display different things based on the age the user entered by changing our display.html to:
PHP provides a very powerful scripting language which will do much more
than what the above simple example demonstrates. See the section on the
PHP Script Language for more information.
You can also use PHP to configure who is allowed to access your pages. This is done using a built-in configuration screen. With this you could for example specify that only people from certain domains would be allowed to see your pages, or you could create a rule which would password protect certain pages. See the Access Control section for more details. PHP is also capable of receiving file uploads from any RFC-1867 compliant web browser. This feature lets people upload both text and binary files. With PHP's access control and logical functions, you have full control over who is allowed to upload and what is to be done with the file once it has been uploaded. See the File Upload section for more details. PHP has support for the PostgreSQL database package. It supports embedded SQL queries in your .HTML files. PHP also has support for the mysql database package. It supports embedded SQL queries in your .HTML files. 22.5 CGI Redirection
Apache 1.0.x NotesA good way to run PHP is by using a cgi redirection module with the Apache server. Please note that you do not need to worry about redirection modules if you are using the Apache module version of PHP. There are two of these redirection modules available. One is developed by Dave Andersen and it is available at and the other comes bundled with Apache and is called mod_actions.c. The modules are extremely similar. They differ slightly in their usage. Both have been tested and both work with PHP.Check the Apache documentation on how to add a module. Generally you add the module name to a file called Configuration. The line to be added if you want to use the mod_actions module is: Module action_module mod_actions.o If you are using the mod_cgi_redirect.c module add this line: Module cgi_redirect_module mod_cgi_redirect.o Then compile your httpd and install it. To configure the cgi redirection you need to either create a new mime type in your mime.types file or you can use the AddType command in your srm.conf file to add the mime type. The mime type to be added should be something like this:
If you are using the mod_actions.c module you need to add the
following line to your srm.conf file:
If you are using mod_cgi_redirect.c you should add this line to
srm.conf:
Don't try to use both mod_actions.c and mod_cgi_redirect.c at the same
time.
Once you have one of these cgi redirection modules installed and configured correctly, you will be able to specify that you want a file parsed by PHP simply by making the file's extension .phtml. Furthermore, if you add index.phtml to your DirectoryIndex configuration line in your srm.conf file then the top-level page in a directory will be automatically parsed by php if your index file is called index.phtml. Netscape HTTPDYou can automatically redirect requests for files with a given extension to be handled by PHP by using the Netscape Server CGI Redirection module. This module is available in the File Archives on the PHP Home Page. The README in the package explicitly explains how to configure it for use with PHP. NCSA HTTPDNCSA does not currently support modules, so in order to do cgi redirection with this server you need to modify your server source code. A patch to do this with NCSA 1.5 is available in the PHP file archives. 22.6 Running PHP from the command lineIf you build the CGI version of PHP, you can use it from the command line simply typing: php.cgi filename where filename is the file you want to parse. You can also create standalone PHP scripts by making the first line of your script look something like:
The "-q" suppresses the printing of the HTTP headers. You can leave off
this option if you like.
22.7 PHPGem packagePHPGem is a PHP-script which accelerates the creation of PHP-scripts for working with tables. It works with different SQL-servers such as PostgreSQL, MySQL, mSQL, ODBC, and Adabas. You input a description of and parameters for your tables' fields (field name, on/off searching in the field, etc.), and PHPGem outputs another PHP-script which will work with the tables (view/add/edit/delete/duplicate entries and search). PHPGem works with multi-level nested tables. PHPGem allows you to specify a level of access for each table and for each field for each user. PHPGem also support images. PHPGem is at 23. Python Interface for PostgreSQLPython in an interpreted, object orientated scripting language. It is simple to use (light syntax, simple and straighforward statements), and has many extensions for building GUIs, interfacing with WWW, etc. An intelligent web browser (HotJava like) is currently under development (november 1995), and this should open programmers many doors. Python is copyrighted by Stichting S Mathematisch Centrum, Amsterdam, The Netherlands, and is freely distributable. It contains support for dynamic loading of objects, classes, modules, and exceptions. Adding interfaces to new system libraries through C code is straightforward, making Python easy to use in custom settings. Python is a very high level scripting language with X interface. Python package is distributed on Linux cdroms includes most of the standard Python modules, along with modules for interfacing to the Tix widget set for Tk. PyGreSQL is a python module that interfaces to a PostgreSQL database. It embeds the PostgreSQL query library to allow easy use of the powerful PostgreSQL features from a Python script. PyGreSQL is written by D'Arcy J.M. Cain and Pascal Andre.
23.1 Where to get PyGres ?The home sites of the differents packages are:
23.2 Information and supportIf you need information about these packages please check their web sites:
For support :
23.3 Testing Python interfaceSee the section - 24. Gateway between PostgreSQL and the WWW - WDB-P95
24.1 About wdb-p95WDB-P95 - A Web interface to PostgreSQL Databases was created by J. Douglas Dunlop It is at
You can try out CASI Tape and Image Query. You can have a peek at the Form Definition File (FDF) which is used to create the CASI Tape and Image Query too, which includes a JOIN of 2 tables. This release contains all files necessary to install and run WDB-P95 as an interface to your PostgreSQL databases. To port this system to other database should be relatively easy - provided that it supports standard SQL and has a Perl interface. 24.2 Does the PostgreSQL server, pgperl, and httpd have to be on the same host?No - the PostgreSQL server does not have to be on the same host. As WDB-P95 is called by the http daemon, they have to be on the same host. - And as WDB-P95 was written to use Pg.pm - pgperl has to be on the same host too. Pgperl was written using the libpq library, so it will be able to access any PostgreSQL server anywhere in the net, just like any other PostgreSQL client. As illustrated below (WWW Client (Netscape)) => (HTTP Server (NCSA's http) + WDB-P95 + pgperl + libpq)=> (PostgreSQL server) Curly brackets () represent machines. Each machine can be of a different type : NT, SUN, HP, ... but you need the libpq interface library for the machine type where you plan to use WDB-P95, as you need it to compile pgperl. (The system was designed to use HTML tables so a recent WWW client is best) 25. "C", "C++", ESQL/C language Interfaces and Bitwise Operators for PostgreSQL
25.1 "C" interfaceIt is included in distribution and is called 'libpq'. Similar to Oracle OCI, Sybase DB-lib, Informix CLI libraries.
25.2 "C++" interfaceIt is included in distribution and is called 'libpq++'. See the section - Testing C and C++ PostgreSQL interface 25.3 ESQL/CESQL/C 'Embedded C Pre-compiler' for PostgreSQL ESQL/C is like Oracle Pro*C, Informix ESQL/C. The PostgreSQL ESQL/C is an SQL application-programming interface (API) enables the C programmer to create custom applications with database-management capabilities. The PostgreSQL ESQL/C allows you to use a third-generation language with which you are familiar and still take advantage of the Structured Query Language (SQL). ESQL/C consists of the following pieces of software:
To use Vim color editor to edit 'ecpg' files (*.pgc), you must do the following:- 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 You should have $HOME/.gvimrc file. If not create one, refer to Vim howto doc at http://metalab.unc.edu/LDP/HOWTO/Vim-HOWTO.html Put the following line in $HOME/.gvimrc file let myfiletypefile = "~/vim/myfiletypes.vim" Now, if you edit with bash$ gvim sample.pgc you will get the color syntax highlighted. 25.4 BitWise Operators for PostgreSQLBitwise operators was written by Nicolas Moldavsky "C" functions that implement bitwise operators (AND, OR, XOR, bit complement) on pgsql. Get them by anonymous FTP from Makefile for Linux is included.26. Japanese Kanji Code for PostgreSQLIt is at the following site 27. PostgreSQL Port to Windows 95/Windows NTPostgreSQL binaries for Windows NT is available from :
If you want to re-compile the source tree then follow the instructions given below. Porting to NT is done using Cygnus cygwin32 package which has gcc, gmake for Win NT/95.
27.1 Authors of NT portThe authors of Windows NT port of PostgreSQL are -
27.2 Install the Cygwin package
27.3 Tuneup Bash WindowAfter installing the Cygwin package, do the following to setup the working environment: 1. Install the Vi editor 'Vim'. See http://metalab.unc.edu/LDP/HOWTO/Vim-HOWTO.html 2. The default window of cygwin bash is black-background window with 24 lines. To set the background color and size of bash window, click on NT-Start->Control-panel->MS DOS console and change the background color to grey and size to 70 lines. (OR) right click on Window titlebar and change property. 3. Edit cygnus.bat in c:\cygnus\cywinb20 and set the following - set HOME=c:\cygnus\cygwinb20 bash --login And also edit the /.bash_profile and put these lines set -o vi PATH=$PATH:/usr/local/bin:/usr/bin export PATH 4. To enable the command-line history editing give - bash$ set -o vi Using the l,k,j,h you can use the vi commands to edit the command line history commands. You can repeat or modify previous commands, saves typing time. 5. You can do mount of drives/directories using this command - bash$ umount / bash$ mount "c:\cygnus" / bash$ mount "c:\cygnus\cygwin-b20\postgres" /usr/local/pgsql 6. See online help with - bash$ mount --help bash$ ls --help 27.4 Install the Andy Piper tools
27.5 Install Ludovic Lange's Cygwin32 IPC package
27.6 Install PostgreSQL
28. Mailing Lists
28.1 E-mail account for PostgreSQLGet free e-mail accounts from
If you have any other e-mail, you can use "Mail Filters" to receive automatically the PostgreSQL mails into a seperate folder. This will avoid mail cluttering. 28.2 English Mailing ListSee the Mailing Lists Item on the main web page at :
You can also subscribe to mailing lists. To subscribe or unsubscribe from the list, send mail to
subscribe (or) unsubscribe 28.3 Archive of Mailing ListAlso mailing lists are archived in html format at the following location -
28.4 Spanish Mailing ListNow there is an "unofficial" list of postgreSQL in Spanish. To subscribe the user has to send a message to: The body of the message should contain the single line:inscripcion pgsql-ayuda 29. Documentation and Reference Books
29.1 User Guides and ManualsThe following are included in the PostgreSQL distribution in the postscript, HTML formats and unix man-pages. They are located in /usr/doc/postgresql* directory. If you have access to internet, you can find the documents listed below at http://www.postgresql.org/docs and at http://www.postgresql.org/users-lounge/docs.
29.2 Online Documentation
29.3 Useful Reference Textbooks
Hundreds of other titles on SQL are available! Check out a bookstore. 29.4 ANSI/ISO SQL Specifications documents - SQL 1992, SQL 1998ANSI/ISO SQL specifications documents can be found at these sites listed below -
29.5 Syntax of ANSI/ISO SQL 1992See Appendix A of this document Appendix A 29.6 Syntax of ANSI/ISO SQL 1998The SQL 1998 (SQL 3) specification is still under development. See 'Electronic Access to the SQL3 Working Draft' of this document at SQL 1998 29.7 SQL Tutorial for beginnersSee Appendix B of this document Appendix B 29.8 Temporal Extension to SQL92
This directory contains the language specification for a temporal extension to the SQL-92 language standard. This new language is designated TSQL2. The language specification present here is the final version of the language. Correspondence may be directed to the chair of the TSQL2 Language Design Committee, Richard T.Snodgrass, Department of Computer Science, University of Arizona, Tucson, AZ 85721, The affiliations and e-mail addresses of the TSQL2 Language Design Committee members may be found in a separate section at the end of the language specification.The contents of this directory are as follows. spec.dvi,.ps TSQL2 Language Specification, published in September, 1994 bookspec.ps TSQL2 Language Specification, as it appears in the TSQL2 book, published in September, 1995 (see below). sql3 change proposals submitted to the ANSI and ISO SQL3 committees. Associated with the language specification is a collection of commentaries which discuss design decisions, provide examples, and consider how the language may be implemented. These commentaries were originally proposals to the TSQL2 Language Design Committee. They now serve a different purpose: to provide examples of the constructs, motivate the many decisions made during the language design, and compare TSQL2 with the many other language proposals that have been made over the last fifteen years. It should be emphasized that these commentaries are not part of the TSQL2 language specification per se, but rather supplement and elaborate upon it. The language specification proper is the final word on TSQL2. The commentaries, along with the language specification, several indexes, and other supporting material, has been published as a book: Snodgrass, R.T., editor, The TSQL2 Temporal Query Language, Kluwer Academic Publishers, 1995, 674+xxiv pages. The evaluation commentary appears in the book in an abbreviated form; the full commentary is provided in this directory as file eval.ps The file tl2tsql2.pl is a prolog program that tranlates allowed temporal logic to TSQL2. This program was written by Michael Boehlen He may be contacted for a paper that describes this translation. This is a rather dated version of that program. Newer versions are available at (the TimeDB and Tiger systems).29.9 Part 0 - Acquiring ISO/ANSI SQL DocumentsThis document shows you how to (legally) acquire a copy of the SQL-92 standard and how to acquire a copy of the "current" SQL3 Working Draft. The standard is copyrighted ANSI standard by ANSI, the ISO standard by ISO. There are two (2) current SQL standards, an ANSI publication and an ISO publication. The two standards are word-for-word identical except for such trivial matters as the title of the document, page headers, the phrase "International Standard" vs "American Standard", and so forth. Buying the SQL-92 Standard The ISO standard, ISO/IEC 9075:1992, Information Technology - Database Languages - SQL, is currently (March, 1993) available and in stock from ANSI at:
at a cost of US$230.00. The ANSI version, ANSI X3.135-1992, American
National Standard for Information Systems - Database Language SQL, was
not available from stock at this writing, but was expected to be
available by some time between late March and early May, 1993). It is
expected to be be priced at US$225.00.
If you purchase either document from ANSI, it will have a handling charge of 7% added to it (that is, about US$9.10). Overseas shipping charges will undoubtedly add still more cost. ANSI requires a hardcopy of a company purchase order to accompany all orders; alternately, you can send a check drawn on an US bank in US dollars, which they will cash and clear before shipping your order. (An exception exists: If your organization is a corporate member of ANSI, then ANSI will ship the documents and simply bill your company.) The ISO standard is also available outside the United States from local national bodies (country standardization bodies) that are members of either ISO (International Organization for Standardization) or IEC (International Electrotechnical Commission). Copies of the list of national bodies and their addresses are available from ANSI or from other national bodies. They are also available from ISO:
If you prefer to order the standard in a more convenient and quick
fashion, you'll have to pay for the privilege. You can order ISO/IEC
9075:1992, Information Technology - Database Languages - SQL, from:
for a cost of US$308.00. I do not know if that includes shipping or not,
but I would guess that international shipping (at least) would cost
extra. They will be able to ship you a document fairly quickly and will
even accept "major credit cards". Global does not yet have the ANSI
version nor do they have a price or an expected date (though I would
expect it within a few weeks following the publication by ANSI and at a
price near US$300.00).
Buying a copy of the SQL3 Working Draft You can purchase a hardcopy of the SQL3 working draft from the ANSI X3 Secretariat, CBEMA (Computer and Business Equipment Manufacturers Association). They intend to keep the "most recent" versions of the SQL3 working draft available and sell them for about US$60.00 to US$65.00. You can contact CBEMA at:
Lynn Barra can also be reached by telephone at +1.202.626.5738 to
request a copy, though mail is probably more courteous.
Electronic Access to the SQL3 Working Draft The most recent version (as of the date of this writing) of the SQL3 (both ANSI and ISO) working draft (and all of its Parts) is available by "anonymous ftp" or by "ftpmail" on:
In this directory are a number of files. There are PostScript. files
and "plain text" (not prettily formatted, but readable on a screen
without special software).
In general, you can find files with names like:
As new versions of the documents are produced, the "mar94" will change
to indicate the new date of publication (e.g., "aug94" is the expected
date of the next publication after "mar94").
In addition, for those readers unable to get a directory listing by FTP, we have placed a file with the name:
into the same directory. This file (surprise!) contains a directory
listing of the directory.
Retrieving Files Directly Using ftp This is a sample of how to use FTP. Specifically, it shows how to connect to gatekeeper.dec.com, get to the directory where the base document is kept, and transfer the document to your host. Note that your host must have Internet access to do this. The login is 'ftp' and the password is your email address (this is sometimes referred to as 'anonymous ftp'). The command 'type binary' is used to ensure that no bits are stripped from the file(s) received. 'get' gets one file at a time. Comments in the script below are inside angle brackets < like so > .
Retrieving Files Without Direct ftp Support
Digital Equipment Corporation, like several other companies, provides ftp email service. The response can take several days, but it does provide a service equivalent to ftp for those without direct Internet ftp access. The address of the server is: ftpmail@decwrl.dec.com The following script will retrieve the PostScript for the latest version of the SQL3 document:
The following script will retrieve the PostScript for the latest version
of the SQL3 document:
The first line in the script commands the server to return the requested
files to you; you should replace "joe.programmer@imaginary-corp.com"
with your Internet address. The file in this example, x3h2-93-091.ps,
is returned in "compress"ed "uuencode"d format as 34 separate email
messages. If your environment does not provide tools for reconstructing
such files, then you could retrieve the file as plain text with the
following script:
But be warned, the .ps file will probably be sent to you in more than 70
parts!
To retrieve any particular file, other than x3h2-93-091.ps, simply replace "x3h2-93-091.ps" with the name of the desired file. To get a directory listing of all files available, replace "get x3h2-93-091.ps" with "dir". 29.10 Part 1 - ISO/ANSI SQL Current StatusThis chapter is a source of information about the SQL standards process and its current state. Current Status: Development is currently underway to enhance SQL into a computationally complete language for the definition and management of persistent, complex objects. This includes: generalization and specialization hierarchies, multiple inheritance, user defined data types, triggers and assertions, support for knowledge based systems, recursive query expressions, and additional data administration tools. It also includes the specification of abstract data types (ADTs), object identifiers, methods, inheritance, polymorphism, encapsulation, and all of the other facilities normally associated with object data management. In the fall of 1996, several parts of SQL3 went through an ISO CD ballot. Those parts were SQL/Framework, SQL/Foundation, and SQL/Bindings. Those ballots failed (as expected) with 900 or so comments. In Late January, there was an ISO DBL editing meeting that processed a large number of problem solutions that were either included with ballot comments or submitted as separate papers. Since the DBL editing meeting was unable to process all of the comments, the editing meeting has been extended. The completion of the editing meeting is scheduled for the end of July, 1997, in London. Following the July editing meeting, the expectation is that a Final CD ballot will be requested for these parts of SQL. The Final CD process will take about 6 months and a DBL editing meeting, after which there will be a DIS ballot and a fairly quick IS ballot. The ISO procedures have changed since SQL/92, so the SQL committees are still working through the exact details of the process. If everything goes well, these parts of SQL3 will become an official ISO/IEC standard in late 1998, but the schedule is very tight. In 1993, the ANSI and ISO development committees decided to split future SQL development into a multi-part standard. The Parts are:
In the USA, the entirety of SQL3 is being processed as both an ANSI Domestic ("D") project and as an ISO project. The expected time frame for completion of SQL3 is currently 1999. The SQL/CLI and SQL/PSM are being processed as fast as possible as addendums to SQL-92. In the USA, these are being processed only as International ("I") projects. SQL/CLI was completed in 1995. SQL/PSM should be completed sometime in late 1996. In addition to the SQL3 work, a number of additional projects are being persued:
Standards Committee and Process There are actually a number of SQL standards committees around the world. There is an international SQL standards group as a part of ISO. A number of countries have committees that focus on SQL. These countries (usually) send representatives to ISO/IEC JTC1/SC 21/WG3 DBL meetings. The countries that actively participate in the ISO SQL standards process are:
NIST Validation SQL implementations are validated (in the Unites States) by the National Institute of Standards and Training (NIST). NIST currently has a validation test suite for entry level SQL-92. The exact details of the NIST validation requirements are defined as a Federal Information Processing Standard (FIPS). The current requirements for SQL are defined in FIPS 127-2. The Postscript and Text versions of this document can be retrieved from NIST. The current SQL Validated Products List can also be retrieved from NIST. Standard SQL Publications and Articles There are two versions of the SQL standard. Both are available from ANSI:
The two versions of the SQL standard are identical except for the front matter and references to other standards. Both versions are available from:
In additon to the SQL-92 standard, there is now a Technical Corrigendum (bug
fixes):
TC 1 should also be available from ANSI. There is only an ISO version of TC
1 -- it applies both to the ISO and ANSI versions of SQL-92.
In addition to the standards, several books have been written about the 1992 SQL standard. These books provide a much more readable description of the standard than the actual standard. Related Standards A number of other standards are of interest to the SQL community. This section contains pointers to information on those efforts. These pointers will be augmented as additional information becomes available on the web.
29.11 Part 2 - ISO/ANSI SQL FoundationA significant portion of the SQL3 effort is in the SQL Foundation document:
There are several prerequisites to the object oriented capabilities:
These capabilities are defined as a part of SQL/PSM A great deal of work is currently being done to refine the SQL-3 object model and align it with the object model proposed by ODMG. This effort is described in the X3H2 and ISO DBL paper: Accomodating SQL3 and ODMG. A recent update on the SQL3/OQL Merger is also available. SQL3 Timing Work on SQL3 is well underway, but the final standards is several years away.
The ANSI version of the standard will be on a similar schedule. 29.12 Part 3 - ISO/ANSI SQL Call Level InterfaceThe SQL/CLI is a programing call level interface to SQL databases. It is designed to support database access from shrink-wrapped applications. The CLI was originally created by a subcommittee of the SQL Access Group (SAG). The SAG/CLI specification was published as the Microsoft Open DataBase Connectivity (ODBC) specification in 1992. In 1993, SAG submitted the CLI to the ANSI and ISO SQL committees. (The SQL Access Group has now merged with X/Open consortium.) SQL/CLI provides an international standard for:
SQL/CLI Timing For the standards process, SQL/CLI is being processed with blinding speed.
29.13 Part 4 - ISO/ANSI SQL Persistent Stored ModulesSQL/PSM expands SQL by adding:
In addition to being a valuable application development tool, SQL/PSM provides the foundation support for the object oriented capabilities in SQL3. Multi-statement and Stored Procedures Multi-statement and stored procedures offer a variety of advantages in a client/server environment:
Procedural Language Extensions Procedural language add the power of a traditional programming language to SQL through flow control statements and a variety of other programming constructs. Flow Control Statements
The procedural language extensions include other programming language constructs:
In addition, all of the traditional SQL statements can be included in multi-statement procedures. External Procedure and Function Calls One feature frequently mentioned in the wish lists for many database products, and implemented in some, is a capability augmenting the built-in features with calls to user-written procedures external to the database software.
The benefit of this capability is that it gives the database (and therefore database applications) access to a rich set of procedures and functions too numerous to be defined by a standards committee. SQL/PSM Timing SQL/PSM is proceeding quickly:
29.14 Part 5 - ISO/ANSI SQL/BindingsFor ease of reference, the programming language bindings have been pulled out into a separate document. The current version is simply an extract of the dynamic and embedded bindings from SQL-92. A variety of issues remain unresolved for the programming language bindings. For traditional programming language, mappings exist for the SQL-92 datatypes. However, mappings must be defined between SQL objects and programming language variables. For object oriented languages, mapping must be defined for the current SQL datatypes and between the SQL object model and the object model of the object-oriented language. The object model needs to stabilize before these can be addressed. The language bindings will be completed as a part of SQL3. 29.15 Part 6 - ISO/ANSI SQL XA Interface Specialization (SQL/XA)This specification would standardize an application program interface (API) between a global Transaction Manager and an SQL Resource Manager. It would standardize the function calls, based upon the semantics of ISO/IEC 10026, "Distributed Transaction Processing", that an SQL Resource Manager would have to support for two-phase commit. The base document is derived from an X/Open publication, with X/Open permission, that specifies explicit input and output parameters and semantics, in terms of SQL data types, for the following functions: xa_close, xa_commit, xa_complete, xa_end, xa_forget, xa_open, xa_prepare, xa_recover, xa_rollback, and xa_start. ISO is currently attempting to fast-track the X/Open XA specification. The fast-track process adopts a current industry specification with no changes. The XA fast-track ballot at the ISO SC21, JTC 1 level started on April 27, 1995 and ends on October 27, 1995. If the XA specification is approved by 75% of the votes, and by 2/3 of the p-members of JTC 1, it will become an International Standard. If the fast-track ballot is approved, SQL/XA could become a standard in 1996. 29.16 Part 7 - ISO/ANSI SQL TemporalTemporal SQL deals with time-related data. The concept is that it is useful to query data to discover what it looked like at a particular point in time. Temporal SQL is a December, 1994 paper by Rick Snodgrass describing the concepts. X3 Announces the Approval of a New Project, ISO/IEC 9075 Part 7: SQL/Temporal is a press release related to SQL/Temporal.
Several people have questioned the need for additional support for time in
SQL3 (as proposed by DBL RIO-75, requesting a new part of SQL to support
temporal databases). The claim is that abstract data types (ADT's) are
sufficient for temporal support. In this informational item, I argue, using
concrete examples, that using columns typed with abstract data types is
inadequate for temporal queries. In particular, many common temporal queries
are either difficult to simulate in SQL, or require embedding SQL in a
procedural language. Alternatives are expressed in TSQL2, a temporal
extension to SQL-92.
INTRODUCTIONValid-time support goes beyond that of a temporal ADT. With the later, a column is specified as of a temporal domain, such as DATE or INTERVAL (examples will be given shortly). With valid time, the rows of a table vary over time, as reality changes. The timestamp associated with a row of a valid-time table is interpreted by the query language as the time when the combination of values of the columns in the row was valid. This implicit timestamp allows queries to be expressed succinctly and intuitively. A CASE STUDY - STORING CURRENT INFORMATIONThe University of Arizona's Office of Appointed Personnel has some information in a database, including each employee's name, their current salary, and their current title. This can be represented by a simple table.
Given this table, finding an employee's salary is easy.
Now the OAP wishes to record the date of birth. To do so, a column is added
to the table, yielding the following schema.
Finding the employee's date of birth is analogous to determining the salary.
A CASE STUDY - STORING HISTORY INFORMATIONThe OAP wishes to computerize the employment history. To do so, they append two columns, one indicating when the information in the row became valid, the other indicating when the information was no longer valid. Employee (Name, Salary, Title, DateofBirth, Start DATE, Stop DATE) To the data model, these new columns are identical to DateofBirth. However, their presence has wide-ranging consequences. A CASE STUDY - PROJECTIONTo find an employee's current salary, things are more difficult.
This query is more complicated than the previous one. The culprit is
obviously the two new columns. The OAP wants to distribute to each employee
their salary history. Specifically, for each person, the maximal intervals
at each salary needs to be determined. Unfortunately, this is not possible
in SQL. An employee could have arbitrarily many title changes between salary
changes.
Note that there are three rows in which Bob's salary remained constant at
$70,000. Hence, the result should be two rows for Bob.
One alternative is to give the user a printout of Salary and Title
information, and have user determine when his/her salary changed. This
alternative is not very appealing or realistic. A second alternative is to
use SQL as much as possible.
repeat
The loop finds those intervals that overlap or are adjacent and thus should
be merged. The loop is executed log N times in the worst case, where N is
the number of rows in a chain of overlapping or adjacent value-equivalent
rows. The reader can simulate the query on the example table to convince
him/herself of its correctness.
A third alternative is to use SQL only to open a cursor on the table. A linked list of periods is maintained, each with a salary. This linked list should be initialized to empty.
iterate through linked list, printing out dates and salaries
The linked list may not be necessary in this case if the cursor is ORDER BY Start. In any case, the query, a natural one, is quite difficult to express using the facilities present in SQL-92. The query is trivial in TSQL2.
A CASE STUDY - JOINA more drastic approach is to avoid the problem of extracting the salary history by reorganizing the schema to separate salary, title, and date of birth information (in the following, we ignore the date of birth, for simplicity).
The Employee1 table is as follows.
Here is the example Employee2 table.
With this change, getting the salary information for an employee is now
easy.
But what if the OAP wants a table of salary, title intervals (that is,
suppose the OAP wishes a table to be computed in the form of Figure 1)? One
alternative is to print out two tables, and let the user figure out the
combinations. A second alternative is to use SQL entirely. Unfortunately,
this query must do a case analysis of how each row of Employee1 overlaps
each row of Employee2; there are four possible cases.
Getting all the cases right is a challenging task. In TSQL2, performing a
temporal join is just what one would expect.
A CASE STUDY - AGGREGATESNow the OAP is asked, what is the maximum salary? Before adding time, this was easy.
Now that the salary history is stored, we'd like a history of the maximum
salary over time. The problem, of course, is that SQL does not provide
temporal aggregates. The easy way to do this is to print out the
information, and scan manually for the maximums. An alternative is to be
tricky and convert the snapshot aggregate query into a non-aggregate query,
then convert that into a temporal query. The non-aggregate query finds those
salaries for which a greater salary does not exist.
Converting this query into a temporal query is far from obvious. The
following is one approach.
This approach creates an auxiliary table. We add to this table the lower
period of a period subtraction and the upper period of a period subtraction.
We then delete all periods that overlap with some row defined by the
subquery, thereby effecting the NOT EXISTS. Finally we generate from the
auxiliary table maximal periods, in the same way that the salary information
was computed above. As one might imagine, such SQL code is extremely
inefficient to execute, given the complex nested queries with inequality
predicates.
A third alternative is to use SQL as little as possible, and instead compute the desired maximum history in a host language using cursors. The query in TSQL2 is again straightforward and intuitive.
SUMMARYTime-varying data is manipulated in most database applications. Valid-time support is absent in SQL. Many common temporal queries are either difficult to simulate in SQL, or require embedding SQL in a procedural language, due to SQL's lack of support for valid-time tables in its data model and query constructs. Elsewhere, we showed that adding valid-time support requires few changes to the DBMS implementation, can dramatically simplify some queries and enable others, and can later enable optimizations in storage structures, indexing methods, and optimization strategies that can yield significant performance improvements. With a new part of SQL3 supporting time-varying information, we can begin to address such applications, enabling SQL3 to better manage temporal data.
-- Accredited Standards Committee
X3, Information Technology is announcing the approval of a new
project on SQL/Temporal Support, ISO/IEC 9075 Part 7, with the work
being done in Technical Committee X3H2, Database.
The scope of this proposed standard specifies a new Part of the emerging
SQL3 standard, e.g., Part 7, Temporal SQL, to be extensions to the SQL
language supporting storage, retrieval, and manipulation of temporal data
in an SQL database environment.
The next X3H2 meeting is scheduled for March 11-14, 1996 in
Kansas.
Inquiries regarding this project should be sent to the
An initial call for possible patents and other pertinent issues
(copyrights, trademarks) is now being issued. Please submit
information on these issues to the
29.17 Part 8 - ISO/ANSI SQL MULTIMEDIA (SQL/MM)A new ISO/IEC international standardization project for development of an SQL class library for multimedia applications was approved in early 1993. This new standardization activity, named SQL Multimedia (SQL/MM), will specify packages of SQL abstract data type (ADT) definitions using the facilities for ADT specification and invocation provided in the emerging SQL3 specification. SQL/MM intends to standardize class libraries for science and engineering, full-text and document processing, and methods for the management of multimedia objects such as image, sound, animation, music, and video. It will likely provide an SQL language binding for multimedia objects defined by other JTC1 standardization bodies (e.g. SC18 for documents, SC24 for images, and SC29 for photographs and motion pictures). The Project Plan for SQL/MM indicates that it will be a multi-part standard consisting of an evolving number of parts. Part 1 will be a Framework that specifies how the other parts are to be constructed. Each of the other parts will be devoted to a specific SQL application package. The following SQL/MM Part structure exists as of August 1994:
There are a number of standards efforts in the area of Spatial and Geographic information:
30. Technical support for PostgreSQLThis is the order of problem solving:
30.1 Commercial SupportPostgreSQL organisation is selling technical support to companies, the revenue generated will be used for maintaining several mirror sites (web and ftp) around the world. The revenue will also be used to produce printed documentation, guides, textbooks which will help the customers. They are at http://www.postgresql.org Another company called 'Great Bridge Corporation' is doing development, sales and support of PostgreSQL. They are at http://www.greatbridge.com. It is a public company setup by 'Landmark Communications corp' and other venture capital firms to exclusively sell and support PostgreSQL to very large enterprises and corporations all over the world. You can also take help from professional consulting firms like RedHat, Anderson, WGS (Work Group Solutions). Contact them for help, since they have very good expertise in "C", "C++" (PostgreSQL is written in "C") -
31. Economic and Business AspectsCommercial databases pay many taxes like federal, state, sales, employment, social security, medicare taxes, health care for employees, bunch of benefits for employees, marketing and advertisement costs. All these costs do not go directly for the development of the database and do not improve the quality or technology of the database. When you buy a commercial database, some portion of the amount goes for overheads like taxes, expenses and balance for database R&D costs. Also commercial databases have to pay for buildings/real-estates and purchase Unix machines, install and maintain them. All of these costs are passed onto customers. PostgreSQL has the advantage over commercial databases as there is no direct taxes since it is made on the internet. A very vast group of people contribute to the development of the PostgreSQL. For example, in a hypothetical case, if there are one million companies in U.S.A and each contribute about $ 10 (worth of software to PostgreSQL) then each and every company will get ten million dollars!! This is the GREAT MAGIC of software development on internet. Currently, PostgreSQL source code is about 2,50,000 lines of "C", "C++" code. If cost of each line of "C" code is $ 2 then the PostgreSQL is worth about $ 5,00,000 (half a million dollars!). Many companies already develop in-house vast amount of "C", "C++" code. Hence by taking in the source code of PostgreSQL and collaborating with other companies on internet will greatly benefit the company saving time and efforts. 32. List of Other DatabasesListed below are other SQL databases for Unix, Linux.
33. Internet World Wide Web Searching TipsInternet is very vast and it has vast number of software and has an ocean of information underneath. It is growing at the rate of 300% annually world wide. It is estimated that there are about 10 million Web sites world wide! To search for an information you would use search engines like "Yahoo", "Netscape", "Lycos" etc. Go to Yahoo, click on search. Use filtering options to narrow down your search criteria. The default search action is "Intelligent search" which is more general and lists all possiblities. Click on "Options" to select "EXACT phrase" search, "AND" search, "OR" search, etc.. This way you would find the information you need much faster. Also in the search menu, there are radio-buttons for searching in Usenet, Web-sites and Yahoo sites. 34. ConclusionAfter researching all the available databases which are free and source code is available, it was found that ONLY PostgreSQL is the MOST mature, most widely used and robust RDBMS SQL free database (object relational) in the world. PostgreSQL is very appealing since lot of work had already been done. It has ODBC and JDBC drivers, using these it is possible to write applications independent of the databases. The applications written in PostgreSQL using ODBC, JDBC drivers are easily portable to other databases like Oracle, Sybase and Informix and vice versa. You may ask "But why PostgreSQL ?" The answer is, since it takes lot more time to develop a database system from scratch, it makes sense to pick up a database system which satisfies the following conditions - A database system
35. FAQ - Questions on PostgreSQLPlease refer to the latest version of FAQ for General, Linux and Irix at 36. Other Formats of this DocumentThis document is published in 11 different formats namely - DVI, Postscript, Latex, Adobe Acrobat PDF, LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages and SGML.
LaTeX documents may be converted into PDF files simply by producing a Postscript output using sgml2latex ( and dvips) and running the output through the Acrobat distill ( http://www.adobe.com) command as follows: bash$ man sgml2latex bash$ sgml2latex filename.sgml bash$ man dvips bash$ dvips -o filename.ps filename.dvi bash$ distill filename.ps bash$ man ghostscript bash$ man ps2pdf bash$ ps2pdf input.ps output.pdf bash$ acroread output.pdf & Or you can use Ghostscript command ps2pdf. ps2pdf is a work-alike for nearly all the functionality of Adobe's Acrobat Distiller product: it converts PostScript files to Portable Document Format (PDF) files. ps2pdf is implemented as a very small command script (batch file) that invokes Ghostscript, selecting a special "output device" called pdfwrite. In order to use ps2pdf, the pdfwrite device must be included in the makefile when Ghostscript was compiled; see the documentation on building Ghostscript for details. This howto document is located at - Also you can find this document at the following mirrors sites -
In order to view the document in dvi format, use the xdvi program. The xdvi program is located in tetex-xdvi*.rpm package in Redhat Linux which can be located through ControlPanel | Applications | Publishing | TeX menu buttons. To read dvi document give the command -
And resize the window with mouse.
To navigate use Arrow keys, Page Up, Page Down keys, also
you can use 'f', 'd', 'u', 'c', 'l', 'r', 'p', 'n' letter
keys to move up, down, center, next page, previous page etc.
To turn off expert menu press 'x'.
You can read postscript file using the program 'gv' (ghostview) or 'ghostscript'. The ghostscript program is in ghostscript*.rpm package and gv program is in gv*.rpm package in Redhat Linux which can be located through ControlPanel | Applications | Graphics menu buttons. The gv program is much more user friendly than ghostscript. Also ghostscript and gv are available on other platforms like OS/2, Windows 95 and NT, you view this document even on those platforms.
To read postscript document give the command -
CAUTION: This document is large, total number of pages (postscript)
if printed will be approximately 113 pages.
You can read HTML format document using Netscape Navigator, Microsoft Internet explorer, Redhat Baron Web browser or any of the 10 other web browsers. You can read the latex, LyX output using LyX a X-Windows front end to latex. 37. Copyright and LicenseCopyright Al Dev (Alavoor Vasudevan) 1997-2000. License policy is GNU/GPL as per LDP (Linux Documentation project). LDP is a GNU/GPL project. Additional restrictions are - you must retain the author's name, email address and this copyright notice on all the copies. If you make any changes or additions to this document then you should intimate all the authors of this document. NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall the author/authors of this document be liable for any damages whatsoever (including without limitation, special, incidental, consequential, or direct/indirect damages for personal injury, loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of this document. Author/authors offers no warranties or guarantees on fitness, usability, merchantability of this document. Brands, companies and product names mentioned in this document are trademarks or registered trademarks of their respective holders. Please refer to individual copyright notices of brands, companies and products mentioned in this document. It is your responsibility to read and understand the copyright notices of the organisations/companies/products/authors mentioned in this document before using their respective information. 38. Appendix A - Syntax of ANSI/ISO SQL 1992
39. Appendix B - SQL Tutorial for beginners
39.1 Tutorial for PostgreSQLSQL tutorial is also distributed with PostgreSQL. The SQL tutorial scripts is in the directory src/tutorial 39.2 Internet URL pointersThe SQL tutorial for beginners can be found at
Comments or suggestions? Mail to
39.3 On-line SQL tutorialsVisit the following sites for on-line SQL tutorials
40. Appendix C - Linux Quick Install InstructionsIf you are planning to use PostgreSQL on Linux, and need help in installing Linux, then please visit the pointers given in this Appendix. They cover the following topics -
41. Appendix C - Midgard InstallationRPMs for Midgard from http://www.midgard-project.org/download/binaries currently do not include PostgreSQL, and hence you need to install from the source tar ball file . Download the Midgard source tarball and read the INSTALL.REDHAT file - bash# cd midgard-lib-1.4beta6 bash# ./configure --prefix=/usr/local --with-mysql=/usr/local --includedir=/usr/include/mysql --with-midgard=/usr/local --with-pgsql=/var/lib/pgsql --includedir=/usr/include/pgsql bash# make bash# make install bash# ldconfig -v | grep -i midga Copy the header files, just in case make install did not do that.. bash# cp *.h /usr/local/include bash# cd ../mod_midgard-1.4beta5c bash# ./configure --prefix=/usr/local --with-mysql=/usr/local --includedir=/usr/include/mysql --with-midgard=/usr --with-pgsql=/var/lib/pgsql --includedir=/usr/include/pgsql bash# make bash# make install #modify apache line to correct /usr/..... bash# vi /etc/httpd/conf/httpd.conf (or it is /etc/apache/httpd.conf) bash# /etc/init.d/apache restart #apache should restart!!! bash# cd ../midgard-php-1.4beta6 bash# ./configure '--with-apxs' '--with-mysql' '--with-pgsql' '--with-midgard' --prefix=/usr/local --with-midgard=/usr/local bash# gvim Makefile And add -I/usr/include/pgsql to INCLUDE variable. Also add $(INCLUDE) to $(APXS) command as below - libphp3.so: mod_php3.c libmodphp3-so.a pcrelib/libpcre.a midgard/libphpmidgard.a -@test -f ./mod_php3.c || test -L ./mod_php3.c || $(LN_S) $(srcdir)/mod_php3.c ./mod_php3.c -@test -f ./mod_php3.c || test -h ./mod_php3.c || $(LN_S) $(srcdir)/mod_php3.c ./mod_php3.c $(APXS) -c -o libphp3.so -I$(srcdir) $(INCLUDE) -I. -I/usr/local/include -I/usr/lib/glib/include -Wl,'-rpath /usr/local/lib' ./mod_php3.c libmodphp3-so.a $(APXS_LDFLAGS) bash# make bash# make install #modify apache line to correct /usr/..... # and add lines like these - LoadModule php4_module modules/libphp4.so AddModule mod_php4.c LoadModule php4_module lib/apache/libphp4.so <IfModule mod_php4.c> AddType application/x-httpd-php4 .php4 AddType application/x-httpd-php4 .php AddType application/x-httpd-php4-source .phps AddType application/x-httpd-php .php </IfModule> bash# vi /etc/httpd/conf/httpd.conf (or it is /etc/apache/httpd.conf) bash# /etc/init.d/apache restart #apache should restart!!! 41.1 Testing Midgard PHP ServerTo test the installation do this - Create a file in your document root directory. I usually call it info.php and in it put this single line: <?phpinfo()?> Then load it up in your browser: http://localhost/info.php You should see a nice summary page showing all sorts of information about your setup. You probably shouldn't leave this file around on a production server, but for debugging and general info during development, it is very handy. 41.2 Security OpenSSLYou may also need to get the RSA package for to enable SSL encryption from ftp://ftp.deva.net/pub/sources/crypto/rsaref20.1996.tar.Z See also OpenSSL RPM package on Linux cdrom ( http://www.openssl.org If you do not want the SSL to be enabled (or if you face any problem), then download the source RPM of Apache-Midgard and edit the *.spec file and comment out SSL and rebuild the RPM. |
||||||
|