ddl

Primary key for multiple column in PostgreSQL?

流过昼夜 提交于 2020-01-22 11:46:26
问题 How to provide primary key for multiple column in a single table using PostgreSQL? Example: Create table "Test" ( "SlNo" int not null primary key, "EmpID" int not null, /* Want to become primary key */ "Empname" varchar(50) null, "EmpAddress" varchar(50) null ); Note: I want to make "EmpID" also a primary key. 回答1: There can only be one primary key per table. That's what the word "primary" hints at. You can have additional UNIQUE columns. CREATE TABLE test( sl_no int PRIMARY KEY, -- NOT NULL

Primary key for multiple column in PostgreSQL?

老子叫甜甜 提交于 2020-01-22 11:45:27
问题 How to provide primary key for multiple column in a single table using PostgreSQL? Example: Create table "Test" ( "SlNo" int not null primary key, "EmpID" int not null, /* Want to become primary key */ "Empname" varchar(50) null, "EmpAddress" varchar(50) null ); Note: I want to make "EmpID" also a primary key. 回答1: There can only be one primary key per table. That's what the word "primary" hints at. You can have additional UNIQUE columns. CREATE TABLE test( sl_no int PRIMARY KEY, -- NOT NULL

MS Access: setting table column Caption or Description in DDL?

ぐ巨炮叔叔 提交于 2020-01-20 08:28:50
问题 Is it possible to set a table column's Caption or Description properties in MS Access using DDL? Ideally, we could include them in a CREATE TABLE statement. 回答1: Use DAO to set Caption and Description properties as Andrea suggested. Just be aware that both Caption and Description are user-defined, not default properties ... meaning that they don't exist before you assign them a value. For example the following statement triggers error 3270, 'Property not found', because I have not assigned a

oracle增删改查基本语法(DDL/DML)整理

两盒软妹~` 提交于 2020-01-18 19:20:53
DDL:Data Definition Language(数据库定义语言) DML:Data Manipulation Language(数据库操作语言) 一、表结构操作(create table、alter table、drop table)   1.创建表 create table tableName(   id number(6) not null primary key ,   class_name varchar2(8) default null,   create_date date   ); comment on column tableName.id is 'id';          #字段注释 comment on column tableName.class_name is '类名'; comment on column tableName.create_date is '创建日期';   2.修改表结构 alter table tableName add constraint id primary key;        #增加约束,id设置为主键 ---------------------------------------------------------------------------- alter table 表名 add constraint

Hive基础sql语法(DDL)

◇◆丶佛笑我妖孽 提交于 2020-01-18 11:20:15
前言: 经过前面的学习 我们了解到Hive可以使用关系型数据库来存储元数据,而且Hive提供了比较完整的SQL功能 ,这篇文章主要介绍Hive基本的sql语法。 首先了解下Hive的数据存储结构,抽象图如下: 1.Database:Hive中包含了多个数据库,默认的数据库为default,对应于HDFS目录是/user/hadoop/hive/warehouse,可以通过hive.metastore.warehouse.dir参数进行配置(hive-site.xml中配置) 2.Table: Hive 中的表又分为内部表和外部表 ,Hive 中的每张表对应于HDFS上的一个目录,HDFS目录为:/user/hadoop/hive/warehouse/[databasename.db]/table 3.Partition:分区,每张表中可以加入一个分区或者多个,方便查询,提高效率;并且HDFS上会有对应的分区目录: /user/hadoop/hive/warehouse/[databasename.db]/table 4.Bucket(桶):暂且不讲 DDL操作(Data Definition Language) 参考官方文档: DDL文档 HiveQL DDL statements are documented here, including: CREATE DATABASE

小米流式平台架构演进与实践

旧巷老猫 提交于 2020-01-17 17:12:19
小米业务线众多,从信息流,电商,广告到金融等覆盖了众多领域,小米流式平台为小米集团各业务提供一体化的流式数据解决方案,主要包括数据采集,数据集成和流式计算三个模块。目前每天数据量达到 1.2 万亿条,实时同步任务 1.5 万,实时计算的数据 1 万亿条。 伴随着小米业务的发展,流式平台也经历三次大升级改造,满足了众多业务的各种需求。最新的一次迭代基于 Apache Flink,对于流式平台内部模块进行了彻底的重构,同时小米各业务也在由 Spark Streaming 逐步切换到 Flink。 背景介绍 小米流式平台的愿景是为小米所有的业务线提供流式数据的一体化、平台化解决方案。具体来讲包括以下三个方面: 流式数据存储 :流式数据存储指的是消息队列,小米开发了一套自己的消息队列,其类似于 Apache kafka,但它有自己的特点,小米流式平台提供消息队列的存储功能; 流式数据接入和转储 :有了消息队列来做流式数据的缓存区之后,继而需要提供流式数据接入和转储的功能; 流式数据处理 :指的是平台基于 Flink、Spark Streaming 和 Storm 等计算引擎对流式数据进行处理的过程。 下图展示了流式平台的整体架构。从左到右第一列橙色部分是数据源,包含两部分,即 User 和 Database。 User 指的是用户各种各样的埋点数据,如用户 APP 和 WebServer

【Canal源码分析】TableMetaTSDB

孤街浪徒 提交于 2020-01-17 13:09:03
这是Canal在新版本引入的一个内容,主要是为了解决由于历史的DDL导致表结构与现有表结构不一致,导致的同步失败的问题。采用的是Druid和Fastsql,来记录表结构到DB中,如果需要进行回滚时,得从DB中根据时间点去查到对应的库表结构,然后进行业务的处理。也就是,如果我们想要这样的效果,需要开启TSDB的功能,同时要新增库表来记录表结构的变更。 这个基本上是在parser启动时,寻找位点时需要的。当然在系统启动的时候,会将库表的信息写入到DB中,然后定时24小时写入一次。另外就是在发生了DDL时,会更新表结构。 我们来看下他的类图。 一张表记录的是表结构,加上了时间,另一张记录的是当时的DDL语句。在进行回溯的时候,直接根据时间戳和binlog文件名来进行寻找即可找到。当然这些数据也会在内存中保存一份,加快速度。 具体的介绍可以见这个链接https://github.com/alibaba/canal/wiki/TableMetaTSDB。 来源: https://www.cnblogs.com/f-zhao/p/9116316.html

MySQL group replication

被刻印的时光 ゝ 提交于 2020-01-17 04:57:24
本篇文章主要讲解 MySQL group replication 介绍,文中有关 MySQL ,group的内容,希望对大家有所帮助。 “ MySQL group replication ” group replication 是 MySQL 官方开发的一个开源插件,是实现 MySQL 高可用集群的一个工具。第一个GA版本正式发布于MySQL5.7.17中;想要使用group replication只需要从官网上下载MySQL5.7.17及以后的版本即可 group replication发布以后,有3种方法来实现MySQL的高可用集群: ①:异步复制 ②:半同步复制 ③:group replication ---注意: 异步复制是实现最早也是最简单的高可用方法。相比异步复制而言,半同步复制提高了MySQL集群的可靠性。group replication则是MySQL复制今后发展的方向,与前两者相比,不仅是可靠性更好,在易用性上也有巨大提高; 1、组的概念: group replication插件中有组(group)的概念,被group replication插件连接在一起的MySQL服务器是一个高可用组,组内的MySQL服务器被称为成员。组的概念贯穿与group replication的使用和内部实现之中。group replication内部集成了组管理服务

sql combine rows with same date

徘徊边缘 提交于 2020-01-16 19:00:27
问题 I want to combine rows when they have same date and Item# while aggregating received QTY and Outstanding QTY. Also, PO# should be combined with “, “. Please refer to the image or table below. Thank you in advance!! This is my SQL Query... SELECT * from [mason01].[dbo].[po_east] as t1 inner join (select distinct [Date],[ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding] FROM [mason01].[dbo].[po_east] group by [Date], [ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding]) as t2 on t1.Date

sql combine rows with same date

倾然丶 夕夏残阳落幕 提交于 2020-01-16 19:00:11
问题 I want to combine rows when they have same date and Item# while aggregating received QTY and Outstanding QTY. Also, PO# should be combined with “, “. Please refer to the image or table below. Thank you in advance!! This is my SQL Query... SELECT * from [mason01].[dbo].[po_east] as t1 inner join (select distinct [Date],[ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding] FROM [mason01].[dbo].[po_east] group by [Date], [ITEMNO],[PONUMBER],[LOCATION],[Received],[Outstanding]) as t2 on t1.Date