The PSequel shell that we installed in the last movie is a command-line interface for working with Postgres database servers. It provides a quick way for administrators to log into the server and run commands, but it's not the most user-friendly environment for new users since it requires that you know what commands you want to run and how to type them out. However, I do think that it's important to see briefly in order to help reinforce the idea that the client application is completely separate from the database server. And PSQL is a very important tool in the world of Postgres development. So let's go ahead and click on it to start it up. When you first run the tool, it opens up a command-line window and starts the login process. In order to log into a Postgres server, you need to know some connection details. If you're in a typical office environment where the Postgres server is running on a centralized computer, then you'll need the IP address of that machine. In our case, we're running the server and client on the same physical machine. So we can use the word localhost instead. You can either type that in or simply press Enter and localhost, the default as indicated by the text in square brackets, will be used instead. I'll just leave this blank and press Enter to enter in localhost. Next, it asks you which database you want to connect to. ![]() Each Postgres server can hold many different databases. Our server is brand new and there's just one database called Postgres, so I'll log into that one. Again, you can press Enter to accept the default value of Postgres. Next, we need the communication port that the server is listening on. This was set up during the installation step, but is typically left at the default of 5432. Then we need to provide the user account credentials. Again, during the installation, we created a superuser account named Postgres. If you've been assigned your own personal user account for your server, you would supply that username here instead. Alternatively, input can be from a file or from command line arguments. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results. dbname username Description psql is a terminal-based front-end to PostgreSQL. Again, we gave the Postgres user account a password during setup. psql psql PostgreSQL interactive terminal Synopsis psql option. So I hope that you remember what you filled in during that step. 0 Comments SELECT is a SQL command that returns information, and we're using a built-in function called version to pull out the. When you type, it's not going to appear on the screen, so just type it out and press Enter when you're done. ![]() If everything was filled in correctly, you should be connected to the Postgres server and the command prompt will change. ![]() Now we can start sending commands to the server. One thing that we can do is get details about the installation. We can do that by running SELECT, version, and then an open and close parentheses. SELECT is a SQL command that returns information, and we're using a built-in function called version to pull out the server version and installation platform information.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |