Using PostgreSQL
Accessing the SeverPostgreSQL like most modern DBMS uses a client/server model. The server manages the databases while the client provides an interface between the user and the database. The server is typically run as a daemon which is always running on the server system. To use the DBMS, you must connect the client to the server. With PostgreSQL, you use the psql dbname where To connect from a department workstation, enter the following command at the Linux prompt psql -h pascal dbname where
To disconnect from the PostgreSQL server, simply enter the cs481=> \q Changing Your PasswordYou need to change your initial password to something more secure than the one I chose for you. At the cs481=> \password You will be prompted for your new password. After entering your new password, you will be prompted to enter it again. Enter the new password a second time, after which you will be returned to the Working With SchemasMost client/server enterprise level databases provide some mechanism for creating and using sub databases. This allows for easier management and security on a single database in which one person or a group needs to create and work with multiple databases. In PostgreSQL, tables are created and belong to a specific schema. You can think of a schema as a sub database or container within the outer database into which a table can be constructed. You can view a list of the schemas within the database using the psql command
All SQL commands are executed in PostgreSQL within the context of a current schema. In order to use simplified query commands, you need to set the search path to the appropriate schema which identifies the current schema similar to the current working directory on UNIX systems. SET search_path TO gradebook; You can view the list of schemas in the database using the PostgreSQL DBMS command SHOW search_path;
Common CommandsThe command-line provided by the PostgreSQL client application is not only used to enter SQL commands, but also various DBMS commands. In PostgreSQL these commands between with a backslash (
|