Vertica Database SQL Operations Memo

Source: Internet
Author: User
Tags datetime

  Delete primary key (the primary key value for the Vertica database is not unique):
SELECT analyze_constraints (' Fb_s.c_log ');

Locate 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;

Build users and schemas:

CREATE user fb_s_sql identified by ' password ';
CREATE SCHEMA Fb_s_sql;

gives permission:
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;

Build table:

CREATE table Fb_s.c_log (
uid int not NULL,
Cash int,
Gold int,
level int,
Rtime dat ETime,
Tid varchar (m),
Act varchar,
Item varchar (+),
value int,
value2 int,
time datetime);

CREATE TABLE fb_s.new_c_log (
uid integer PRIMARY KEY not NULL,
Cash integer,
Gold integer,
leve L Integer,
rtime datetime,
tid varchar,
Act varchar,
ITEM varchar,
value integer,
value2 integer,
time datetime not NULL
)
PARTITION by EXTRACT Time) *100 + EXTRACT (month from time); The

is followed by the Time field partition

to 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 ';


Guide 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); Data between

Two libraries:

Exporting in Source Library:

vsql-d topcity-u dbadmin-w password-f ', '-at-o fs_user_info.csv-c ' Sele CT * from Fb_s.user_info; "The
vsql-d topcity-u dbadmin-w password-f ', '-at-o fs_c_log.csv-c" select * from F B_s.c_log

Destination Gallery 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 ' exceptions '/tmp/exp.log ' DELIMITER ', ';

Ps:

Does it feel like the great God has nothing to do, want to worship God's email to zhe-jiang.he@hp.com.

Give me a vote on HP's Tomorrow star, Oh, kiss!

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.