![]() The ‘\q’ command is used to quit the psql in the PostgreSQL. In order to illustrate the effect of ‘\ H’ command for the output format change, we will execute the ‘select * from employee’ command and will have a look at the output.Ģ0. The command’ \H’ is used to format the output in the HTML format. Command to switch output format to HTML format In order to illustrate the effect of ‘\ a’ command for the output format change, we will execute the select * from employee’ command and will have a look at the output.ġ9. Now we will again switch the output format by using ‘\ a’ command. In order to illustrate the effect of ‘\ a’ command for the output format change, we will execute the ‘select * from employee’ command and will have a look at the output. We will switch the output format by using the ‘\ a’ command. The command’ \ a’ is used to switch the output format from aligned to the non-aligned column and vice-versa. Command to switch output format from aligned to the non-aligned column and vice-versa Illustrate the result of the step by using the following snapshot.ġ8. Now we will modify the SQL query in a text editor and close the text editor. We can edit that in the query in a text editor and can run it again. The ‘\e’ command opens the recently executed SQL query in a text editor. ![]() Command to use the psql with the text editor The ‘\g’ command is used to execute the previous command.ġ7. The ‘\timing’ command is used to get the execution time of the SQL query in the PostgreSQL.ġ6. Command to get the execution time of SQL query Illustrate the result of the command by using the following snapshot.ġ5. If we want detailed information about any statement, we can use this command. The ‘\ h’ command lists all SQL commands in the PostgreSQL. We can save the history in the file by using the ‘\s filename’ command.The ‘\ s’ command is used to view the complete history in the PostgreSQL.The ‘\ du’ command lists all the users with their roles. The ‘\ dv’ command is used to list available views in the current database.ġ1. The ‘\ df’ command is used to list all of the functions of the current database. The ‘\ dn’ command is used to list all of the schemas of the current database. The ‘\d table_name’ command is used to describe the table. Illustrate the result of the ‘\ dt’ command by using the following snapshot. The ‘\ dt’ command returns the tables from the current database. Command for listing all of the tables from the current database ![]() The ‘\c db_name ’ command is used to switch the connection to the new database.Ħ. Command to switch database connection to the new database Illustrate the result of the above command by using the following snapshot.ĥ. This command is used to connect to the database. Illustrate the result of the ‘\l’ command by using the following snapshot.Ĥ. The ‘\l’ command returns all of the databases available in PostgreSQL. Command to list all of the available databases Illustrate the result of the ‘SELECT’ command using the following snapshot.ģ. The ‘SELECT VERSION()’ statement returns the version of PostgreSQL. Command to get the version of the PostgreSQL Illustrate the result of the ‘\?’ command by using the following snapshot.Ģ. The ‘\?’ command returns all of the commands available in PostgreSQL. Command to list all commands available in PostgreSQL ![]() Given below are the various meta-commands: 1. The PostgreSQL supports various commands which we can execute from the psql prompt.įirst, we will open the psql prompt, which looks like the following snapshot. List of PostgreSQL Commands with Examples The psql returns 2 if the server connection fails. If the shell command fails because of errors like file not found or out of memory, the psql returns 1. If the shell command finishes without any error, then the psql returns 0. We can give input as command-line arguments or commands from a file. We can use the psql prompt for writing various commands and queries interactively and execute them to the PostgreSQL for having results. The psql prompt is an interactive interface front-end to the PostgreSQL, the same as the terminal provided with its default installation. The PostgreSQL supports various commands which we can execute from the psql prompt. Hadoop, Data Science, Statistics & others Introduction to PostgreSQL Commands ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |