In MySQL it is possible to do show create table tablename What is the SQL Server equivalent?
Finding the actual Job number for a particular JDBC SQL connection to iSeries?
I am using the JTOpen JDBC driver to connect to the iSeries (aka AS/400, IBM System-i, IBMi, WTH?!…). I am having problems with a particular statement and it appears I need to go back to the actual SQL job QSQSRVR (or QZDASOINIT?) to find more details. Only problem is that there are hundreds of these on…
How to calculate the maximum of two numbers in Oracle SQL select?
This should be simple and shows my SQL ignorance: SQL> select max(1,2) from dual; select max(1,2) from dual * ERROR at line 1: ORA-00909: invalid number of arguments I know max is normally …
SQL: How to select 1st, 3rd, 11th and nth row from a table?
How to select 1st, 3rd, 11th and nth row from a table? Answer If there is a primary key defined for the table that is an integer based data type–both MySQL and SQLite have auto_increment for example–then you can use: …where id is the auto_increment column. There’s very little detail to…
MySQL create time and update time timestamp
I am creating some tables where I want to store the time when a record was created and when it was last updated. I thought I could have two timestamp fields where one would have the value …
How can I see the contents of an Oracle index?
Is it possible to have a look at what is there inside an index using SQL*Plus? If I have a table like this: Table A ———————— rowid | id name 123 | 1 A 124 | 4 G 125 …
Is a Primary Key necessary in SQL Server?
This may be a pretty naive and stupid question, but I’m going to ask it anyway I have a table with several fields, none of which are unique, and a primary key, which obviously is. This table is accessed via the non-unique fields regularly, but no user SP or process access data via the primary key. Is th…
How Do I aggregate Data By Day and Still Respect Timezone?
We are currently using a summary table that aggregates information for our users on an hourly basis in UTC time. The problem we are having is that this table is becoming too large and slowing our system down immensely. We have done all the tuning techniques recommended for PostgreSQL and we are still experien…
Only inserting a row if it’s not already there
I had always used something similar to the following to achieve it: …but once under load, a primary key violation occurred. This is the only statement which inserts into this table at all. So does this mean that the above statement is not atomic? The problem is that this is almost impossible to recreate…
Synchronizing client-server databases
I’m looking for some general strategies for synchronizing data on a central server with client applications that are not always online. In my particular case, I have an android phone application with an sqlite database and a PHP web application with a MySQL database. Users will be able to add and edit i…