ddl

Clone a Table's definition with Hibernate (hbm2ddl)

﹥>﹥吖頭↗ 提交于 2019-12-03 22:06:34
问题 In my hibernate application there is annotation driven object: AuditEvent . Its very simple and has no foreign key relationships. I archive old entries in this table by moving them to another table OldAuditEvent , which is a clone of the AuditEvent table. Right now we generate the DDL for the entire application using hbm2ddl (on our annotated datamodel) and manually copy/paste the AuditEvent table and change its name to create OldAuditEvent . I want to automate the build process, is there any

【Canal源码分析】TableMetaTSDB

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

Generate DDL with spring boot using a custom delimiter

谁说胖子不能爱 提交于 2019-12-03 19:32:51
问题 I want generate create and drop ddl scripts using spring boot v1.4.3 with JPA - Hibernate 5.0.11. Most answers I found use the javax.persistence.schema-generation properties. E.g. https://stackoverflow.com/a/36966419/974186 The problem with this approach is the it outputs the sql statements without an delimiter. E.g. create table ... (...) create table ... (...) I want it to output the statements with the delimiter ; create table ... (...); create table ... (...); But I can't find any javax

How do I get alembic to emit custom DDL on after_create?

蹲街弑〆低调 提交于 2019-12-03 19:28:41
问题 I've got a couple of custom DDL statements that I want to run after create table: update_function = DDL(""" CREATE OR REPLACE FUNCTION update_timestamp() RETURNS TRIGGER AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$ language 'pgplsql'; """) update_trigger = DDL(""" CREATE TRIGGER update %(table)s_timestamp BEFORE UPDATE ON %(table)s FOR EACH ROW EXECUTE PROCEDURE update_timestamp(); """) And I've attached them like this: event.listen(Session.__table__, 'after_create', update

JPA / EclipseLink - create script source with one SQL statement taking multiple lines

余生长醉 提交于 2019-12-03 17:23:08
问题 I want to let the persistence provider (EclipseLink 2.5.0) automatically create the tables in the, already existing, database by using the persistence unit property "javax.persistence.schema-generation.create-script-source" and a valid SQL-DDL-script. persistence.xml: <property name="javax.persistence.schema-generation.create-script-source" value="data/ddl.sql"/> ddl.sql: USE myDatabase; CREATE TABLE MyTable ( id INTEGER NOT NULL AUTO_INCREMENT, myColumn VARCHAR(255) NOT NULL, PRIMARY KEY (id

Drop column and all dependent objects using data definition language

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 16:11:23
I need to remove a column from a table, but when I try to remove it: The object 'object_name' is dependent on column 'column_name'. ALTER TABLE DROP COLUMN column_name failed because one or more objects access this column. I can look for the dependency in the system tables and remove it manually, but I need to do a migration (using SQL DDL ) so all others members of the team just do the update, run the migration and don´t have to mess up up system objects. Try this code: Declare @TABLENAME varchar(max), @COLUMN varchar(max) SET @TABLENAME = 'YOURTableName' SET @COLUMN = 'YOURColumnName'

ambiguous class with namespace names in 2 dlls

流过昼夜 提交于 2019-12-03 15:18:18
问题 I've imported 2 dlls to my application (third party) Now both of them have a namespace with same name. For example A.B and in both of them there is a class again with a same name. Now I want to create an instance of one of them, but because the namespace and class names are same, the compiler goes ambiguous. How can I specify witch dll used in the place? 回答1: Let's suppose that you have 2 assemblies ( ClassLibrary1.dll and ClassLibrary2.dll ) that both define the same class in the same

Oracle面试题(基础篇)(转)

大城市里の小女人 提交于 2019-12-03 14:37:39
1. Oracle跟SQL Server 2005的区别? 宏观上: 1). 最大的区别在于平台,oracle可以运行在不同的平台上,sql server只能运行在windows平台上,由于windows平台的稳定性和安全性影响了sql server的稳定性和安全性 2). oracle使用的脚本语言为PL-SQL,而sql server使用的脚本为T-SQL 微观上: 从数据类型, 数据库 的结构等等回答 2. 如何使用Oracle的游标? 1). oracle中的游标分为显示游标和隐式游标 2). 显示游标是用cursor...is命令定义的游标,它可以对查询语句(select)返回的多条记录进行处理;隐式游标是在执行插入 (insert)、删除(delete)、修改(update)和返回单条记录的查询(select)语句时由PL/SQL自动定义的。 3). 显式游标的操作:打开游标、操作游标、关闭游标;PL/SQL隐式地打开SQL游标,并在它内部处理SQL语句,然后关闭它 3. Oracle中function和procedure的区别? 1). 可以理解函数是存储过程的一种 2). 函数可以没有参数,但是一定需要一个返回值,存储过程可以没有参数,不需要返回值 3). 函数return返回值没有返回参数模式,存储过程通过out参数返回值, 如果需要返回多个参数则建议使用存储过程

How can I avoid getting this MySQL error Incorrect column specifier for column COLUMN NAME?

寵の児 提交于 2019-12-03 14:35:05
问题 How can I avoid getting this MySQL error Incorrect column specifier for column topic_id ? MySQL Error... #1063 - Incorrect column specifier for column 'topic_id' SQL Schema... CREATE TABLE discussion_topics ( topic_id char(36) NOT NULL AUTO_INCREMENT, project_id char(36) NOT NULL, topic_subject VARCHAR(255) NOT NULL, topic_content TEXT default NULL, date_created DATETIME NOT NULL, date_last_post DATETIME NOT NULL, created_by_user_id char(36) NOT NULL, last_post_user_id char(36) NOT NULL,

How can I automatically convert MySQL DDL to Oracle DDL? [closed]

删除回忆录丶 提交于 2019-12-03 12:40:24
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I know my question sounds a little bit like a shopping request, but I honestly believe that many people could find it useful. I've been looking for an automatic tool that converts Data Definition Language from MySQL dialect to Oracle dialect - the other way round would also be fine. I found “SQL Fairy” but I was