CHAPTER 27 THE MANY POSTGRESQL CLIENTS Storing (Web design company)
CHAPTER 27 THE MANY POSTGRESQL CLIENTS Storing psql Variables and Options Of course, heavy-duty command-line users know that repeatedly entering commonly used commands can quickly become tedious. To eliminate such repetition, you should take advantage of aliases, configuration files, and environment variables at every possibility. To set an environment variable from within psql, just execute the set command followed by the variable name and a corresponding value. For example, suppose your database consists of a table named apressproduct. You re constantly working with this table and, accordingly, are growing sick of typing in its name. You can forego the additional typing by assigning an environment variable, like so: corporate=> set ap ‘apressproduct’ Now it s possible to execute queries using the abbreviated name: corporate=> SELECT name, price FROM :ap; Note that a colon must prefix the variable name in order for it to be interpolated. psql also supports a number of predefined variables. A list of the most commonly used psql variables are presented in Table 27-2. Table 27-2. Commonly Used psql Variables Variable Description PAGER Determines which paging utility is used to page output that requires more space than a single screen. PGDATABASE The presently selected database. PGHOST The name of the server hosting the PostgreSQL database. PGHOSTADDR The IP address of the server hosting the PostgreSQL database. PGPORT The post on which the PostgreSQL server is listening for connections. PGPASSWORD Can be used to store a connecting password. However, this variable is deprecated, so you should use the .pgpass file instead for password storage. PGUSER The name of the connected user. PSQL_EDITOR The editor used for editing a command prior to execution. This feature is particularly useful for editing and executing long commands that you may wish to store in a separate file. After looking to PSQL_EDITOR, psql will then examine the contents of the EDITORand VISUAL variables, if they exist. If examination of all three variables proves inconclusive, notepad.exe is executed on Windows, and vi on all other operating systems. To view a list of all presently set variables, execute set without passing it any parameters, like so: corporate=> set For instance, executing this command on our Ubuntu server produces:
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.