text stringlengths 6 9.38M |
|---|
#存储过程和函数
/*
存储过程和函数:类似于Java中的方法
好处:
1.提高代码的重用性
2.简化操作
*/
#存储过程
/*
定义:一组预先编译好的SQL语句的集合,理解成批处理SQL语句
1,提高代码的重用性
2,简化操作
3,减少了编译次数并且减少了和数据库服务器的连接次数,提高了效率
*/
#一、创建语法
CREATE PROCEDURE 存储过程名(参数列表)
BEGIN
存储过程体(一组合法的SQL语句)
END
#注意:
/*
1、参数列表包含三部分
参数模式 参数名 参数类型
举例:
in 参数名 varchar(20)
参数模式:
... |
DROP DATABASE IF EXISTS passport_demo;
CREATE DATABASE passport_demo;
|
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 50173
Source Host : localhost:3306
Source Schema : mt-store
Target Server Type : MySQL
Target Server Version : 50173
File Encoding : 65001
Date: 07/06/2020 1... |
create table blog_entries(
id int not null auto_increment primary key,
text text not null,
name varchar(25) not null,
time timestamp not null default current_timestamp,
key(time)
) engine=InnoDB charset=utf8;
create table blog_comments(
id int not null auto_increment primary key,
blog_entry_id int not nu... |
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jul 26, 2021 at 04:42 PM
-- Server version: 8.0.21
-- PHP Version: 7.4.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@... |
--------------------------------------------------------------------------
-- .rem command test
--------------------------------------------------------------------------
.help rem
.rem
SELECT 1234;
.end rem
.help rem
.rem asdfasdfasdf
asdfasdf;
asd;
a//z/
.end rem
.help rem
|
/*SELECT
product_name,
brand_name,
list_price
FROM
production.products p
INNER JOIN production.brands b
ON b.brand_id = p.brand_id;
*/
/*CREATE VIEW sales.product_info
AS
SELECT
product_name,
brand_name,
list_price
FROM
production.products p
INNER JOIN pro... |
insert into bonuses (name, valid_from, valid_to, type, created_by, created_date, promotion_id,
amount, maximum_amount, quantity, percentage, currency, required_level,
allowed_countries, max_grant_numbers)
values
('Welcome Bonus: 200% Match bonus up to €200', timestamp('2014-... |
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 11-07-2017 a las 08:08:37
-- Versión del servidor: 10.1.21-MariaDB
-- Versión de PHP: 7.1.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLI... |
/* number of dives by diver */
SELECT COUNT(diver_id) AS number_of_dives
FROM dives
WHERE diver_id = 1
GROUP BY diver_id;
/* average dive duration by location */
SELECT AVG(duration)
::INT AS average_duration
FROM dives WHERE location_id = 1 GROUP BY location_id;
/* most active month */
SELECT DATE_TRUNC('month', div... |
INSERT INTO coach (name_first, name_last, email, sport, team_name)
VALUES ($1, $2, $3, $4, $5)
RETURNING *;
|
ALTER TABLE user
ADD COLUMN password VARCHAR(50) NOT NULL COMMENT '密码';
|
DELIMITER $$
USE `cci_gh_go_dev`$$
DROP PROCEDURE IF EXISTS `SPAdminQSFieldStaffApplicationStats`$$
CREATE DEFINER=`phanipothula`@`%` PROCEDURE `SPAdminQSFieldStaffApplicationStats`()
BEGIN
DELETE FROM `AdminQuickStatsCategoryAggregate`
WHERE `adminQSTypeId` = 1 AND `adminQSCategoryId` = 4;
ALTER TABLE Ad... |
/*
Navicat SQLite Data Transfer
Source Server : Douban
Source Server Version : 30808
Source Host : :0
Target Server Type : SQLite
Target Server Version : 30808
File Encoding : 65001
Date: 2017-01-17 22:49:35
*/
PRAGMA foreign_keys = OFF;
-- ----------------------------
-- Table structu... |
CREATE TABLE [ERP].[ValeTransferenciaReferencia] (
[ID] INT IDENTITY (1, 1) NOT NULL,
[IdValeTransferencia] INT NULL,
[IdReferenciaOrigen] INT NULL,
[IdReferencia] INT NULL,
[IdTipoComprobante] INT NULL,
[Serie] ... |
SELECT -- WHAT TO BUILD and where to sell
/*
One way to yield on this is to build 5-10 different kinds of products out of those that show higher profits,
and keep filling the shelves as they sell. Another valuable info is which products do not seem profitable at the moment.
*/
INITCAP(fin.produce) AS... |
-- Скрипт создает последнее состояние бд, после создания не нужно применять миграции
CREATE TABLE db_info(
id SERIAL PRIMARY KEY,
major INTEGER NOT NULL,
minor INTEGER NOT NULL,
patch INTEGER NOT NULL,
UNIQUE (major, minor, patch)
);
INSERT INTO db_info(major, minor, patch) VALUES(1, 0, 1);
CREATE TABLE product... |
/* [1] Apresentar os detalhes dos departamentos ordenados pelo nome de forma ascendente */
SELECT * FROM departments d ORDER BY d.department_name ASC ;
/* [2] Apresentar os nomes dos departamentos e os responsaveis por estes */
SELECT d.department_name, e.first_name, e.last_name FROM departments d, employees e WHERE d... |
/*
Subquries practices
*/
SELECT
o.name,
COUNT(m.id)
FROM
orchestras AS o
JOIN members AS m ON o.id = m.orchestra_id
GROUP BY
1
HAVING
COUNT(m.id) > (SELECT AVG (d.count1)
FROM (SELECT COUNT (*) AS count1 FROM members GROUP BY orchestra_id)
... |
DROP TABLE IF EXISTS `XXX_deepltrans_data`; ##b_dump##
DROP TABLE IF EXISTS `XXX_plugin_deepltrans_data`; ##b_dump##
DROP TABLE IF EXISTS `XXX_plugin_deepltrans_deepltrans_form`; ##b_dump##
DROP TABLE IF EXISTS `XXX_plugin_deepltrans_einstellun_form`; ##b_dump##
DROP TABLE IF EXISTS `XXX_plugin_deepltrans_bersetzung_f... |
rollback ;
savepoint 1;
commit;
set AUTOCOMMIT ON; -- 设置自动提交事务
select sysdate from dual; -- 返回当前数据库本地时间
select TO_CHAR(CURRENT_DATE,'YYYY-MM-DD HH:MM:SS') from dual; -- 返回当前会话时间 并格式化
select add_months(sysdate,5) from dual; -- 返回当前时间加 5个月
select localtimestamp from dual; -- 返回当前会话时间,包括时分秒
begin
dbms_output.put_line(... |
CREATE OR REPLACE VIEW SCH_TRIGGER AS
SELECT
TRI.TRIGGER_CATALOG AS CATALOG_NAME
, TRI.TRIGGER_SCHEMA AS SCHEMA_NAME
, TRI.EVENT_OBJECT_TABLE
, TRI.TRIGGER_NAME
, TRI.ACTION_TIMING
, TRI.EVENT_MANIPULATION
, TRI.ACTION_ORIENTATION
, TRI.ACTION_STATEMEN... |
PRAGMA foreign_keys = ON;
create table time (
timestamp BIGINT not null,
packets INT not null,
PRIMARY KEY (timestamp)
);
create table macaddr (
mac BIGINT NOT NULL,
ssid VARCHAR(32),
PRIMARY KEY (mac)
);
create table timemac (
timestamp BIGINT not null,
mac BIGINT not null,
cou... |
-- phpMyAdmin SQL Dump
-- version 4.9.7
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Jul 03, 2021 at 07:03 PM
-- Server version: 5.7.32
-- PHP Version: 7.4.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIE... |
-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 24, 2018 at 10:25 AM
-- Server version: 10.1.29-MariaDB
-- PHP Version: 7.2.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD... |
SELECT
TOP 1 ADDRESS
FROM
CORRESPONDENCE_MST
WHERE
--取引先コード = パラメータ.取引先コード
CUSTOMER_CODE = /*customerCode*/
ORDER BY
CORRESPONDENCE_No |
-- AlterTable
ALTER TABLE `Users` ADD COLUMN `fb_name` VARCHAR(191) NOT NULL DEFAULT '';
|
/* *************************************************************************************** */
/* TASK 1. В базе данных shop и sample присутствуют одни и те же таблицы, учебной базы */
/* данных. Переместите запись id = 1 из таблицы shop.users в таблицу sample.users. */
/* Используйте транзакции. ... |
# Loans schema
# --- !Ups
CREATE TABLE loans (
id VARCHAR(255) NOT NULL,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
amount DECIMAL(16,4) NOT NULL,
term_days INTEGER NOT NULL,
timestamp TIMESTAMP NOT NULL,
client_ip VARCHAR(16) NOT NULL,
approved BOOLEAN NOT NULL... |
insert into avatars (avatar_base_type_id, level, skin, hair, picture_url, night_background_url, day_background_url, status, text_id, created_by, created_date)
values
(1, 1, 1, 3, 's1h3.png', '', '', 'ACTIVE', 1, 1, current_timestamp),
(1, 2, 1, 3, 's1h3.png', '', '', 'ACTIVE', 1, 1, current_timestamp),
(1, 3, 1, ... |
-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 20, 2017 at 07:45 PM
-- Server version: 5.7.17-0ubuntu0.16.04.1
-- PHP Version: 7.0.15-0ubuntu0.16.04.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_C... |
db.coffee.remove(
{
size: "grande"
}
);
db.coffee.remove({});
db.coffee.drop();
show collections;
db.dropDatabase(); |
USE agreeddb
INSERT INTO recommended VALUES (11431, "Jaws", 1, 1)
INSERT INTO recommended VALUES (11432, "Jaws 2", 1, 0)
INSERT INTO recommended VALUES (11433, "Jaws 3", 1, 1)
INSERT INTO recommended VALUES (11434, "Jaws Returns", 1, 0)
INSERT INTO recommended VALUES (11435, "Jaws The Revenge", 1, 0)
INSERT INT... |
-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 16, 2018 at 11:23 PM
-- Server version: 5.7.21-0ubuntu0.16.04.1
-- PHP Version: 7.0.28-0ubuntu0.16.04.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_C... |
INSERT INTO todo VALUES (null ,'todoInDbmigration-1', false, true, true, false, NOW(), 1);
INSERT INTO todo VALUES (null ,'todoInDbmigration-2', false, true, true, false, NOW(), 2);
INSERT INTO todo VALUES (null ,'todoInDbmigration-3', false, true, true, false, NOW(), 3); |
/********************
* Ver 1.2
* 2019/3/12
*******************/
CREATE DATABASE `fms` COLLATE 'utf8_general_ci' ;
USE fms;
CREATE TABLE `fms_app_auth` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`app_id` VARCHAR(50) NULL DEFAULT NULL,
`app_key` VARCHAR(50) NULL DEFAULT NULL,
`app_info` VARCHAR(50) NULL DEFAULT N... |
-- phpMyAdmin SQL Dump
-- version 5.0.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 26 Des 2020 pada 07.57
-- Versi server: 10.4.14-MariaDB
-- Versi PHP: 7.4.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@C... |
-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Anamakine: 127.0.0.1
-- Üretim Zamanı: 30 Tem 2021, 07:51:06
-- Sunucu sürümü: 10.4.20-MariaDB
-- PHP Sürümü: 8.0.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=... |
use master;
create database TMPSVV_UNIVER; |
-- Creates the table unique_id
-- Create a unique id
CREATE TABLE unique_id (id INT DEFAULT 1 UNIQUE, name VARCHAR(256));
|
--解約損害金情報
UPDATE END_AGREEMENT_WITHDRAW_INFO
SET
--発票印刷フラグ(元本)=印刷済
INVOICE_PRINTED_FLG = /*dto.invoicePrintKbnYes*/,
--単据番号(元本)=DTO.領収書番号
INVOICE_PRINCIPAL_PRINTED_NO = /*dto.invoicePrintedNo*/,
--新規者/更新者
MODIFY_USER = /*modifyUser*/,
--新規日付/更新日付
MODIFY_DATE = /*modifyDate*/
WHERE
--更新日時 <= パラメータ.日時
MODIFY_DA... |
WITH CTE_SALES_GROUP AS
(
SELECT
CTX.NU_CARTEIRA_VERSION,
MAX(CTX.CD_SALES_DISTRICT) CD_SALES_DISTRICT,
MAX(CTX.NO_SALES_DISTRICT) NO_SALES_DISTRICT,
MAX(CTX.CD_SALES_OFFICE) CD_SALES_OFFICE,
MAX(CTX.NO_SALES_OFFICE) NO_SALES_OFFICE,
CTX.CD_SALES_GROUP CD_SALES_GROUP,
MAX(CTX.NO_SALES_GROUP) NO_SALES_GROUP
FRO... |
--// Create_Link_table
-- Migration SQL that makes the change goes here.
create table Link (
id varchar(36) not null,
updatedOn bigint unsigned not null default 0,
createdOn bigint unsigned not null default 0,
echoedUserId varchar(36) not null,
partnerId varchar(36) not null,
partnerHandle varc... |
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
CREATE TABLE `esx_scrap` (
`id` int(11) NOT NULL,
`vehicle` varchar(64) NOT NULL,
`multiplier` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `esx_scrap` (`id`, `vehicle`, `multiplier... |
DROP TABLE IF EXISTS smth;
-- DROP TABLE CATEGORY
-- DROP TABLE CATEGORY_EVENTS
-- DROP TABLE EVENT
-- DROP TABLE EVENTS_USERS
-- DROP TABLE LOCATION
-- DROP TABLE USER |
ALTER TABLE `log_activity_emails`
MODIFY `created` datetime(6) NOT NULL,
MODIFY `modified` datetime(6) NOT NULL,
MODIFY `messageid` varchar(255) NOT NULL;
|
/**
* SQL for check exist batch warning in table BY_SHISETSU_NYUKO_ERROR
* @author TuyenVHA
* @version $Id: CommonShisetsuService_checkExistBatchWarning_Sel_01.sql 9253 2014-06-28 03:22:15Z p__toen $
*/
SELECT
COUNT(BSNE.NYUKO_ERROR_NO)
FROM
BY_SHISETSU_NYUKO_ERROR BSNE
WHERE
BSNE.SHISETSU_CD = /*shisetsuCd*/'... |
-- MySQL dump 10.13 Distrib 5.7.17, for
macos10.12 (x86_64)
--
-- Host: 47.101.183.63 Database: cinema
-- ------------------------------------------------------
-- Server version 5.7.24
/*!40101 SET
@OLD_CHARACTER_SET_CLIENT=@@CHA
RACTER_SET_CLIENT */;
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CH
... |
CREATE OR REPLACE VIEW DIALOG_STATUS AS (
SELECT
d.dialog_id,
aktor_id,
CASE WHEN lest_av_bruker_tid >= NVL(MAX(h.sendt), lest_av_bruker_tid) THEN 1 ELSE 0 END as lest_av_bruker,
CASE WHEN lest_av_veileder_tid >= NVL(MAX(h.sendt), lest_av_veileder_tid) THEN 1 ELSE 0 END as lest_av_veileder,
CASE ... |
-- phpMyAdmin SQL Dump
-- version 4.9.2
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1:3306
-- Généré le : mer. 23 déc. 2020 à 15:13
-- Version du serveur : 10.4.10-MariaDB
-- Version de PHP : 7.3.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*... |
ALTER TABLE Employee
ADD CONSTRAINT Employee_Superssn_FK
FOREIGN KEY(superssn)
REFERENCES Employee(SSN)
ON DELETE SET NULL;
|
ALTER TABLE `users_history` DROP INDEX `users_history_user_id_358ca354_fk_users_id`;
|
INSERT into math_expression (expression, result) VALUES ('(1+2)*3', 9.0);
|
CREATE PROC [ERP].[Usp_Sel_Cuenta]
@IdEmpresa INT
AS
BEGIN
SELECT C.ID,
C.Nombre,
E.ID IdEntidad,
ETD.NumeroDocumento,
B.ID IdBanco,
E.Nombre NombreBanco,
M.ID IdMoneda,
M.Nombre NombreMoneda,
IdTipoCuenta,
TC.Nombre NombreTipoCuenta,
C.IdPlanCuenta,
PC.CuentaContable,
ISNULL... |
-- this is joining tables and columns to have a small and concise table
select CONCAT(s.FirstName,' ', s.LastName) as 'Name', c.Description as 'Class'
from student s
join Schedule sc
on s.Id = sc.StudentId
join class c
on c.Id = sc.ClassId
where s.FirstName = 'Aaron'
and s.LastName = 'Zell' |
INSERT INTO [StaticModel].[Benefits] ([BenefitId], [Name], [ObjectDocument], [ObjectHash]) VALUES
(106109, 'Adventure Activities','{}', 0),
(106121, 'Business Class Cruise','{}', 0),
(106122, 'Business Class Cruise- Domestic','{}', 0),
(106103, 'Business equipment','{}', 0),
(106106, 'Cruise ','{}', 0),
(106112, 'Crui... |
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.0
-- Dumped by pg_dump version 10.0
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_m... |
CREATE TABLE IF NOT EXISTS `twitter_details` (
`iUserID` INT NOT NULL,
`cDescription` VARCHAR(255) DEFAULT NULL,
`iFollowers` SMALLINT DEFAULT 0,
`iFollowing` SMALLINT DEFAULT 0,
`cImage` TEXT DEFAULT NULL,
`cLocation` VARCHAR(80) DEFAULT NULL,
PRIMARY KEY (`iUserID`)
);
CREATE TABLE IF NOT EXISTS `twitter_twee... |
DELIMITER /
ALTER TABLE PERSON_SIGNATURE_MODULE
ADD CONSTRAINT FK_PERSON_SIGNATURE_ID
FOREIGN KEY (PERSON_SIGNATURE_ID)
REFERENCES PERSON_SIGNATURE (PERSON_SIGNATURE_ID)
/
DELIMITER ;
|
DROP DATABASE IF EXISTS `phalcon_sample`;
CREATE DATABASE `phalcon_sample`;
use `phalcon_sample`;
SET NAMES 'utf8';
CREATE TABLE `session` (
`session_id` varchar(35) NOT NULL,
`data` text NOT NULL,
`created_at` int(15) unsigned NOT NULL,
`modified_at` int(15) unsigned DEFAULT NULL,
PRIMARY KEY (`... |
DROP TABLE IF EXISTS USERS;
CREATE TABLE USERS(
userId varchar(12) NOT NULL ,
password varchar(12) NOT NULL ,
name varchar(20) NOT NULL ,
email varchar(50) ,
PRIMARY KEY (userId)
);
INSERT INTO USERS VALUES('nightbobo', 'nightbobo' , '보보형' , 'nightbobo@gmail.net'); |
use PHARMACY
create table discount(
id_discount int not null,
name_disc nvarchar(20) unique,
percent_discount int not null
constraint PK_discount primary key (id_discount)
)
create table [client-disc](
id_dis int not null,
id_client int not null,
date_start date,
date_end date,
constraint PK_c_d primary ... |
--Consultas
--La Vista de turnos, se utiliza para poder ver dia y horario de los turnos asignados, asi como paciente, especialidad
--y Medico que lo atendera. Tambien dice el Telefono por si hubiera que llamarlo para confirmar el turno, o modificarlo.
--Por ultimo tiene el campo activo para ver si el paciente es... |
delete from "PlanGroup";
/* Data for the 'public.PlanGroup' table (Records 1 - 3) */
INSERT INTO public."PlanGroup" ("PlanGroupID", "Name", "Description", "ParentID", "HasSameGlobalPaymentMethodForAllPlans")
VALUES (1, E'SCP Plans', NULL, NULL, False);
INSERT INTO public."PlanGroup" ("PlanGroupID", "Name", "Descri... |
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.4
-- Dumped by pg_dump version 10.4
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', fal... |
select ssn, lname, salary
from jmendoza.employee
where salary > (select avg(salary)
from jmendoza.employee)
and
dno in (select dno
from jmendoza.employee
where lower(lname) like '%n%')
|
CREATE TABLE users_new (
id SERIAL PRIMARY KEY,
username TEXT,
password varchar(40),
favNum integer,
price decimal,
class1 varchar(40),
degree varchar(40),
pie float,
name VARCHAR,
email VARCHAR
);
insert into users_new (
id,
username,
password,
favNum,
price,
class1,
degree,
pie,
... |
-- phpMyAdmin SQL Dump
-- version 4.3.1
-- http://www.phpmyadmin.net
--
-- Počítač: 127.0.0.1
-- Vytvořeno: Čtv 08. led 2015, 17:03
-- Verze serveru: 5.6.17
-- Verze PHP: 5.5.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!4010... |
insert into diet values(1, 1);
insert into diet values(1, 7);
insert into diet values(2, 2);
insert into diet values(2, 3);
insert into diet values(3, 2);
insert into diet values(3, 4);
insert into diet values(4, 2);
insert into diet values(4, 4);
insert into diet values(5, 2);
insert into diet values(5, 4);
insert int... |
CREATE TABLE IF NOT EXISTS product (
product_id INT NOT NULL AUTO_INCREMENT,
product_name VARCHAR(128) NULL,
unit_price DECIMAL(8,2) NULL,
PRIMARY KEY (product_id)
);
CREATE TABLE IF NOT EXISTS account (
account_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(128) NULL,
email_id VARCHAR(128) NULL,
... |
insert into tax_rate
values ('201',0.02);
insert into tax_rate
values ('202',0.03);
insert into tax_rate
values ('203',0.02);
insert into tax_rate
values ('204',0.03);
insert into tax_rate
values ('205',0.025);
insert into tax_rate
values ('206',0.02);
insert into tax_rate
values ('207',0.02);
insert into tax_rate
valu... |
drop table if exists Administers;
CREATE TABLE Administers (
timeAdministered datetime NOT NULL,
treatmentGiverID integer,
treatmentID integer,
patientID integer,
PRIMARY KEY (treatmentID, treatmentGiverID, patientID),
FOREIGN KEY (treatmentGiverID) REFERENCES TreatmentGiver(treatmentGiverID),
FO... |
SELECT
ACCOUNT_CODE,
ACCOUNT_NAME,
PARENTS_ACCOUNT_CODE,
ACCOUNT_CODE_LEVEL,
ACCOUNT_CODE_CURRENCY,
CUSTOMER_CODE,
AGENCY_CUST_CODE,
OWNER_ACCOUNT_NO,
SAP_COOPERATION_OBJ_FLG,
SAP_COOPERATION_STATUS,
MODIFY_USER,
MODIFY_DATE
F... |
-- Create tables for our ingredients and favorite recipes, plus the cache tables to save our results
CREATE TABLE IF NOT EXISTS favoriterecipes(
favoriterecipe_id VARCHAR(32) PRIMARY KEY,
title VARCHAR(256),
image_url VARCHAR(256),
directions_url VARCHAR(256),
source_title VARCHAR(256),
calo... |
CREATE EXTENSION get_sum;
SELECT get_sum(1::INT, 1::INT);
SELECT get_sum(101::INT, 202::INT);
SELECT get_sum(0::INT, 0::INT);
SELECT get_sum(-1::INT, 0::INT);
SELECT get_sum(-1::INT, -1::INT);
SELECT get_sum(-101::INT, -202::INT);
SELECT get_sum(NULL::INT, 11::INT);
SELECT get_sum(-1::INT, NULL::INT);
SELECT get_sum(0:... |
/* create advertiser login a*/
/*create table advertiser*/
CREATE TABLE advertiser
{
idadvertiser AUTO_INCREMENT int(11) ,
nameadv varchar(45) ,
email varchar(29) ,
phonenum varchar(45) ,
passw varchar(10),
CONSTRAINT pk_advertiser PRIMARY KEY(idadvertiser)
}
/* insert values to the table*/... |
/*
Navicat MySQL Data Transfer
Source Server : localhost_3306
Source Server Version : 50520
Source Host : localhost:3306
Source Database : truething
Target Server Type : MYSQL
Target Server Version : 50520
File Encoding : 65001
Date: 2016-07-06 17:51:31
*/
SET FOREIGN_KEY_CHECKS=0... |
--Query a list of CITY and STATE from the STATION table.
--The STATION table is described as follows: https://s3.amazonaws.com/hr-challenge-images/9336/1449345840-5f0a551030-Station.jpg
SELECT CITY, STATE
FROM STATION;
---------------------------------------------------------------------
--Query a list of CITY names f... |
CREATE TABLE sys_order
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`user_id` BIGINT NOT NULL COMMENT '用户id',
`amount` BIGINT NOT NULL COMMENT '金额,精确到后面2位',
`target_id` BIGINT NOT NULL COMMENT '订单目标id',
`type` TINYINT COMMENT '0:赞赏作品,1:赞赏文章,2:买作品',
`create_time` datetime DEF... |
use movimentacoes_cartoes;
----------------------------------------
-- carga tabela associado:
insert into associado (nome, sobrenome, idade, email)
values ('Marlos', 'Nascimento', 33, 'marlos.nascimento@sicooperative.com'),
('Ronaldo', 'Abreu', 22, 'ronaldo@abreu.com'),
('Maria', 'Madalena', 28, 'maria@madalena.com... |
--Requires PostGIS Extension!
SET search_path = acs2011_5yr, public; --Change target schema here if other than acs2011_5yr
CREATE SEQUENCE geoheader_gid_seq;
ALTER TABLE geoheader
ADD COLUMN geom geometry(MultiPolygon, 4269),
ADD COLUMN gid int NOT NULL DEFAULT nextval('geoheader_gid_seq');
CREATE INDEX ON geohea... |
-- show triggers;
-- drop trigger before_movie_insert_movieCertificate;
delimiter $$
create trigger before_movie_insert_movieRuntime before insert on movie
for each row
begin
if new.movieRuntime <= 25 then
signal sqlstate '42000'
set message_text = 'Check constraint on movieRuntime in table movie failed. Runtime t... |
-- --------------------------------------------------------
-- Servidor: 127.0.0.1
-- Versão do servidor: 5.5.62 - MySQL Community Server (GPL)
-- OS do Servidor: Win64
-- HeidiSQL Versão: 11.0.0.5919
-- ------------------------------------------------------... |
-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 27, 2019 at 05:49 PM
-- Server version: 5.7.25-0ubuntu0.16.04.2
-- PHP Version: 7.0.33-0ubuntu0.16.04.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD... |
DROP TABLE V_VIK_PRODUCT_GROUP;
CREATE TABLE V_VIK_PRODUCT_GROUP
(
ID NUMBER(10) ,
CP_CATEGORY VARCHAR2( CHAR) ,
PRODUCT_TYPE NUMBER(10) DEFAULT 0 NOT NULL,
GROUP_NAME NUMBER(10) DEFAULT 0 NOT NULL,
CP_CATEGORY_ID NUMBER(10) ,
IS_ACTIVE NUMBER(1) DEFAULT 0 NOT NULL,
CONSTRA... |
--
-- Simple bank database
--
set termout on
prompt Building small bank database. Please wait ...
set termout off
set feedback off
-- Remove old instances of database
drop table Branches;
drop table Customers;
drop table Accounts;
-- Create Accounts, Branches, Customers tables
create table Branches (
location va... |
create or replace view fmv_bompvtuptodown as
select
s.sel_cle Key
,p.pvt_em_addr fromID
,p.pvt_cle fromName
--,f.f_cle
--,f.f_desc
,n.nmc_field
,n.fils_pro_nmc famID
,p.geo5_em_addr geoID
,p.dis6_em_addr disID
,p1.pvt_em_addr ToID
,case when p1.pvt_cle is null then
REPLACE(p.pvt_cle,f.f_cle,f1.f_cle)
else
p1.pvt_cle... |
SELECT DepositGroup , MagicWandCreator, MIN (DepositCharge) AS MinDepositCharge
FROM WizzardDeposits
GROUP BY DepositGroup , MagicWandCreator
ORDER BY MagicWandCreator ,DepositGroup |
CREATE TABLE account (
id BIGSERIAL NOT NULL,
version BIGINT,
created TIMESTAMP WITH TIME ZONE,
modified TIMESTAMP WITH TIME ZONE,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
CONSTRAINT pk_account PRIMARY KEY (id),
CONSTRAINT unique_username UNIQUE(use... |
-- Plan count should match the number of tests. If it does
-- not then pg_prove will fail the test
SELECT plan(7);
-- Run the tests.
-- Columns
SELECT columns_are('problem', ARRAY[ 'problemid', 'input', 'output', 'name', 'description']);
SELECT col_type_is('problem', 'input', 'text', 'input column type is -- text' );... |
--@drop_schema_tables.sql;
purge recyclebin;
CREATE TABLE Department(
did VARCHAR2(20),
Major VARCHAR2(20),
PRIMARY KEY (did),
constraint Major_notNull
check (Major != NULL)
);
CREATE TABLE Student(
sid VARCHAR2(20),
firstname VARCHAR2(20),
lastname VARCHAR2(20),
dob DATE,
gp... |
-- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 13 Sep 2019 pada 10.56
-- Versi server: 10.1.37-MariaDB
-- Versi PHP: 7.3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARA... |
-- Adminer 4.7.5 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
SET NAMES utf8mb4;
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`username` varchar(50) NOT NULL,
`password` varchar(100) NOT NULL,
`user_type` varchar(100) NOT NULL,... |
###################
# INVALID OBJECTS #
###################
-- find a user's invalid objects
select object_name, object_type, status from user_objects where status != 'VALID';
-- find all invalid objects
set lines 120 pagesize 100
col owner format a20
col object_name format a25
select owner, object_name, o... |
SELECT
date,
p.id as player_id,
name,
case
when plans=0 then '×'
when plans=1 then '△'
when plans=2 then '○'
end as plans,
sc_password,
te.team_id as team_id,
team_name,
mst_id
FROM m_schedule m
LEFT OUTER JOIN t_schedule t ON m.id=t.mst_id
LEFT OUTER JOIN player p ON p.id=t.player_id
LEFT OUTER JOIN team ... |
-- drop table account;
create table account (
sno int NOT NULL AUTO_INCREMENT,
userid varchar(50) NOT NULL,
password varchar(20) NOT NULL,
PRIMARY KEY(sno)
);
insert into account (userid, password) values('admin', 'admin');
-- drop table records;
create table records (
id int NOT NULL AUTO_INCREMENT,
members int NO... |
SELECT *
FROM tb_ComprobanteCompra
WHERE ComprobanteID IN ("01","02","07","08") |
SELECT id, name, split_part( characteristics, ',' , 1 ) as characteristic
FROM monsters
ORDER BY id; |
set serveroutput on;
execute insertarmesas('RA01');
execute insertarmesas('RA02');
execute insertarmesas('RA03');
|
-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 15, 2020 at 03:49 AM
-- Server version: 10.4.6-MariaDB
-- PHP Version: 7.3.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.