PostgreSQL version: Psql (9.3.4)
1. Add a column
Copy Code code as follows:
ALTER TABLE table_name ADD column_name datatype;
2, delete a column
Copy Code code as follows:
ALTER TABLE table_name DROP
Objective
In fact, there are many modules that can be used to connect PostgreSQL in Python, here it is recommended psycopg2. PSYCOPG2 installation is very simple ( pip install psycopg2 ), here is the main focus on how to use.
To connect to a
Fedora
User
To the operation of the database, first transfer to Postgres user
The first time you want to set a password
sudo passwd postgres
Switch to this user
Su-postgres
Database initialization
The first time to do
Gets the maximum value of the self-increment ID in the every_check_accident tableSELECT Last_value from Every_check_accident_id_seq;$list = Db::getinstance (self::D bname)->pg_insert_id (' every_check_accident ', ' id ');View the version of
Official websiteIn addition to simply finding the rows to is returned by a query, an index may is able to deliver them in a specific sorte D order. This allows a query ' s ORDER by specification to be honored without a separate sorting step. Of the
PostgreSQL supports case,coalesce,nullif,greatest,least conditional expressions, and using them can sometimes simplify many feature implementations.Test tableTest=#Create TableTbl_test (IDint, namevarchar( +), Sexvarchar(1));CREATE TABLETest=#Insert
General:\copyright display the use and release license terms for PostgreSQL\g [file] or; Execute the query (and write the results to a file or | pipeline)\h [name] SQL command syntax description, with * Show all commands syntax description\q Exit
This chapter provides an overview of how to perform simple operations using SQL. The purpose of this tutorial is simply to give you an introduction, not a complete SQL tutorial. There are many books on SQL, including understanding the New SQL and A
Up Vote2down Votefavorite
From the article, I tried to update or delete the property of a jsonb column:CREATE TABLE xxx (id bigserial, data jsonb);INSERT into XXX (data) VALUES (' {' A ': 1, ' B ': 2} ');SELECT * from data;ID | Data----+---------
Understanding the interrelationships between PostgreSQL components will make this section clearer.In terms of database terminology, PostgreSQL uses a client/server pattern. A PostgreSQL session consists of the following related processes (Programs):
Index expansion, mainly for B-treeSeveral sources of index bloat:After a large number of deletions, the index pages are sparse, which reduces the efficiency of indexing;PG9.0 the previous version, vacuum full will also cause the index page
PostgreSQL version number: Psql (9.3.4)1. Add a row of ALTER TABLE table_name ADD COLUMN_NAME datatype; 2. Delete a list of ALTER TABLE table_name drop column_name; 3. Change the data type of the
1. Suitable maximum number of connectionsUsed_connections/max_connections is around 85%.2. Modify the maximum number of connectionsPostgreSQL Maximum number of connections defaults to 1001) Open PostgreSQL configuration
To create a table:CREATE TABLE Char(2PRIMARYKEYtextUNIQUE);Insert data:INSERT intocountries (Country_code,country_name)VALUES('US','states'),('MX','Mexico'),('au','Australia'),('GB','Kingdom'),('de','Gemany'),('ll','Loompaland');OrINSERT into
Pgsql partition Table:--Main Table CREATE TABLE test (ID integer, name varchar); CREATE index idx_test_id on test using btree (ID);--Table Create Table Test_b (like test including constraints including defaults including indexes) inherits (test);
There are no problems in the reading process. Welcome to communicate togetherEmail:[email protected]qq:1494713801One, PostgreSQL time type conversion--The time type is converted into character type select To_char (current_date, ' yyyy/mm/dd ');
If you need to create a table with 99 columns, the column names are regular, such as S01,s02,s03 ... Perhaps you would think of the following statementCREATE TABLE tb_sxx (s01 varchar), S02 varchar (TEN), S03 varchar, ... s99 varchar (10));Is there
??Add PostgreSQL apt repo. According to your distribution (Utopic, trusty, Jessie, wheezy and etc):??Deb HTTP://APT.POSTGRESQL.ORG/PUB/REPOS/APT/TRUSTY-PGDG main 9.5??Install PostgreSQL 9.5wget--quiet-o-HTTPS://WWW.POSTGRESQL.ORG/MEDIA/KEYS/ACCC4CF8.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service