zoukankan      html  css  js  c++  java
  • Vertica数据库操作

      删除主键(Vertica数据库的主键值并非唯一的):
    SELECT ANALYZE_CONSTRAINTS('fb_s.c_log');

    找到key名,再:

    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;

    建用户和SCHEMA :

    CREATE user fb_s_sql IDENTIFIED BY 'password';
    CREATE SCHEMA fb_s_sql;

    给权限:
    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;

    建表:

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

    后一个是按time字段分区

    添加及改动字段:

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


    两表之间导数据:
    insert into fb_s.c_log (uid,cash,gold,level,rtime,tid,act,item,value,value2,time)
    (select * from fb_s.c_logbak);

    两库之间导数据:

    在源库导出:

    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;" &

    目的库导入:
    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 ',';

  • 相关阅读:
    【JavaSE】成员方法快速入门和方法的调用机制原理
    HarmonyOS实战—实现注册登录和修改密码页面
    苹果CMS自动定时采集教程
    HarmonyOS实战—统计按钮点击次数
    HarmonyOS实战—点击更换随机图片
    C语言 main 函数
    C语言 vprintf 函数和 printf 函数区别
    C语言 vprintf 函数
    C语言 va_start / va_end / va_arg 自定义 printf 函数
    C语言 va_arg 宏
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/5143217.html
Copyright © 2011-2022 走看看