database-agnostic

Distributed primary key - UUID, simple auto increment or custom sequential values?

泪湿孤枕 提交于 2020-01-14 09:49:07
问题 I know this type of question has been asked before, but I could not find one that compared the options I have in mind. So I am going to post them here, please post links if there are duplicates. This has ended up a rather long post, if you have time please read it through as the question is at the end EDIT2: I've accepted an answer as I think that will be the best solution for now. But I thought I would like to two other questions that answer my query about concatenating numbers. They can be

Getting week number of date in SQL

自作多情 提交于 2020-01-11 11:45:10
问题 Is there a way to get the week number of a date with SQL that is database independent? For example to get the month of a date I use: SELECT EXTRACT(MONTH FROM :DATE) But the EXTRACT function doesn't know about weeks in SQL92. Please pay attention to the fact that I want a solution that is database independent ! Do not misinterpret this as a question regarding MS SQL Server. 回答1: There doesn't appear to be a single standard SQL function to extract the week number from a date - see here for a

Number of times a nested query is executed

青春壹個敷衍的年華 提交于 2019-12-31 04:04:19
问题 How many times will this nested sub-query be executed? SELECT CID, CNAME FROM CUSTOMER WHERE EXISTS ( SELECT CID FROM RENTALS WHERE CUSTOMER.CID = RENTALS.CID AND PICKUP = 'CARY' ) This is a theoretical question i.e. it is found in my book. The provided answer was 6, but I don't understand why this is so. Ok, I think there is some problem with the book itself. I will go through the book and maybe, later ask the question. 回答1: As others point out, this correlated subquery can be rewritten as a

Database Agnostic Application

强颜欢笑 提交于 2019-12-23 04:35:32
问题 The database for one the application that I am working on is not confirmed yet by the business. Best guess is Oracle and DB2. What I've heard is initially the project will go live with DB2 V9 and then to Oracle 11g. We are using Spring 3.0.5, Hibernate 3.5, JPA2 and JBoss 5 for this project So what are the best practices here going into the build phase and test phase? Shall I build using DB2 first and worry about Oracle later (this doesn't sound right)? Or, shall I write using JPA (Hibernate)

How to construct query in querydsl without domain classes

泄露秘密 提交于 2019-12-22 09:40:00
问题 While looking for java libraries to build queries in a database agnostic way I came across many including iciql, querydsl, jooq, joist, hibernate etc. I wanted something that does not require configuration files and can work with dynamic schemas. For my application, I come to know about the database and the schema at runtime so I won't have any configuration files or domain classes for the schema. This seems to be one of the core goals of querydsl but going through the documentation for

DB agnostic SQL for CURRENT_TIMESTAMP

故事扮演 提交于 2019-12-22 04:50:38
问题 I'm currently using Oracle, but most of the SQL is db agnostic. One exception is CURRENT_TIMESTAMP which fails in MSSQL. Is is possible to move to a more portable syntax for this too? 回答1: According to their documentation the following vendors support CURRENT_TIMESTAMP . Oracle Postgresql MySQL SQL Server Firebird H2 HSQLDB DB2 Vertica InterSystems Caché Doctrine Teradata In summary, CURRENT_TIMESTAMP is the method stated in the SQL Standard, a summary of which is below, and if you are

Does “group by” automatically guarantee “order by”?

早过忘川 提交于 2019-12-21 07:39:07
问题 Does "group by" clause automatically guarantee that the results will be ordered by that key? In other words, is it enough to write: select * from table group by a, b, c or does one have to write select * from table group by a, b, c order by a, b, c I know e.g. in MySQL I don't have to, but I would like to know if I can rely on it accross the SQL implementations. Is it guaranteed? 回答1: group by does not order the data neccessarily. A DB is designed to grab the data as fast as possible and only

How to get fully materialized query from querydsl

僤鯓⒐⒋嵵緔 提交于 2019-12-17 18:21:21
问题 I am trying to use querydsl for building dynamic queries for dynamic schemas. I am trying to get just the query instead of having to actually execute it. So far I have faced two issues: - The schema.table notation is absent. Instead I only get the table name. - I have been able to get the query but it separates out the variables and puts '?' instead which is understandable. But I am wondering if there is some way to get fully materialized query including the parameters. Here is my current

ActiveRecord aggregate function: is there a database-agnostic 'EXTRACT(WEEK from date)'?

纵然是瞬间 提交于 2019-12-11 22:24:25
问题 i have a method that works just fine (with rails 3 and PostgreSQL) ; i just wonder if it's possible to make it database-agnostic : FarmGatePrice.average :price, :group => 'EXTRACT(WEEK FROM date)' As i understand it, methods to extract a week ISO number from a date are always database-specific. I could use something like a virtual attribute :week as seen here, but it seems the :group options only accepts raw SQL. I've also seen this solution but it doesn't fit my needs. Another way would be

Static Analysis Tools for Database Design [closed]

守給你的承諾、 提交于 2019-12-11 06:28:46
问题 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 6 years ago . I'm looking for Static Analysis Tools for Database Tier. I got some answers for reviewing PLSQL, TSQL code, i'm wondering what are the options available for reviewing database design for naming conventions of tables and their columns, foreign key constraints and triggers etc. There is MSDN article which talks