Vertica database operations, vertica Database

Source: Internet
Author: User

Vertica database operations, vertica Database

Delete a primary key (the primary key value of the Vertica database is not unique ):
SELECT ANALYZE_CONSTRAINTS ('fb _ s. c_log ');

Find the key name, and then:

Alter table fb_s.c_log drop constraint C_PRIMARY;

SELECT ANALYZE_CONSTRAINTS ('fb _ s. user_info ');

Alter table fb_s.user_info drop constraint C_PRIMARY;

Create user and SCHEMA:

CREATE user fb_s_ SQL IDENTIFIED BY 'Password ';
Create schema fb_s_ SQL;

Grant permissions:
Grant all on schema fb_s_ SQL TO fb_s_ SQL;
Grant all on schema fb_s TO fb_s_ SQL;

Grant all on table fb_s_ SQL .sqllog TO fb_s_ SQL;

Table creation:

Create table fb_s.c_log (
Uid int not null,
Cash int,
Gold int,
Level int,
Rtime datetime,
Tid varchar (20 ),
Act varchar (50 ),
Item varchar (500 ),
Value int,
Value2 int,
Time datetime
);

Create table fb_s.new_c_log (
Uid integer primary key not null,
Cash integer,
Gold integer,
Level integer,
Rtime datetime,
Tid varchar (20 ),
Act varchar (50 ),
Item varchar (500 ),
Value integer,
Value2 integer,
Time datetime NOT NULL
)
Partition by extract (year FROM time) * 100 + EXTRACT (month FROM time );

The last one is partitioned by the time field.

Add and modify fields:

Alter table fb_s.c_logADD COLUMN value2 integer default 0;
Alter table fb_s.c_log alter column duration set default 0;
Alter table fb_s.c_log alter column mesg set default '';


Import data between two tables:
Insert into fb_s.c_log (uid, cash, gold, level, rtime, tid, act, item, value, value2, time)
(Select * from fb_s.c_logbak );

Import data between two databases:

Export in source database:

Vsql-d topcity-U dbadmin-w password-F', '-At-o fs_user_info.csv-c "SELECT * FROM fb_s.user_info ;"&
Vsql-d topcity-U dbadmin-w password-F', '-At-o fs_c_log.csv-c "SELECT * FROM fb_s.c_log ;"&

Destination Database Import:
COPY fb_s.user_info FROM '/opt/fs_user_info.csv 'exceptions'/tmp/exp. log 'delimiter ',';

COPY fb_s.c_log FROM '/opt/fs_c_log.csv 'exception'/tmp/exp. log 'delimiter ',';

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.