You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
-- siehe auch: http://stackoverflow.com/questions/6083132/postgresql-insert-into-select
-- in DestinationDB do:
INSERT INTO Table1
SELECT id, valuefield
FROM dblink('dbname=SourceDB', 'SELECT id, valuefield FROM Table1')
AS t(id integer, valuefield varchar(100));
245
PL/pgSQL
Datenbank
SQL SELECT Statische Werte
SELECT
*
FROM (
VALUES
(1, 2),
(3, 4)
) AS q (col1, col2)
;
-- the same as:
SELECT 1 AS col1, 2 AS col2 UNION ALL
SELECT 3 AS col1, 4 AS col2
;
-- col1 | col2
-- ===========
-- 1 | 2
-- -----------
-- 3 | 4
134
SSIS
Fallunterscheidung
Wenn-Dann Abfrage
' Using IF(IIF) logic in Derived Column
(LEN(TRIM(Test)) > 0 ? SUBSTRING(Test,1,5) : NULL(DT_WSTR,5))
260
SQLite
Datenbank
Temporäre DB-Tabelle
CREATE TEMPORARY TABLE myTempTable1
(
id INT
,myText TEXT
)
263
SQLite
Datenbank
CTAS
CREATE TABLE newDestinationTable AS
SELECT * FROM oldSourceTable
264
SQLite
Datenbank
Eine Menge B reduziert um Menge A
-- Es soll die Menge an Datensätze ausgegeben reduziert um eine andere Menge (Rest)
-- Die einzelnen Tabellen oder Subqueries müssen die gleichen Spalten im Statement haben
SELECT
FieldA
,FieldB
,FieldC
FROM myTable1
EXCEPT
SELECT
FieldA
,FieldB
,FieldC
FROM myTable2
291
SQLite
Strings
Führende Nullen vor einer Zahl
WITH cte_example AS
(
SELECT 5 AS int_example UNION ALL
SELECT 10 AS int_example UNION ALL
SELECT 50 AS int_example
)
SELECT
int_example,
substr('0000000'||ROW_NUMBER() OVER(ORDER BY int_example)||'00', -8, 8) AS example_result
FROM cte_example
;
141
SQLite
Datenbank
Fremdschlüsselprüfung aktivieren
-- http://www.sqlite.org/foreignkeys.html
PRAGMA foreign_keys = ON;
-- !! this is only valid for the current session.
-- If you want to use this permanent, you have to use this statement every time you start a new session
168
SQLite
Datum, Zeit
Erster und letzter Tag des Monats ermitteln
select date('now','start of month'); --first day of current month
select date('now','start of month', '+1 months','-1 day'); --last day of current month