Copy Paste Table on PostgreSQL

Copy Bulk / besar table gak gampang karena harus copy file di mana cukup take time, triknya sbb:

 

 

PostgreSQL copy table example

The following statement creates a new table named contacts for the demonstration:

In this table, we have two indexes: one index for the primary key and another for the UNIQUE constraint.

Let’s insert some rows into the contacts table:

To copy the contacts to a new table, for example, contacts_backup table, you use the following statement:

This statement creates a new table named contact_backup whose structure is the same as the contacts table. In addition, it copies data from the contacts table to the contact_backup table.

Let’s check the data of the contact_backup table by using the following SELECT statement:

It returns two rows as expected.

To examine the structure of the contact_backup table:

As you can see in the output, the structure of the contact_backup table is the same as the contactstable except for the indexes.

To add the primary key and UNIQUE constraints to the contact_backup table, you use the following ALTER TABLE statements:

To view structure of the contact_backup table again, you use \d command:

In this tutorial, you have learned how to copy an existing table to a new one using the various forms PostgreSQL copy table statement.

 

Belajar dari link ini:

http://www.postgresqltutorial.com/postgresql-copy-table/

Advertisements

SSMTP GMAIL di LINUX

#
# /etc/ssmtp.conf — a config file for sSMTP sendmail.
#
# See the ssmtp.conf(5) man page for a more verbose explanation of the
# available options.
#

# The person who gets all mail for userids < 500
# Make this empty to disable rewriting.
root=it.hollandbakery@gmail.com
#postmaster

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
#mailhub=mail

# Example for SMTP port number 2525
mailhub=smtp.gmail.com:587
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
RewriteDomain=gmail.com

# The full hostname
Hostname=localhost

# Set this to never rewrite the “From:” line (unless not given) and to
# use that address in the “from line” of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
UseTLS=YES
UseSTARTTLS=YES
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/etc/pki/tls/private/ssmtp.pem

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES
Root=admin
AuthUser=xxx@gmail.com
AuthPass=xxx

 

 

jangan lupa Revaliasess nya di ganti ya.

 

 

 

Send Email in Linux Server using SSMTP

sebenernya udah pakai beberapa kali tapi manusia tidak luput dari salah dan Lupa, jadi link yang gua pakai untuk install ini adalah :

http://techgyaan.org/how-to-install-and-configure-ssmtp-on-html/

 

Download & Install
# rpm -Uvhhttp://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# yum -y install ssmtp
Now we will editthe ssmtp configuration file.
# cd /etc/ssmtp
# vim /etc/ssmtp/ssmtp.conf
Here is the custom configuration
MailHub=mail.techgyaan.org:25         # SMTP server hostname and port
UseTLS=NO                             # Secure connection (SSL/TLS)
FromLineOverride=YES                  # Force the From: line
Hostname=mail.techgyaan.org           # The name of this host
RewriteDomain=mail.techgyaan.org      # The host the mail appears to be coming from
Root=Bala                             # Redirect mail for root@ to postmaster@
AuthUser=bala@techgyaan.org           # Your DreamHost mailaccount
AuthPass=myemailpassword              # The password for the mail account
Now let’sconfigure the Aliases
# vim /etc/ssmtp/revaliases
root:alerts@techgyaan.org:mail.techgyaan.org:25
Postmaster:alerts@techgyaan.org:mail.techgyaan.org:25
Bala:bala@techgyaan.org:mail.techgyaan.org:25
If you would like to change the “FromDisplay Name, edit the /etc/passwd and modify theuser alias
# vim /etc/passwd
alerts:Alerts:507:507::/home/alerts:/bin/bash
bala:BALA:505:506::/home/bala:/bin/bash
postmaster:POSTMASTER:505:506::/home/postmaster:/bin/bash
Before we start using sSMTP lets stop thesendmail which is default installed on all Linux distribution.Stop sendmailservice to start after reboot
# service sendmail stop
# sudo chkconfig –levels 2345 sendmail off
Move or replace the sendmail and thencreate
a symbolic link for sSMTP to sendmail with authentication
# mv /usr/sbin/sendmail/usr/sbin/sendmail.orig
# ln -s /usr/sbin/ssmtp/usr/sbin/sendmail
We all done with the installation andconfiguration let’s send a test mail to internal & external email addressusing sSMTP.

echo”Sending Test mail to external & Internal email address”| mail -s”This is the test message using sSMTP” bala@techgyaan.orgbala@gmail.com

 

thank you…

Mount / UnMount Share Drive from window or NAS

using CIFS

jika belum ada bisa di install

sudo apt-get install cifs-utils

Untuk Mount:

  1. buat folder di linux untuk tempat menampung mkdir /homexxxxx
  2.  command mounting: sudo mount.cifs //xx.xxx.xxx.xx/sharefoldel /homexxxxxx/ -o user=userxx
  3. enter dan akan meminta password
  4.  https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/ 

done

 

untuk Un Mount:

  1. sudo umount -a -t cifs -l

https://stackoverflow.com/questions/74626/how-do-you-force-a-cifs-connection-to-unmount 

good luck