Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add Queries vulnerable to SQL injection | /*
Author: Bert Wagner
Source link: https://blog.bertwagner.com/warning-are-your-queries-vulnerable-to-sql-injection-db914fb39668
*/
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT
ROUTINE_CATALOG
, ROUTINE_SCHEMA
, ROUTINE_NAME
, ROUTINE_TYPE
, ROUTINE_DEFINITION
FROM
INFORMATION_S... | |
Create function to locate points | -- Locate user defined point on network
-- Author: Christopher Fricke
-- License: MIT
-- DROP FUNCTION routing.get_waypoint(geometry);
CREATE OR REPLACE FUNCTION routing.get_waypoint(test_geom geometry) RETURNS int AS $$
SELECT id::integer FROM routing.ways_vertices_pgr ORDER BY the_geom <-> test_geom LIMIT 1;;
$$... | |
Add SQL to move items to archive table | -- Archive anything older than 1 month that is read.
--
-- This is to keep the table used for active interaction smaller and quicker.
--INSERT INTO rss_item_archive
--(id, title, description, link, publication_date, rss_feed_id, create_time,
-- update_time, guid)
--SELECT ri.id, ri.title, ri.description, ri.link, ri.... | |
Update SQL file to create schema from ERD. | -- Test Script for Database Migration
CREATE TABLE ACCOUNT (
USER_ID INT PRIMARY KEY,
USER_NAME VARCHAR(100) NOT NULL
);
CREATE TABLE PROJECT (
PROJECT_ID INT PRIMARY KEY,
PROJECT_NAME VARCHAR(100) NOT NULL
);
| CREATE TABLE ACCOUNT(
USER_ID IDENTITY NOT NULL,
USER_NAME VARCHAR(100) NOT NULL,
MAIL_ADDRESS VARCHAR(100) NOT NULL,
PASSWORD VARCHAR(20) NOT NULL,
USER_TYPE INT DEFAULT 0 NOT NULL,
URL VARCHAR(200),
REGISTERED_DATE TIMESTAMP NOT NULL,
UPDATED_DATE TIMESTAMP NOT NULL,
LAST_LOGIN_DATE TIMESTA... |
Change users_vocabulary vocabulary_id data type. | # Move current id to hash column
ALTER TABLE `vocabulary` ADD hash BINARY(16) NOT NULL;
UPDATE `vocabulary` SET hash = id;
# Change id to auto-increment int
ALTER TABLE `vocabulary` DROP PRIMARY KEY;
UPDATE vocabulary SET id = 0;
ALTER TABLE `vocabulary` MODIFY id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT;
# Update... | # Move current id to hash column
ALTER TABLE `vocabulary` ADD hash BINARY(16) NOT NULL;
UPDATE `vocabulary` SET hash = id;
# Change id to auto-increment int
ALTER TABLE `vocabulary` DROP PRIMARY KEY;
UPDATE vocabulary SET id = 0;
ALTER TABLE `vocabulary` MODIFY id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT;
# Update... |
Remove Process.PgBackendPID as this column is not set anymore. We instead log it per execution to Log. | CREATE TABLE cron.Processes (
ProcessID serial NOT NULL,
JobID integer NOT NULL REFERENCES cron.Jobs(JobID),
Running boolean NOT NULL DEFAULT FALSE,
FirstRunStartedAt timestamptz,
FirstRunFinishedAt timestamptz,
LastRunStartedAt ... | CREATE TABLE cron.Processes (
ProcessID serial NOT NULL,
JobID integer NOT NULL REFERENCES cron.Jobs(JobID),
Running boolean NOT NULL DEFAULT FALSE,
FirstRunStartedAt timestamptz,
FirstRunFinishedAt timestamptz,
LastRunStartedAt ... |
Fix can challenge for performance query | SELECT * FROM users WHERE
(NOT EXISTS (SELECT * FROM challenges WHERE userNamenumber = $1 AND performanceid = $2)) AND
(SELECT voluntary FROM manage AS m WHERE m.usernamenumber = $1 AND m.performanceid = $2 ORDER BY id DESC LIMIT 1) OR
(
SELECT substring($3, 2)::integer > 12 AND
(
NOT EXISTS (SELECT * FROM mana... | SELECT * FROM users WHERE
NOT EXISTS (SELECT * FROM challenges WHERE userNamenumber = $1 AND performanceid = $2) AND
((SELECT COALESCE(voluntary, true) FROM manage AS m WHERE m.usernamenumber = $1 AND m.performanceid = $2 ORDER BY id DESC LIMIT 1) OR
(
SELECT substring($3, 2)::integer > 12 AND
(
NOT EXISTS (SEL... |
Add the script to create db with proper encoding | CREATE TABLE "public"."media" (
"id" serial NOT NULL,
"iid" text NOT NULL,
"document" jsonb NOT NULL,
"created_at" timestamp NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "public"."subscriptions" (
"id" serial NOT NULL,
"name" text NOT NULL,
"lat" real NOT NULL,
"long" real NOT NULL,... | #CREATE DATABASE spoto OWNER spoto ENCODING 'UTF-8' template template0;
CREATE TABLE "public"."media" (
"id" serial NOT NULL,
"iid" text NOT NULL,
"document" jsonb NOT NULL,
"created_at" timestamp NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "public"."subscriptions" (
"id" serial NOT NULL,
... |
Test the simple MPU query | --drop proc sspBatchMPU -- Monthly Paying User
create proc sspBatchMPU
as
set nocount on
declare @Day30DT datetimeoffset(7)
declare @CurrentDT datetimeoffset(7)
declare @nowdt datetime
declare @MPU bigint
set @nowdt = (select getutcdate())
set @CurrentDT = ((SELECT DATETIMEFROMPARTS (DATEPART(year, @nowdt), DATEPART(... | --drop proc sspBatchMPU -- Monthly Paying User
create proc sspBatchMPU
as
set nocount on
declare @Day30DT datetimeoffset(7)
declare @CurrentDT datetimeoffset(7)
declare @nowdt datetime
declare @MPU bigint
set @nowdt = (select getutcdate())
set @CurrentDT = ((SELECT DATETIMEFROMPARTS (DATEPART(year, @nowdt), DATEPART(... |
Adjust a comment line that prevents cloud from deploying | --
-- PostgreSQL database dump
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
CREATE FUNCTION update_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$... | --
-- PostgreSQL database dump
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
CREATE FUNCTION update_updated_at_column() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$;
CREATE TABLE deployment_tracker (
id integer NOT NULL,
... |
Update migration to add igg | create table sguser (
id serial not null primary key,
email text not null unique,
password text not null,
username text,
credentials text,
challenges text,
emailverified boolean,
verificationtoken boolean,
status text,
modified timestamp with time zone default now(),
realm text,
firstname text,
... | create table sguser (
id serial not null primary key,
email text not null unique,
password text not null,
username text,
credentials text,
challenges text,
emailverified boolean,
verificationtoken boolean,
status text,
modified timestamp with time zone default now(),
realm text,
firstname text,
... |
Drop database table when running init_b | CREATE TABLE measurements (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
time_stamp DATETIME,
stroom_dal FLOAT,
stroom_piek FLOAT,
stroom_current FLOAT,
gas FLOAT,
diff_stroom_dal FLOAT,
diff_stroom_piek FLOAT,
diff_gas FLOAT
);
| DROP TABLE measurements;
CREATE TABLE measurements (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
time_stamp DATETIME,
stroom_dal FLOAT,
stroom_piek FLOAT,
stroom_current FLOAT,
gas FLOAT,
diff_stroom_dal FLOAT,
diff_stroom_piek FLOAT,
diff_gas FLOAT
);
|
Add LOGIN permissions to new roles | CREATE ROLE metacpan;
CREATE ROLE "metacpan-api";
-- make things easier for when we're poking around from inside the container
CREATE USER root;
| CREATE ROLE metacpan WITH LOGIN;
CREATE ROLE "metacpan-api" WITH LOGIN;
-- make things easier for when we're poking around from inside the container
CREATE USER root;
|
Update SQL script for reset | update lfv2_account set cup_cagnoute = false, cup_points = 0, cup_rank = 99;
delete from lfv2_cup_vote;
delete from lfv2_cup_match;
update lfv2_cup set name = 'EURO 2016'; | update lfv2_account set cup_cagnoute = false, cup_points = 0, cup_rank = 99, stat_cup_scores = 0, stat_cup_matchs = 0, stat_cup_results = 0;
delete from lfv2_cup_vote;
delete from lfv2_cup_match;
update lfv2_cup set name = 'EURO 2016'; |
Fix typo in db patch | -- Add the ratings column to the event_comments table
ALTER TABLE event_comments ADD COLUMN `rating` int(11) default NULL, ;
-- Increase patch count
INSERT INTO patch_history SET patch_number = 55; | -- Add the ratings column to the event_comments table
ALTER TABLE event_comments ADD COLUMN `rating` int(11) default NULL;
-- Increase patch count
INSERT INTO patch_history SET patch_number = 55; |
Fix long name for TAS in update sql | UPDATE linked_system SET beskrivelse = 'Det Fælles Medicinkort' where kode = 'FMK';
UPDATE linked_system SET beskrivelse = 'Det Danske Vaccinationsregister' where kode = 'DDV';
UPDATE linked_system SET beskrivelse = 'Tilskudsadministration' where kode = 'TAS';
| UPDATE linked_system SET beskrivelse = 'Det Fælles Medicinkort' where kode = 'FMK';
UPDATE linked_system SET beskrivelse = 'Det Danske Vaccinationsregister' where kode = 'DDV';
UPDATE linked_system SET beskrivelse = 'Tilskudsansøgningsservicen' where kode = 'TAS';
|
Use single-quotes around string literals used in SQL statements | R"**(
BEGIN TRANSACTION;
ALTER TABLE trans
ADD comment TEXT DEFAULT "";
UPDATE config
SET value = "1.2"
WHERE key = 'version';
COMMIT;
)**"
| R"**(
BEGIN TRANSACTION;
ALTER TABLE trans
ADD comment TEXT DEFAULT '';
UPDATE config
SET value = '1.2'
WHERE key = 'version';
COMMIT;
)**"
|
Change Robs position to Project Advisor. | update xcolab_StaffMember set role="CCI Associate Director" where id_=149;
update xcolab_StaffMember set role="Project Manager" where id_=150;
update xcolab_StaffMember set categoryId=8, role="" where id_=155;
update xcolab_StaffMember set userId=1003305, photoUrl="" where id_=159;
update xcolab_StaffMember set photoUr... | update xcolab_StaffMember set role="Project Advisor" where id_=149;
update xcolab_StaffMember set role="Project Manager" where id_=150;
update xcolab_StaffMember set categoryId=8, role="" where id_=155;
update xcolab_StaffMember set userId=1003305, photoUrl="" where id_=159;
update xcolab_StaffMember set photoUrl="http... |
Add settings for has_invitation field of csiprova2 meeting | -- Inizio script
/*!40101 SET character_set_client = latin1 */;
/*!40103 SET TIME_ZONE='+00:00' */;
SET AUTOCOMMIT=0;
START TRANSACTION;
-- Add schedule details to csi prova 2
update meeting_sessions
set warm_up_time = '14:00:00',
begin_time = '14:50:00',
day_part_type_id = (select dpt.id from day_part_... | -- Inizio script
/*!40101 SET character_set_client = latin1 */;
/*!40103 SET TIME_ZONE='+00:00' */;
SET AUTOCOMMIT=0;
START TRANSACTION;
-- Add schedule details to csi prova 2
update meeting_sessions
set warm_up_time = '14:00:00',
begin_time = '14:50:00',
day_part_type_id = (select dpt.id from day_part_... |
Fix SQL statement to prevent always asking for updates | #
# Table structure for table 'tx_tevglossary_domain_model_entry'
#
CREATE TABLE tx_tevglossary_domain_model_entry (
uid int(11) unsigned NOT NULL auto_increment,
pid int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
c... | #
# Table structure for table 'tx_tevglossary_domain_model_entry'
#
CREATE TABLE tx_tevglossary_domain_model_entry (
uid int(11) unsigned NOT NULL auto_increment,
pid int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
c... |
Add data to populate on re-deploy. | -- Note: When adding new tables, also add the tables to dropSchema.sql and clearSchema in order for tests to work correctly.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE IF NOT EXISTS users (
user_id bigserial PRIMARY KEY ,
username text UNIQUE NOT NULL,
email text NOT NULL,
passwor... | -- Note: When adding new tables, also add the tables to dropSchema.sql and clearSchema in order for tests to work correctly.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE IF NOT EXISTS users (
user_id bigserial PRIMARY KEY ,
username text UNIQUE NOT NULL,
email text NOT NULL,
passwor... |
Revert "Intentionally breaking code to check build failure on CI. <Jaideep>" - verified it :) | --liquibase formatted sql
--changeset JAIDEEP:1
CREATE TABLE PERSON (
ID SERIAL PRIMARY KEY,
FIRST_NAME VARCHAR(130) NOT NULL,
MIDDLE_NAME VARCHAR(130),
LAST_NAME VARCHAR(130),
CATEGORY varchar(200) NOT NULL remove it
);
--rollback drop table PERSON; | --liquibase formatted sql
--changeset JAIDEEP:1
CREATE TABLE PERSON (
ID SERIAL PRIMARY KEY,
FIRST_NAME VARCHAR(130) NOT NULL,
MIDDLE_NAME VARCHAR(130),
LAST_NAME VARCHAR(130),
CATEGORY varchar(200) NOT NULL
);
--rollback drop table PERSON; |
Add updated function to db alter sql | -- These are changes needed to the schema to support moving over to DBIx::Class
begin;
-- table for sessions - needed by Catalyst::Plugin::Session::Store::DBIC
CREATE TABLE sessions (
id CHAR(72) PRIMARY KEY,
session_data TEXT,
expires INTEGER
);
-- users table
create table users (
id ... | -- These are changes needed to the schema to support moving over to DBIx::Class
begin;
-- table for sessions - needed by Catalyst::Plugin::Session::Store::DBIC
CREATE TABLE sessions (
id CHAR(72) PRIMARY KEY,
session_data TEXT,
expires INTEGER
);
-- users table
create table users (
id ... |
Correct index for identifier search | CREATE INDEX HPA_KA_SEARCH ON IIS.KNOWN_AS
(
PERSON_SURNAME,
PERSON_FORENAME_1,
PERSON_BIRTH_DATE,
FK_PERSON_IDENTIFIER
)
CREATE INDEX HPA_LOL_SEARCH ON IIS.LOSS_OF_LIBERTY
(
INMATE_SURNAME,
INMATE_FORENAME_1,
INMATE_BIRTH_DATE,
FK_PERSON_IDENTIFIER
)
CREATE INDEX HPA_IDENT_SEARCH ON I... | CREATE INDEX HPA_IDENT_SEARCH ON IIS.IIS_IDENTIFIER
(
PERSON_IDENT_TYPE_CODE,
PERSON_IDENTIFIER_VALUE,
FK_PERSON_IDENTIFIER
)
|
Add DELETE statement to fix broken data in users_history table | ALTER TABLE `users_history`
CHANGE COLUMN `user_id` `user_id` INT (11) NOT NULL,
CHANGE COLUMN `created` `created` DATETIME (6) NOT NULL,
CHANGE COLUMN `modified` `modified` DATETIME (6) NOT NULL,
CHANGE COLUMN `id` `id` INT (10) UNSIGNED NOT NULL AUTO_INCREMENT,
CHANGE COLUMN `email` `email` VARCHA... | /* There are some old entries in users_history which point to non-existent users, need to delete them to add the missing constraint */
DELETE FROM `users_history` USING `users_history`
LEFT JOIN `users` ON `users_history`.`user_id` = `users`.`id`
WHERE `users`.`id` IS NULL AND `users_history`.`user_id` IS NOT N... |
Trim leading and trailing whitespace and replace blanks with null in ObjectImagesExport view | CREATE OR REPLACE VIEW ObjectImagesExport AS
SELECT
o.ItemType,
i.Accession_Full_ID,
o.ItemName,
ObjectsImagesID,
CONCAT_WS('/', REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(ImageFilePath, '\\', '/'), 'Y:/', ''), 'Y:', ''),
'//Foyer/c/Images Mosaic/', ''... | CREATE OR REPLACE VIEW ObjectImagesExport AS
SELECT
NULLIF(TRIM(o.ItemType), '') AS ItemType,
NULLIF(TRIM(i.Accession_Full_ID), '') AS Accession_Full_ID,
NULLIF(TRIM(o.ItemName), '') AS ItemName,
NULLIF(TRIM(ObjectsImagesID), ... |
Fix up indices for users_who_share_rooms | /* Copyright 2017 Vector Creations Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agree... | /* Copyright 2017 Vector Creations Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agree... |
Add default value for user.account_type field to trackit | -- Copyright 2020 MSolution.IO
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or ... | -- Copyright 2020 MSolution.IO
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or ... |
Make table changes remember status before changeing | ALTER TABLE `contest` CHANGE `status` `status` ENUM( 'Open', 'Closed' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Open';
ALTER TABLE `contest` ADD `visibility` ENUM( 'Visible', 'Hidden' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Hidden';
| ALTER TABLE `contest` ADD `visibility` ENUM( 'Visible', 'Hidden' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Hidden';
UPDATE `contest` SET `startDate` = NOW(), `endDate` = NOW() + INTERVAL 3 YEAR WHERE `status` = 'RunningContest';
UPDATE `contest` SET `startDate` = NOW() + INTERVAL 2 YEAR, `end... |
Fix query to count apprenticeships with missing email addresses | CREATE VIEW [DashboardReporting].[ApprenticeshipsWithNoEmail]
AS
SELECT
C.EmployerAndProviderApprovedOn AS ApprovedOn,
A.Id AS ApprenticeshipId
FROM Apprenticeship A
INNER JOIN Commitment C ON A.CommitmentId = C.Id
WHERE A.IsApproved = 1 AND C.EmployerAndProviderApprovedOn >= '2000-09-10' AND A.Email IS NULL
GO | CREATE VIEW [DashboardReporting].[ApprenticeshipsWithNoEmail]
AS
SELECT
C.EmployerAndProviderApprovedOn AS ApprovedOn,
A.Id AS ApprenticeshipId
FROM Apprenticeship A
INNER JOIN Commitment C ON A.CommitmentId = C.Id
WHERE A.IsApproved = 1 AND C.EmployerAndProviderApprovedOn >= '2021-09-10' AND A.Email IS NULL AND ... |
Remove kv table from postgres ddl script | -- Sample database schema for tourbillon
CREATE TABLE IF NOT EXISTS jobs (
id VARCHAR PRIMARY KEY,
data TEXT
);
CREATE TABLE IF NOT EXISTS workflows (
id VARCHAR PRIMARY KEY,
data TEXT
);
CREATE TABLE IF NOT EXISTS accounts (
id VARCHAR PRIMARY KEY,
data TEXT
);
CREATE TABLE IF NOT EXISTS tem... | -- Sample database schema for tourbillon
CREATE TABLE IF NOT EXISTS jobs (
id VARCHAR PRIMARY KEY,
data TEXT
);
CREATE TABLE IF NOT EXISTS workflows (
id VARCHAR PRIMARY KEY,
data TEXT
);
CREATE TABLE IF NOT EXISTS accounts (
id VARCHAR PRIMARY KEY,
data TEXT
);
CREATE TABLE IF NOT EXISTS tem... |
Simplify best end date query a little | select
min(
ifsapp.work_time_calendar_api.get_end_date(
wc.calendar_id,
ifsapp.work_time_calendar_api.get_end_time(
wc.calendar_id,
greatest(
fc.start_work_day,
ifsapp.work_time_calendar_api.get_end_date(
wc.calendar_id,
trunc(sysdate),
... | select
min(
ifsapp.work_time_calendar_api.get_end_date(
wc.calendar_id,
ifsapp.work_time_calendar_api.get_end_time(
wc.calendar_id,
greatest(
fc.start_work_day,
ifsapp.work_time_calendar_api.get_end_date(
wc.calendar_id,
trunc(sysdate),
... |
Add comment (just a test commit!) | OPTIONS
compile yes
merge trees.all.pak
| OPTIONS
compile yes
merge trees.all.pak
# There's relatively little sense in allowing users to manipulate single trees, usually they are only all deleted for network games.
|
Use REPLACE INTO (maybe the new rows already exist) Removed db specification. | --
-- Time Warsong Gulch
--
INSERT INTO `ascemu_world`.`worldstate_templates` (`map`, `zone`, `field`, `value`) VALUES (489, 3277, 4247, 1);
INSERT INTO `ascemu_world`.`worldstate_templates` (`map`, `zone`, `field`, `value`) VALUES (489, 3277, 4248, 25);
--
-- Update world db version
--
UPDATE `world_db_version` SET `... | --
-- Time Warsong Gulch
--
REPLACE INTO `worldstate_templates` (`map`, `zone`, `field`, `value`) VALUES (489, 3277, 4247, 1);
REPLACE INTO `worldstate_templates` (`map`, `zone`, `field`, `value`) VALUES (489, 3277, 4248, 25);
--
-- Update world db version
--
UPDATE `world_db_version` SET `LastUpdate` = '2016-01-30_01... |
Add table for export profiles. | CREATE TABLE IF NOT EXISTS lddb (
id text not null unique primary key,
data jsonb not null,
collection text not null,
changedIn text not null,
changedBy text,
checksum text not null,
created timestamp with time zone not null default now(),
modified timestamp with time zone not null defau... | CREATE TABLE IF NOT EXISTS lddb (
id text not null unique primary key,
data jsonb not null,
collection text not null,
changedIn text not null,
changedBy text,
checksum text not null,
created timestamp with time zone not null default now(),
modified timestamp with time zone not null defau... |
Fix a SQL syntax error | -- avoid innocuous NOTICEs about automatic sequence creation
set client_min_messages='WARNING';
-- Tell psql to stop on an error. Default behavior is to proceed.
\set ON_ERROR_STOP 1
-- Tables for the KM
-- ----------------------------------------------------------------------
DROP TABLE IF EXISTS km_asserted_attrib... | -- avoid innocuous NOTICEs about automatic sequence creation
set client_min_messages='WARNING';
-- Tell psql to stop on an error. Default behavior is to proceed.
\set ON_ERROR_STOP 1
-- Tables for the KM
-- ----------------------------------------------------------------------
DROP TABLE IF EXISTS km_asserted_attrib... |
Add update user photo sql function. | -- :name create-profile :<! :1
-- :doc Create a new user entry.
insert into users (id, fullname, username, email, password, metadata)
values (:id, :fullname, :username, :email, :password, :metadata)
returning *;
-- :name get-profile :? :1
-- :doc Retrieve the profile data.
select * from users
where id = :id and ... | -- :name create-profile :<! :1
insert into users (id, fullname, username, email, password, metadata, photo)
values (:id, :fullname, :username, :email, :password, :metadata, '')
returning *;
-- :name get-profile :? :1
select * from users
where id = :id and deleted = false;
-- :name get-profile-by-username :? :1
selec... |
Add UUID to signages view | CREATE VIEW {# geotrek.signage #}.v_signages AS (
SELECT e.geom, e.id, t.*
FROM signage_signage AS t, signage_signagetype AS b, core_topology AS e
WHERE t.topo_object_id = e.id AND t.type_id = b.id
AND e.deleted = FALSE
);
| CREATE VIEW {# geotrek.signage #}.v_signages AS (
SELECT e.geom, e.id, e.uuid, t.*
FROM signage_signage AS t, signage_signagetype AS b, core_topology AS e
WHERE t.topo_object_id = e.id AND t.type_id = b.id
AND e.deleted = FALSE
);
|
Make MySQL user passwords match | # Create a MySQL user with limited privileges for backup purposes.
# This isn't strictly necessary on a local machine - you could just use the root
# MySQL user in the backup script.
# ==============================================================================
# Get a MySQL/MariaDB prompt:
mysql -u root -p
# In th... | # Create a MySQL user with limited privileges for backup purposes.
# This isn't strictly necessary on a local machine - you could just use the root
# MySQL user in the backup script.
# ==============================================================================
# Get a MySQL/MariaDB prompt:
mysql -u root -p
# In th... |
Fix the Oracle upgrade script | ALTER TABLE share ADD latency_threshold NUMBER(*,0);
UPDATE share SET latency_threshold = 20;
COMMIT;
QUIT;
| ALTER TABLE "share" ADD latency_threshold NUMBER(*,0);
UPDATE "share" SET latency_threshold = 20;
COMMIT;
QUIT;
|
Remove the duplicated entry "route.all-resources". | #This contains all the db schema changes that are going to be applied every time the server is deployed
delete from ofProperty where name='provider.lockout.className';
insert into ofProperty values ('provider.lockout.className', 'com.magnet.mmx.lockout.MmxLockoutProvider');
delete from ofProperty where name='xmpp.pars... | #This contains all the db schema changes that are going to be applied every time the server is deployed
delete from ofProperty where name='provider.lockout.className';
insert into ofProperty values ('provider.lockout.className', 'com.magnet.mmx.lockout.MmxLockoutProvider');
delete from ofProperty where name='xmpp.pars... |
Enlarge SQL fields to more comfortable sizes |
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
CREATE TABLE `is... |
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
CREATE TABLE `is... |
Fix the query and test insert Argomenti. | #Create db 'des' (Database-Exercise-System)
CREATE DATABASE IF NOT EXISTS des;
#Create 'argomenti' table
CREATE TABLE IF NOT EXISTS argomenti(
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
argomento varchar(255) NOT NULL
);
#Create 'soluzioni' table
CREATE TABLE IF NOT EXISTS soluzioni(
id INT PRIMARY KEY AUTO_I... | #Create db 'des' (Database-Exercise-System)
CREATE DATABASE IF NOT EXISTS des;
#Create 'argomenti' table
CREATE TABLE IF NOT EXISTS des.argomenti(
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
argomento varchar(255) NOT NULL
);
#Create 'soluzioni' table
CREATE TABLE IF NOT EXISTS des.soluzioni(
id INT PRIMARY KE... |
Fix user ID in migration 32 | ALTER TABLE jam
ADD COLUMN jam_default_icon_url TEXT NULL AFTER jam_colors;
UPDATE jam
SET jam_default_icon_url = "logo.png";
INSERT INTO config
(config_lastedited, config_lasteditedby, config_key, config_value, config_category, config_description, config_type, config_options, config_editable, config_required, confi... | ALTER TABLE jam
ADD COLUMN jam_default_icon_url TEXT NULL AFTER jam_colors;
UPDATE jam
SET jam_default_icon_url = "logo.png";
INSERT INTO config
(config_lastedited, config_lasteditedby, config_key, config_value, config_category, config_description, config_type, config_options, config_editable, config_required, confi... |
Set db default collation & charset | drop database if exists mo_development;
create database mo_development;
drop database if exists mo_test;
create database mo_test;
drop database if exists mo_tmp;
create database mo_tmp;
use mo_tmp;
drop procedure if exists createUser;
delimiter $$
create procedure createUser(username varchar(50), pw varchar(50))
begin... | drop database if exists mo_development;
create database mo_development
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
drop database if exists mo_test;
create database mo_test
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
drop database if exists mo_tmp;
create database mo_tmp;
use mo_t... |
Add test of name in trend record | BEGIN;
SELECT plan(2);
SELECT trend_directory.create_table_trend_store(
'test1',
'some_entity_type_name',
'900',
ARRAY[
('x', 'integer', 'some column with integer values')
]::trend_directory.trend_descr[]
);
SELECT columns_are(
'trend',
'test1_some_entity_type_name_qtr',
ARRAY... | BEGIN;
SELECT plan(3);
SELECT trend_directory.create_table_trend_store(
'test1',
'some_entity_type_name',
'900',
ARRAY[
('x', 'integer', 'some column with integer values')
]::trend_directory.trend_descr[]
);
SELECT columns_are(
'trend',
'test1_some_entity_type_name_qtr',
ARRAY... |
Add v17 update script to schema creation script | -- Generate core schema
\i schema/generate/01-schema.sql
\i schema/generate/02-augur_data.sql
\i schema/generate/03-augur_operations.sql
\i schema/generate/04-spdx.sql
\i schema/generate/05-seed_data.sql
-- Update scripts
\i schema/generate/06-schema_update_8.sql
\i schema/generate/07-schema_update_9.sql
\i schema/gen... | -- Generate core schema
\i schema/generate/01-schema.sql
\i schema/generate/02-augur_data.sql
\i schema/generate/03-augur_operations.sql
\i schema/generate/04-spdx.sql
\i schema/generate/05-seed_data.sql
-- Update scripts
\i schema/generate/06-schema_update_8.sql
\i schema/generate/07-schema_update_9.sql
\i schema/gen... |
Fix the primary key uniqueness. | create type distribution as enum('stable', 'testing', 'unstable', 'experimental');
create type component as enum('main');
create table source (
name varchar(255) not null,
distribution distribution not null,
component component not null default 'main',
version varchar(255) not null,
primary key(nam... | create type distribution as enum('stable', 'testing', 'unstable', 'experimental');
create type component as enum('main');
create table source (
name varchar(255) not null,
distribution distribution not null,
component component not null default 'main',
version varchar(255) not null,
primary key(nam... |
Remove link that does not work | -- SQL to show number of records recorded earlier than tracking_start_date_time.
-- Those records should be removed.
-- https://lifewatch-inbo.cartodb.com/viz/5d42a40a-9951-11e3-8315-0ed66c7bc7f3/table
select
count(*)
from
bird_tracking as t
left join bird_tracking_devices as d
on t.device_info_serial = d.device_inf... | -- SQL to show number of records recorded earlier than tracking_start_date_time.
-- Those records should be removed.
select
count(*)
from
bird_tracking as t
left join bird_tracking_devices as d
on t.device_info_serial = d.device_info_serial
where
t.date_time < d.tracking_start_date_time
|
Rearrange drop tables for uninstall | DROP TABLE IF EXISTS `civicrm_sms_conversation`;
DROP TABLE IF EXISTS `civicrm_sms_conversation_question`;
DROP TABLE IF EXISTS `civicrm_sms_conversation_contact`;
DROP TABLE IF EXISTS `civicrm_sms_conversation_action`;
| DROP TABLE IF EXISTS `civicrm_sms_conversation_action`;
DROP TABLE IF EXISTS `civicrm_sms_conversation_contact`;
DROP TABLE IF EXISTS `civicrm_sms_conversation`;
DROP TABLE IF EXISTS `civicrm_sms_conversation_question`;
|
Optimize member metrics for campaigns | INSERT INTO speakeasy_petition_metrics
(campaign_id, activity, is_opt_out, npeople)
SELECT
campaign_id AS campaign_id,
status AS activity,
is_opt_out AS is_opt_out,
COUNT(*) AS npeople
FROM
civicrm_contact c
JOIN civicrm_group_contact g ON g.contact_id = c.id AND g.group_id = 42 AND c.is_del... | INSERT INTO speakeasy_petition_metrics
(campaign_id, activity, is_opt_out, npeople)
SELECT
camp.id AS campaign_id,
status AS activity,
is_opt_out AS is_opt_out,
COUNT(*) AS npeople
FROM
civicrm_contact c
JOIN civicrm_group_contact g ON g.contact_id = c.id AND g.group_id = 42 AND c.is_deleted... |
Update MySQL init script with more comments. | CREATE TABLE IF NOT EXISTS `KV` (
-- MySQL InnoDB indexes are limited to 767 bytes
-- You can go up to 3072 bytes if you set innodb_large_prefix
-- See: http://dev.mysql.com/doc/refman/5.5/en/innodb-restrictions.html
-- Also recommended: innodb_file_per_table
`kv_key` VARBINARY(767) NOT NULL,
`kv... | CREATE TABLE IF NOT EXISTS `KV` (
`kv_key` VARBINARY(767) NOT NULL,
`kv_value` LONGBLOB NOT NULL,
PRIMARY KEY(`kv_key`)
) ENGINE=InnoDB default charset=utf8 collate=utf8_bin
--
-- MySQL InnoDB indexes are normally limited to 767 bytes, but
-- you can go up to 3072 bytes if you set innodb_large_prefix=true;
--... |
Use decimal literal to avoid precision problems in TPCH Q6 | -- database: presto; groups: tpch,quarantine; tables: lineitem
SELECT sum(l_extendedprice * l_discount) AS revenue
FROM
lineitem
WHERE
l_shipdate >= DATE '1994-01-01'
AND l_shipdate < DATE '1994-01-01' + INTERVAL '1' YEAR
AND l_discount BETWEEN 0.06 - 0.01 AND 0.06 + 0.01
AND l_quantity < 24
| -- database: presto; groups: tpch,quarantine; tables: lineitem
SELECT sum(l_extendedprice * l_discount) AS revenue
FROM
lineitem
WHERE
l_shipdate >= DATE '1994-01-01'
AND l_shipdate < DATE '1994-01-01' + INTERVAL '1' YEAR
AND l_discount BETWEEN decimal '0.06' - decimal '0.01' AND decimal '0.06' + decimal '0.01'
A... |
Add new location and code query | -- Shows codes for a game
SELECT `code_lookup`.`code`, `code_lookup`.`type`, `code_lookup`.`location_id`, `locations`.`internal_note`, `locations`.`is_start`, `locations`.`is_end` FROM `code_lookup` LEFT OUTER JOIN `locations` ON `code_lookup`.`game_id` = `locations`.`game_id` AND `code_lookup`.`location_id` = `locatio... | -- Shows codes for a game
SELECT `code_lookup`.`code`, `code_lookup`.`type`, `code_lookup`.`location_id`, `locations`.`internal_note`, `locations`.`is_start`, `locations`.`is_end` FROM `code_lookup` LEFT OUTER JOIN `locations` ON `code_lookup`.`game_id` = `locations`.`game_id` AND `code_lookup`.`location_id` = `locatio... |
Add IF NOT EXISTS modifiers to table defs | -- Keyspace -------------------------------------------------------------------
CREATE KEYSPACE uuuurrrrllll
WITH replication = {
-- 'class': 'NetworkTopologyStrategy', 'replication_factor': '3'
'class': 'SimpleStrategy', 'replication_factor': '1'
};
CREATE TABLE uuuurrrrllll.message (
short_url text,
... | -- Keyspace -------------------------------------------------------------------
CREATE KEYSPACE IF NOT EXISTS uuuurrrrllll
WITH replication = {
-- 'class': 'NetworkTopologyStrategy', 'replication_factor': '3'
'class': 'SimpleStrategy', 'replication_factor': '1'
};
CREATE TABLE IF NOT EXISTS uuuurrrrllll.messa... |
Create table if not exist. | begin;
create table ncaa_sr.polls (
year integer,
school_id text,
school_name text,
week text,
rank integer,
primary key (year,school_id,week)
);
copy ncaa_sr.polls from '/tmp/polls.csv' with delimiter as ',' csv header quote as '"';
commit;
| begin;
create table if not exists ncaa_sr.polls (
year integer,
school_id text,
school_name text,
week text,
rank integer,
primary key (year,school_id,week)
);
copy ncaa_sr.polls from '/tmp/polls.csv' with delimiter as ',' csv header quote as '"';
commit;
|
Add missing SVN id keyword | -- tiki_myisam.sql is run after tiki.sql if MyISAM is being installed
CREATE FULLTEXT INDEX ft ON tiki_articles(`title`, `heading`, `body`);
CREATE FULLTEXT INDEX ft ON tiki_blog_posts(`data`, `title`);
CREATE FULLTEXT INDEX ft ON tiki_blogs(`title`, `description`);
CREATE FULLTEXT INDEX ft ON tiki_calendar_items(`name... | -- tiki_myisam.sql is run after tiki.sql if MyISAM is being installed
-- $Id$
CREATE FULLTEXT INDEX ft ON tiki_articles(`title`, `heading`, `body`);
CREATE FULLTEXT INDEX ft ON tiki_blog_posts(`data`, `title`);
CREATE FULLTEXT INDEX ft ON tiki_blogs(`title`, `description`);
CREATE FULLTEXT INDEX ft ON tiki_calendar_ite... |
Add running indicies script to upgrade | -- upgrade the previous schema to the current schema
-- 1.4.3 -> 1.5.0 in this version
--
-- Copyright 2013,2014 Google Inc. All Rights Reserved.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the Lice... | -- upgrade the previous schema to the current schema
-- 1.4.3 -> 1.5.0 in this version
--
-- Copyright 2013,2014 Google Inc. All Rights Reserved.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the Lice... |
Change from mediumtext to varchar |
DROP TABLE IF EXISTS `Config`;
CREATE TABLE `Config` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL COMMENT 'Configuration name',
`Value` VARCHAR(255) NOT NULL COMMENT 'Configuration Value',
`Description` MEDIUMTEXT(1024) NULL DEFAULT NULL COMMENT 'Configuration description',
`Config... |
DROP TABLE IF EXISTS `Config`;
CREATE TABLE `Config` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`Name` VARCHAR (64) NOT NULL COMMENT 'Configuration name',
`Value` VARCHAR(255) NOT NULL COMMENT 'Configuration Value',
`Description` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Configuration description',
`Config_gro... |
Fix SQL to create the entity_type and sequence tables | /* File generated automatically by dynamo */
/* Entity types */
CREATE TABLE entity_type (
/* the entity type identifier */
"id" INTEGER AUTO_INCREMENT,
/* the entity type name (table name) */
"name" VARCHAR(127) UNIQUE NOT NULL,
PRIMARY KEY ("id")
);
/* Sequence generator */
CREATE TABLE sequence (
/* the... | /* File generated automatically by dynamo */
/* Entity types */
CREATE TABLE entity_type (
/* the entity type identifier */
"id" SERIAL,
/* the entity type name (table name) */
"name" VARCHAR(127) UNIQUE NOT NULL,
PRIMARY KEY ("id")
);
/* Sequence generator */
CREATE TABLE sequence (
/* the sequence name */... |
Fix the script for inserting divisions | insert into divisions values 'PACIFIC', 'CENTRAL', 'METROPOLITAN', 'ATLANTIC'; | insert into divisions(name) values ('PACIFIC'), ('CENTRAL'), ('METROPOLITAN'), ('ATLANTIC'); |
Add author timestamp field to hash table | -- git_hash table
--
-- Stores ONLY metadata about commits that MediaWiki CANNOT store.
--
-- The other tables git_status_modify_hash and git_edit_hash store
-- actual CHANGES of a commit that MediaWiki cannot store or cannot
-- store in a suitable format.
CREATE TABLE IF NOT EXISTS /*_*/git_hash(
-- The primary... | -- git_hash table
--
-- Stores ONLY metadata about commits that MediaWiki CANNOT store.
--
-- The other tables git_status_modify_hash and git_edit_hash store
-- actual CHANGES of a commit that MediaWiki cannot store or cannot
-- store in a suitable format.
CREATE TABLE IF NOT EXISTS /*_*/git_hash(
-- The primary... |
Fix users_merits table to include timestamps. | CREATE TABLE users_merits (user_id INT, merit_id INT, created_at DATE);
| CREATE TABLE users_merits (
user_id INT,
merit_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
|
Add project avail code n to animal billable days report | PARAMETERS
(START_DATE TIMESTAMP, END_DATE TIMESTAMP)
SELECT id
, GROUP_CONCAT(project, ', ') as Projects
, GROUP_CONCAT(date, ', ') as AssignmentDates
, GROUP_CONCAT(enddate, ', ') as ReleaseDates
, GROUP_CONCAT(project.avail, ', ') as ProjectAvails
FROM study.assignment
WHERE... | PARAMETERS
(START_DATE TIMESTAMP, END_DATE TIMESTAMP)
SELECT id
, GROUP_CONCAT(project, ', ') as Projects
, GROUP_CONCAT(date, ', ') as AssignmentDates
, GROUP_CONCAT(enddate, ', ') as ReleaseDates
, GROUP_CONCAT(project.avail, ', ') as ProjectAvails
FROM study.assignment
WHERE... |
Remove unnecessary foreign key constraint. | ALTER TABLE REPOSITORY ADD COLUMN ORIGIN_USER_NAME VARCHAR(100);
ALTER TABLE REPOSITORY ADD COLUMN ORIGIN_REPOSITORY_NAME VARCHAR(100);
ALTER TABLE REPOSITORY ADD COLUMN PARENT_USER_NAME VARCHAR(100);
ALTER TABLE REPOSITORY ADD COLUMN PARENT_REPOSITORY_NAME VARCHAR(100);
CREATE TABLE PULL_REQUEST(
USER_NAME VARCHAR(... | ALTER TABLE REPOSITORY ADD COLUMN ORIGIN_USER_NAME VARCHAR(100);
ALTER TABLE REPOSITORY ADD COLUMN ORIGIN_REPOSITORY_NAME VARCHAR(100);
ALTER TABLE REPOSITORY ADD COLUMN PARENT_USER_NAME VARCHAR(100);
ALTER TABLE REPOSITORY ADD COLUMN PARENT_REPOSITORY_NAME VARCHAR(100);
CREATE TABLE PULL_REQUEST(
USER_NAME VARCHAR(... |
Update sql query for removing recipe follow | DELETE FROM
followers_users_recipes
WHERE
user_id = ${user_id}
AND recipe_id = ${recipe_id}
RETURNING *;
| DELETE FROM
followers_users_recipes
WHERE
user_id = ${userID}
AND recipe_id = ${targetID}
RETURNING *;
|
Create indexes for tables with a FK to job.id | CREATE INDEX log_job_id on log (job_id);
CREATE INDEX performance_job_id on performance (job_id);
CREATE INDEX output_job_id on output (oq_job_id);
| |
Add script to update terms and conditions table with reference to new template | -- IFS-3980
-- New version of site-wide terms and conditions to include GDPR notice
SET @system_maintenance_user_id =
(SELECT id FROM user WHERE email = 'ifs_system_maintenance_user@innovateuk.org');
INSERT INTO terms_and_conditions (name, template, version, type, created_by, created_on, modified_on, modified_by)
VAL... | |
Add a function for creating a report of traffic from the database nicely consolated for us already | CREATE OR REPLACE FUNCTION snort.report_traffic_for_site_within_timeperiod(_site_id bigint, _seconds bigint)
RETURNS json
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
traffic_report_cursor cursor (query_site_id bigint, interval_seconds bigint) FOR
SELECT nsip_src.ip_address AS src_ip, nsip_ds... | |
Fix Portal/Teleport to Tol Barad | -- Fix Mage's Tol barad Portals and Teleports
UPDATE gameobject_template SET data0=88341 WHERE entry=206615; -- ally portal
UPDATE gameobject_template SET data0=88339 WHERE entry=206616; -- horde portal
DELETE FROM spell_target_position WHERE id IN (88342, 88344);
INSERT INTO spell_target_position VALUES
(88342, 732,... | |
Update lukukausimaksukokeilu to lukukausimaksu (and translations) | USE [VipunenTK_lisatiedot]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[rahoituslahde]') AND type in (N'U'))
update [dbo].[rahoituslahde]
set [rahoituslahde] = 'Lukukausimaksu' --old Lukukausimaksukokeilu
,[rahoituslahde_SV] = 'Terminsavgift' --old Experiment med terminsavgi... | |
Fix errors caused by c81c0b3. | # --- !Ups
create table issue_event (
id bigint not null,
created timestamp,
sender_login_id varchar(255),
issue_id bigint,
event_type varchar(26),
old_value varchar(255),
new_value varchar(255),
... | |
Include seed data for testing MySQL | USE uncovery;
INSERT INTO users (token) VALUES ('Archon');
INSERT INTO users (token) VALUES ('Carrier');
INSERT INTO users (token) VALUES ('Colossus');
INSERT INTO users (token) VALUES ('Dark Templar');
INSERT INTO users (token) VALUES ('Zealot');
INSERT INTO users (token) VALUES ('SCV');
INSERT INTO users (token) VAL... | |
Add SQL file to create required tables | CREATE TABLE IF NOT EXISTS `Lectura` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`data` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`trasto_id` char(64) CHARACTER SET latin1 COLLATE latin1_spanish_ci NOT NULL,
`intensitat` float DEFAULT NULL,
`tensio` float DEFAULT NULL,
... | |
Add sql solution for 626. Exchange Seats | SELECT IF(`id` = (SELECT MAX(`id`) FROM `seat`) AND (`id` & 1), `id`, IF(`id` & 1, `id` + 1, `id` - 1)) AS `id`, `student` FROM `seat` ORDER BY `id`
| |
Add missing comma in SQL migration. | CREATE TABLE `wiki_documentlink` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`linked_from_id` integer NOT NULL,
`linked_to_id` integer NOT NULL,
`kind` varchar(16) NOT NULL
UNIQUE (`linked_from_id`, `linked_to_id`)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wik... | CREATE TABLE `wiki_documentlink` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`linked_to_id` integer NOT NULL,
`linked_from_id` integer NOT NULL,
`kind` varchar(16) NOT NULL,
UNIQUE (`linked_from_id`, `linked_to_id`)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wi... |
Add SQL for selecting all blog posts. | SELECT
`blog_post`.`post_id`,
`blog_post`.`title`,
`blog_post`.`body`,
`blog_post`.`category`,
`blog_post`.`created`,
`blog_post`.`created_by`
FROM
`blog_post`;
| |
Make users have secret keys, not the user/app relationship. | # ---!Ups
alter table application_users drop column secret_key;
alter table users add column secret_key varchar(36) not null;
drop index application_users_idx;
create index users_secret_key_idx on users (username, secret_key);
# ---!Downs
alter table application_users add column secret_key varchar(36) not null;
alter ... | |
Fix bad upgrade014_015 ALTER TABLE command | -- Upgrade: schema_version 14 to 15
--
ALTER TABLE patch_comments ADD parent_uuid VARCHAR(40);
CREATE TABLE account_patch_reviews
(account_id INTEGER NOT NULL DEFAULT(0),
change_id INTEGER NOT NULL DEFAULT(0),
patch_set_id INTEGER NOT NULL DEFAULT(0),
file_name VARCHAR(255) NOT NULL DEFAULT(''),
PRIMARY KEY (account_i... | -- Upgrade: schema_version 14 to 15
--
ALTER TABLE patch_comments ADD parent_uuid VARCHAR(40);
CREATE TABLE account_patch_reviews
(account_id INTEGER NOT NULL DEFAULT(0),
change_id INTEGER NOT NULL DEFAULT(0),
patch_set_id INTEGER NOT NULL DEFAULT(0),
file_name VARCHAR(255) NOT NULL DEFAULT(''),
PRIMARY KEY (account_i... |
Migrate db partition incomes by user_id |
-- +goose Up
-- SQL in section 'Up' is executed when this migration is applied
ALTER TABLE `incomes` DROP PRIMARY KEY, ADD PRIMARY KEY (`id`, `user_id`) PARTITION BY HASH(`user_id`) PARTITIONS 4096;
-- +goose Down
-- SQL section 'Down' is executed when this migration is rolled back
ALTER TABLE `incomes` REMOVE PARTIT... | |
Add active field to manuscript table | -- Author: dan.leehr@nescent.org
--
-- Organizations
CREATE SEQUENCE organization_seq;
CREATE TABLE organization
(
organization_id INTEGER PRIMARY KEY not null default nextval('organization_seq'),
code VARCHAR(32) not null,
name VARCHAR(255) not null
);
CREATE UNIQUE INDEX org_code_idx on organization(code);
-... | -- Author: dan.leehr@nescent.org
--
-- Organizations
CREATE SEQUENCE organization_seq;
CREATE TABLE organization
(
organization_id INTEGER PRIMARY KEY not null default nextval('organization_seq'),
code VARCHAR(32) not null,
name VARCHAR(255) not null
);
CREATE UNIQUE INDEX org_code_idx on organization(code);
-... |
Add script showing cyclic parents in Nominatim | select c.place_id,c.name,c.parent_place_id,c.linked_place_id,c.osm_id,c.osm_type,c.indexed_status
from placex c
join placex r on r.place_id=c.parent_place_id
where r.parent_place_id=c.place_id;
| |
Add myplaces3 to ol4 appsetup |
UPDATE portti_view_bundle_seq SET startup = '{
"metadata": {
"Import-Bundle": {
"maparcgis": {
"bundlePath": "/Oskari/packages/mapping/ol3/"
},
"mapmodule": {
"bundlePath": "/Oskari/packages/mapping/ol3/"
},
"oskariui": {
"bundlePath": "/Oskari/packages/framework/bundle/"
},
"mapwf... | |
Add description to adminisrator role in bootstrap data | UPDATE referencedata.roles
SET description = 'System administrator.'
WHERE id = 'a439c5de-b8aa-11e6-80f5-76304dec7eb7'; | |
Add extra attributes to the attribute table. | -- Copyright [1999-2016] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/... | |
Add file of data base,Table User will be created and some users will be implemented | CREATE TABLE Utilisateur {
IdUser int NOT NULL AUTO_INCREMENT,
Username VARCHAR 100,
Password VARCHAR 100,
Email VARCHAR 100
};
INSERT INTO Utilisateur VALUES ('anthony','anthony','anthony@barei.fr');
INSERT INTO Utilisateur VALUES ('elliezar','elliezar','elliezar@rayray.fr');
INSERT INTO Utilisateur VALUES ('qix... | |
Add trigger to create borrower debarment | DROP TRIGGER IF EXISTS autoKemnerSperring;
delimiter //
CREATE TRIGGER autoKemnerSperring BEFORE UPDATE ON items
FOR EACH ROW
BEGIN
IF NEW.itemlost = 12 AND (OLD.itemlost != 12 OR OLD.itemlost IS NULL) THEN
INSERT INTO borrower_debarments (borrowernumber, type, comment, manager_id)
(SELECT borrowernumber, 'MA... | |
Add script to update database schema | -- create procedure
DELIMITER $$
DROP PROCEDURE IF EXISTS updateMSE$$
CREATE PROCEDURE updateMSE()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE p_testcase_id VARCHAR(125);
DECLARE p_auc_result VARCHAR(125);
DECLARE p_auc_time DATETIME;
DECLARE cur1 CURSOR FOR
SELECT test_case_id,date,result
FROM h2... | |
Add Kev Riley VLF count script | /*
https://gallery.technet.microsoft.com/scriptcenter/SQL-Script-to-list-VLF-e6315249
Kev Riley
*/
--variables to hold each 'iteration'
declare @query varchar(100)
declare @dbname sysname
declare @vlfs int
--table variable used to 'loop' over databases
declare @databases table (dbname sysname)
insert in... | |
Create indexes for tables with a FK to job.id | CREATE INDEX log_job_id on log (job_id);
CREATE INDEX performance_job_id on performance (job_id);
CREATE INDEX output_job_id on output (oq_job_id);
| |
Add procedure occurrence dimension with ICD-9-CM | /* Build procedure occurrence dimension table. This uses the ICD-9-CM
* vocabulary. */
INSERT INTO #dim
SELECT
cp.person_id,
SUBSTRING(REPLACE(sm.source_code, '.', '') FROM 2 FOR 3) AS covariate_id,
COUNT(SUBSTRING(REPLACE(sm.source_code, '.', '') FROM 2 FOR 3))
AS covariate_count
FROM
#cohort_... | |
Add script for reversing incorrectly-set project lat/long coordinates | -- Reverses project lat/long coordinates, as they were set in reversed order initially
UPDATE
civictechprojects_project
SET
project_location_coords = st_geometryfromtext('POINT('|| ST_Y(project_location_coords) ||' '|| ST_X(project_location_coords) ||')', 4326);
| |
Create parameter protocolProjectEndDateNumberOfYears for creating proposal development from IRB protocol | INSERT INTO KRCR_PARM_T (NMSPC_CD, CMPNT_CD, PARM_NM, OBJ_ID, VER_NBR, PARM_TYP_CD, VAL, PARM_DESC_TXT, EVAL_OPRTR_CD, APPL_ID)
VALUES ('KC-PROTOCOL', 'Document', 'protocolProjectEndDateNumberOfYears', SYS_GUID(), 1, 'CONFG', '5', 'Number of Years for Proposal Development Project End Date', 'A', 'KUALI')
/
| |
Make use of language support for pxweb | UPDATE oskari_statistical_datasource SET config='{
"url": "https://pxnet2.stat.fi/pxweb/api/v1/{language}/Kuntien_avainluvut/2018/kuntien_avainluvut_2018_aikasarja.px",
"info": {
"url": "http://www.tilastokeskus.fi"
},
"regionKey": "Alue 2018",
"indicatorKey": "Tiedot",
"hints" : {
"dimensions" : [ {
... | |
Create a summary table of the extents of the hocr areas | /*
We're going to introduce some data quality here that needs to be
carried through when using this table:
- text with less than 2 characters is skipped
- images with x or y < 100 are skipped
- words who's x0, x1, y0, or y1 are within 10 of the edge of the image
are skipped
*/
CREATE TABLE
text_extent
SELECT
occ... | |
Add the ship changes script for current round. | UPDATE smr_new.ship_type SET cost = 12026598 WHERE ship_type_id = 21; -- Federal Warrant to 12,026,598 credits
UPDATE smr_new.ship_type SET cost = 23675738 WHERE ship_type_id = 22; -- Federal Ultimatum to 23,675,738 credits
UPDATE smr_new.ship_type SET cost = 7483452 WHERE ship_type_id = 24; -- Assasin to 7,483,452 cre... | |
Add the SQL for the hello world example | CREATE TABLE HELLOWORLD (
HELLO VARCHAR(15),
WORLD VARCHAR(15),
DIALECT VARCHAR(15) NOT NULL,
PRIMARY KEY (DIALECT)
);
PARTITION TABLE HELLOWORLD ON COLUMN DIALECT;
CREATE PROCEDURE Insert PARTITION ON TABLE Helloworld COLUMN Dialect
AS INSERT INTO HELLOWORLD (Dialect, Hello, World) VALUES (?, ?, ?);
CR... | |
Add ITN roads view (roadlink with roadname and road.fid) | -- Lookup between road and roadlink on fid
CREATE OR REPLACE VIEW osmm_itn.road_roadlink AS
SELECT road_fid,
replace(roadlink_fid, '#', '') AS roadlink_fid
FROM
(SELECT fid AS road_fid,
unnest(networkmember_href) AS roadlink_fid
FROM osmm_itn.road) AS a;
-- Each roadlink with associated roadname(... | |
Test script for Niels' newly introduced code + bugs | SET auto_commit=true;
-- the following statements should all fail
ROLLBACK;
COMMIT;
SAVEPOINT failingsavepoint;
-- this one is incorrect since the savepoint should not exist
-- however, the server might answer with an error about auto_commit
-- for that might be cheaper
RELEASE SAVEPOINT failingsavepoint;
| |
Store precedure for insert data into bioassay_data_data_category | -- insert data into bioassay_data_data_category
declare
cursor c_bioassay_data_category is
select chara.NAME name, data.DERIVED_BIOASSAY_DATA_PK_ID id, data.CATEGORY category
from DERIVED_BIOASSAY_DATA data, CHARACTERIZATION chara
where data.CHARACTERIZATION_PK_ID = chara.CHARACTERIZATION_PK_ID
and data.CATEGORY i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.