• Home
  • Services
    • DBA Support
    • DBA Consultancy Services
    • PostgreSQL Support
    • Website Maintenance
  • Courses

    About Courses

    • List Of Courses
    • Become an Instructor
    Greenplum Database

    Greenplum Database

    $2,000.00 $1,500.00
    Read More
  • Company
    • FAQs
    • About Us
    • Contact
  • Events
  • Portfolio
  • Blogs
    • Blog – RayaFeeL
    • Blog – PostgreSQL Support
    • Blog – PostgreSQL Migration
    • Blog – All DB’s
    • Blog – Linux
    • Blog – Medical Coding
      • Cart

        0

    Have any question?
    (+91)8838953252
    ITsupport@rayafeel.com
    RegisterLogin
    RayaFeeL
    • Home
    • Services
      • DBA Support
      • DBA Consultancy Services
      • PostgreSQL Support
      • Website Maintenance
    • Courses

      About Courses

      • List Of Courses
      • Become an Instructor
      Greenplum Database

      Greenplum Database

      $2,000.00 $1,500.00
      Read More
    • Company
      • FAQs
      • About Us
      • Contact
    • Events
    • Portfolio
    • Blogs
      • Blog – RayaFeeL
      • Blog – PostgreSQL Support
      • Blog – PostgreSQL Migration
      • Blog – All DB’s
      • Blog – Linux
      • Blog – Medical Coding
        • Cart

          0

      Blog

      • Home
      • Blog
      • Blog
      • How to append the postgres data in production server ?

      How to append the postgres data in production server ?

      • Posted by 2ndnijam
      • Categories Blog
      • Date February 27, 2019
      • Comments 0 comment

      I have a table name is nijam, that table contains 63017 records and have csv excel data contains 586128 records so want to append the data in nijam table for this task you have to following below steps

      Sample DATA ‘s are

      id,code,name,date,
      63202,63202,tdba,,now(),
      Note : after tdba null value and system time is there, while copying it need to insert null values then server time for those purpose you can use "NULL" and now() keyword

      Taking nijam table backup before appending the records below command will help you to take table level backup

      create table postgre.nijam_temp As select * from postgre.nijam;
      nijam_db=# create table postgre.nijam_temp As select * from postgre.nijam;
      SELECT 63017

      Then count the records before appending the data below command will help you to count the records :
      select count(*) from postgre.nijam_temp;

      nijam_db=# select count(*) from postgre.nijam_temp;
      count
      -------
      63017
      (1 row)

      Then issue the COPY command against nijam_temp table then count the records if everything is ok ,then you can do directly into source table means nijam table, Below command will help you to copy or append data into table

      \COPY postgre.nijam_temp FROM '/home/missing_data.csv' delimiter ',' CSV header NULL AS 'null';
      nijam_db=# \COPY postgre.nijam_temp FROM '/home/missing_data.csv' delimiter ',' CSV header NULL AS 'null';
      COPY 586128

      Explanation :

      • , – Data splitting by delimiter
      • NULL AS  ‘null’ – Inserting NULL values id record is empty
      • HEADER – Excel sheet having header name like id,name,date

      Counting temporary table’s records

      nijam_db=# select count(*) from postgre.nijam_temp;
      count
      --------
      649145
      (1 row)

      Why we are appending data  initially on temporary table means if we get any issue or error while copying data means source table may be collapse for those purpose we are working on temporary table.

      APPENDING DATA INTO SOURCE TABLE OF NIJAM :
      Below steps for appending the data into original table which you have done previously do same like

      Counting the source table records

      select count(*) from postgre.nijam;

      Appending the data into source table

      \COPY postgre.nijam FROM '/home/missing_data.csv' delimiter ',' CSV header NULL AS 'null';

      checking the table rows count below command will help to count the table records

      select count(*) from postgre.nijam

      Tag:copy from.append data, data append, postgres, rows appending

      • Share:
      2ndnijam

      Previous post

      Postgres Extension postgis Database
      February 27, 2019

      Next post

      what are the parameters we need to change if we keep replication in sync mode on postgresql ?
      March 3, 2019

      Leave A Reply Cancel reply

      You must be logged in to post a comment.

      Login with:

      Login with Google Login with Twitter Login with LinkedIn Login with Microsoft


      Search

      ADVERTISEMENT

      Latest Posts

      PostgreSQL Patching version 9, 10,11
      10Oct2019
      Tools for PostgreSQL
      16Sep2019
      Postgres user creation and restrict DDL & database access
      13Sep2019
      PostgreSQL SSL Setup
      07Sep2019
      How to DELETE current XLOG / WAL LOG in postgresql database ?
      19Aug2019

      Latest Courses

      PostgreSQL Database

      PostgreSQL Database

      $600.00 $500.00
      Greenplum Database

      Greenplum Database

      $2,000.00 $1,500.00

      Preview Course

      Free

      Recent Forum Topics

      • thought behind whiteboard activity
      • Are you going to take your first ste
      • How to start working on an application?
      • please let me know pre requirements to increase work_mem
      • how to copy some data in one table to another table in postgres

      2ndquadrant.in

      (+91) 8838953252

      ITsupport@rayafeel.com

      Company

      • About Us
      • Contact
      • Our Team
      • Blog

      COURSES

      • List Of Course
      • Become An Instructor
      • Events
      • Postgres Support Blog

      Support

      • DBA Support
      • Consultancy Services
      • Postgres Migration Blogs
      • Forum

      Recommend

      • Groups
      • Login
      • FAQs
      • SignUp

      IT Services by rayafeel.com. Powered by Rayafeel Technologies Pvt Ltd.

      • Privacy
      • Terms

      Become An Instructor?

      Join thousand of instructors and earn money hassle free!

      Get Started Now

      Login with:

      Login with Google Login with Twitter Login with LinkedIn Login with Microsoft

      Login with your site account

      Lost your password?

      Not a member yet? Register now

      Register a new account

      Are you a member? Login now