ddl

db2look导出ddl 详细用法(转)

倾然丶 夕夏残阳落幕 提交于 2019-11-27 03:38:49
DB2的db2look命令诠释如下: db2look 版本 8.2 db2look:生成 DDL 以便重新创建在数据库中定义的对象 语法: db2look -d DBname [-e] [-u Creator] [-z Schema] [-t Tname1 Tname2...TnameN] [-tw Tname] [-h] [-o Fname] [-a] [-m] [-c] [-r] [-l] [-x] [-xd] [-f] [-fd] [-td x] [-noview] [-i userID] [-w password] [-v Vname1 Vname2 ... VnameN] [-wrapper WrapperName] [-server ServerName] [-nofed] db2look -d DBname [-u Creator] [-s] [-g] [-a] [-t Tname1 Tname2...TnameN] [-p] [-o Fname] [-i userID] [-w password] db2look [-h] -d: 数据库名称:这必须指定 -e: 抽取复制数据库所需要的 DDL 文件 此选项将生成包含 DDL 语句的脚本 可以对另一个数据库运行此脚本以便重新创建数据库对象 此选项可以和 -m 选项一起使用 -u: 创建程序标识:若 -u 和 -a

贪心算法 区间问题

坚强是说给别人听的谎言 提交于 2019-11-27 03:30:41
1. 单区间调度问题 问题定义:存在单一资源,有一组以时间区间形式表示的资源请求reqs={req-1, req-2, …, req-n},第i个请求希望占用资源一段时间来完成某些任务,这段时间开始于begin(i)终止于end(i)。如果两个请求req-i和req-j在时间区间上没有重叠,则说这两个请求是相容的,求出这组请求的最大相容子集(最优子集)。举个例子:有一间多媒体课室,某一个周末有多个社团想要申请这间课室去举办社团活动,每个社团都有一个对应的申请时间段,比如周六上午8:00-10:00。求出这间课室在这个周末最多能满足几个社团的需求。 解决方案:贪心算法,优先选择最早结束的需求,确保资源尽可能早地被释放,把留下来满足其他需求的时间最大化。具体伪代码如下所示,算法结束后集合A中会保留所有相容请求,A的大小即是最大相容数量。 初始化R是所有需求的集合, A 为空集 对R中的需求Ri,根据结束时间从早到晚排序 for Ri in R, do if Ri与 A 中的请求相容 A = A 并Ri endIf endFor return A 上述伪代码的C++实现如下 #include <iostream> #include <algorithm> #include <vector> using namespace std ; const int MAX_SIZE = 100 ;

How do I add a foreign key to an existing SQLite table?

▼魔方 西西 提交于 2019-11-27 03:02:04
I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER, description TEXT); How do I add a foreign key constraint on parent_id ? Assume foreign keys are enabled. Most examples assume you're creating the table - I'd like to add the constraint to an existing one. You can't. Although the SQL-92 syntax to add a foreign key to your table would be as follows: ALTER TABLE child ADD CONSTRAINT fk_child_parent FOREIGN KEY (parent_id) REFERENCES parent(id); SQLite doesn't support the ADD CONSTRAINT variant of the ALTER TABLE command ( sqlite.org: SQL Features That

MYSQL学习系列--DDL语句

不想你离开。 提交于 2019-11-27 02:46:45
DDL语句: 对数据库内部的对象进行创建、删除、修改等操作的语言,DDL语句更多的是由数据库管理员(DBA)使用,开发人员一般很少使用登录mysql之后就可以使用sql语句对数据库进行各种操作啦! 实践操作: 在基础操作之前,如果没有安装mysql的可以参考我之前写的一篇文章(windows) windows命令行使用mysql 还有,MYSQL不区分大小写,这里为了演示看的清楚,我们使用小写。 show databses; #查看数据库列表 后面的分号别落下了!!! 1)创建数据库 1>使用 create database 数据库名; 2>选择要操作的数据库:USE 数据库; 对于要操作的数据库我们需要使用use来选择一下! 3>查看数据库中所有的数据表show tables; 2)删除数据库: drop database 数据库名; 我们创建一个will_del的数据库,然后在删除它; 3)创建表(在哪个数据库里面创建表需要先使用use选择到那个要操作的数据库) 1>创建表 create table 表名( 字段1名 字段1类型 列的约束条件, 字段2名 字段2类型 列的约束条件, ...); 2>创建完表之后可以查看表的定义 desc 表名; 3>查看创建表的SQL语句 show create table 表名 \G \G选项使得记录能够按照字段竖向排列

Upgrading a varchar column to enum type in postgresql

旧城冷巷雨未停 提交于 2019-11-27 02:42:14
问题 We have a varchar column in a table, that we need to upgrade to enum type. All the values in the varchar column are valid values in the enumeration. There is no null values in the varchar column. ALTER TABLE tableName ALTER COLUMN varcharColumn TYPE enum_type ERROR: column "varcharColumn" cannot be cast to type enum_type SQL state: 42804 The round about way is to Create another new column with enum type. Update the enum type column with the varchar column after typecasting. Drop the varchar

debezium关于cdc的使用(下)

筅森魡賤 提交于 2019-11-27 02:28:46
博文原址: debezium关于cdc的使用(下) 简介 debezium在 debezium关于cdc的使用(上) 中有做介绍。具体可以跳到上文查看。本篇主要讲述使用 kafka connector 方式来同步数据。而kafka connector实际上也有提供其他的sink( Kafka Connect JDBC )来同步数据,但是没有delete事件。所以在这里选择了 Debezium MySQL CDC Connector 方式来同步。本文需要使用Avro方式序列化kafka数据。 流程 第一步准备 使用kafka消息中间介的话需要对应的服务支持,尤其需要 chema-registry 来管理schema,因电脑内存有限就没使用docker方式启动,如果条件ok内存够大的话阔以使用 docker方式 。所以使用的就是 local本地方式 。具体下载,安装,部署,配置环境变量我就不在重复描述了,阔以参考官方文档。 第二步启动kafka配套 进入目录后启动 bin/confluent start 第三步创建kafka topic 可以通过kafka命令创建topic也可以通过 Confluent Control Center 地址: http://localhost:9021 来创建topic。我们还是按照上文的表来同步数据,所以创建topic: dbserver1

How do I DROP a constraint from a sqlite (3.6.21) table?

☆樱花仙子☆ 提交于 2019-11-27 01:32:38
问题 I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER CONSTRAINT parent_id REFERENCES parent(id), description TEXT); How do I drop the constraint? 回答1: SQLite does not (as of this answer) support the alter table drop constraint command. The allowed syntax can be seen here. You will need to create a new table without a constraint, transfer the data, then delete the old table. I think something like the following should work: CREATE TABLE child2 ( id INTEGER

Mysql delete,truncate,drop

大城市里の小女人 提交于 2019-11-27 01:15:46
1、delete 是DML(Data Manipulation Language),每次删除一行,作为事务记录在日志,可以回滚。delete from xxx 2、truncate是DDL(Data Define Language),一次性删除数据,不把行的删除记录日志,不能恢复,不激活触发器。truncate table 3、drop是DDL,删除表的数据和表结构。 转载于:https://www.cnblogs.com/nzbbody/p/4275808.html 来源: https://blog.csdn.net/weixin_30896763/article/details/99234744

Using ALTER to drop a column if it exists in MySQL

假如想象 提交于 2019-11-27 01:05:28
How can ALTER be used to drop a column in a MySQL table if that column exists? I know I can use ALTER TABLE my_table DROP COLUMN my_column , but that will throw an error if my_column does not exist. Is there alternative syntax for dropping the column conditionally? I'm using MySQL version 4.0.18. For MySQL, there is none: MySQL Feature Request . Allowing this is arguably a really bad idea, anyway: IF EXISTS indicates that you're running destructive operations on a database with (to you) unknown structure. There may be situations where this is acceptable for quick-and-dirty local work, but if

Why use multiple columns as primary keys (composite primary key)

孤人 提交于 2019-11-26 23:49:26
This example is taken from w3schools . CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName) ) My understanding is that both columns together ( P_Id and LastName ) represent a primary key for the table Persons . Is this correct? Why would someone want to use multiple columns as primary keys instead of a single column? How many columns can be used together as a primary key in a given table? MJB Your understanding is correct. You would do this in many cases. One