In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces PostgreSQL commonly used commands, the text is very detailed, has a certain reference value, interested friends must read!
mydb=# SELECT version(); version ------------------------------------------------------------------------------------------------------- PostgreSQL 9.3.6 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3), 32-bit(1 row) create database mydb=# CREATE DATABASE test;CREATE DATABASE show all databases mydb-# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+---------+----------+-------------+-------------+--------------------- mydb | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | postgres | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | template0 | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgre + | | | | | postgre=CTc/postgre template1 | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgre + | | | | | postgre=CTc/postgre test | postgre | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |(5 rows) Switch current database mydb-# \c testPassword for user postgre: You are now connected to database "test" as user "postgre". Delete database #Cannot delete currently connected database test=# DROP DATABASE test; ERROR: cannot drop the currently open database test =# DROP DATABASE mydb;DROP DATABASE enumerates the current database table test=# create table t as select * from pg_tablespace;SELECT 2test=# \dt List of relations Schema | Name | Type | Owner --------+------+-------+--------- public | t | table |postgre(1 row) View table structure test=# \d t Table "public.t" Column | Type | Modifiers ------------+-----------+----------- spcname | name | spcowner | oid | spcacl | aclitem[] | spcoptions | text[] |rename table test=# alter table t rename to t_t;ALTER TABLEtest=# \dt List of relations Schema | Name | Type | Owner --------+------+-------+--------- public | t_t | table |postgre(1 row) View table index #Create index test=# create index idx_name on t (spcname);CREATE INDEX#Show index test=# \di ; List of relations Schema | Name | Type | Owner | Table --------+----------+-------+---------+------- public | idx_name | index | postgre | t public | idx_t | index | postgre |t_t(2 rows) drop table test=# drop table t_t;DROP TABLE create user test=# CREATE USER sroid;CREATE ROLE#create sovid specify password test=# CREATE USER sroid WITH PASSWORD '123 qwe'; CREATE ROLE view system user information test=# SELECT usename FROM pg_user; usename ------ postgre sroid (2 rows)test=# \du; List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- postgre | Superuser, Create role, Create DB, Replication | {} svoid | | {} Delete user test=# DROP USER sroid;DROP ROLE View schematest=# \dn; List of schemas Name| Owner --------+--------- public |postgre(1 row) Create schematest=# CREATE SCHEMA myschema;CREATE SCHEMA Delete schematest=# DROP SCHEMA myschema;DROP SCHEMA The above is "What are the common commands in PostgreSQL" All the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.