PostgreSQL Describe TableIn this section, we are going to discuss how to describe a table in PostgreSQL. In PostgreSQL, to find the information on columns of a table, we can use the describe command query in two different ways, which are as follows:
Note: In PostgreSQL, we cannot have the direct command to Describe the table, but using MySQL, we use the DESCRIBE command directly to identify the information on the columns of a specific table.PostgreSQL DESCRIBE TABLE using pgAdmin 4In pgAdmin 4, we are going to use the information_schema for describing the tables. Here, the information schema itself is a schema that is automatically present in all databases and called information_schema. And by default, it is not available in the schema search path. Thus, if we want to access all objects, we will use it through its qualified names. The user gets all the advantages of the particular schema if the owner of the information schema is the original database user. Meanwhile, in the information schema, the names of some of the objects are generic names, which might be happened in user applications or the software. Therefore, we should be alert if we need to place the information schema on the path. For this, we will use the SELECT command in the information_schema database for quering the column_names of the columns table. For example, the below query will return all column names of the customer table: SQL Query in PgAdmin4The table StructureAfter executing the Select command, we can see the columns_name present in the Customer table. PostgreSQL describe table using psqlIn psql, we can get the information of a table with the help of the below command and to describe the particular tables in the current database: To get the list of tables, we will follow the below steps: Step1
Step2
Step3
Note: The \d command is used to describe a table such as a type, column, modifiers of columns, and so on.Output The following screenshot explains it more clearly: Next TopicPostgreSQL Schema |