blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 3 276 | src_encoding stringclasses 33
values | length_bytes int64 23 9.61M | score float64 2.52 5.28 | int_score int64 3 5 | detected_licenses listlengths 0 44 | license_type stringclasses 2
values | text stringlengths 23 9.43M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
0c55f7e160b7f3bc81f0d952b348c1368486e749 | SQL | youstinus/volunteer | /utilities/Volunteer database model/Untitled (2).sql | UTF-8 | 1,407 | 3.46875 | 3 | [
"MIT",
"Intel"
] | permissive | CREATE TABLE `orders`
(
`id` int,
`user_id` int,
`status` varchar(255),
`created_at` varchar(255)
);
CREATE TABLE `order_items`
(
`order_id` int,
`product_id` int,
`quantity` int
);
CREATE TABLE `orderMore`
(
`id` int
);
CREATE TABLE `products`
(
`id` int,
`name` varchar(255),
`merchant_id` int,
`price` int,
`status` varchar(255),
`created_at` varchar(255)
);
CREATE TABLE `users`
(
`id` int,
`full_name` varchar(255),
`email` varchar(255),
`gender` varchar(255),
`date_of_birth` varchar(255),
`created_at` varchar(255),
`country_code` int
);
CREATE TABLE `merchants`
(
`id` int,
`merchant_name` varchar(255),
`country_code` int,
`created_at` varchar(255),
`admin_id` int
);
CREATE TABLE `countries`
(
`code` int,
`name` varchar(255),
`continent_name` varchar(255)
);
ALTER TABLE `orders` ADD FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);
ALTER TABLE `order_items` ADD FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`);
ALTER TABLE `order_items` ADD FOREIGN KEY (`product_id`) REFERENCES `products` (`id`);
ALTER TABLE `products` ADD FOREIGN KEY (`merchant_id`) REFERENCES `merchants` (`id`);
ALTER TABLE `users` ADD FOREIGN KEY (`country_code`) REFERENCES `countries` (`code`);
ALTER TABLE `merchants` ADD FOREIGN KEY (`admin_id`) REFERENCES `users` (`id`);
ALTER TABLE `merchants` ADD FOREIGN KEY (`country_code`) REFERENCES `countries` (`code`);
| true |
db31912244721114dee345360c91774b89ecc50f | SQL | BahaStriker/EPIcommerce | /BD.sql | UTF-8 | 3,011 | 3.25 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : EPI
Source Server Version : 50554
Source Host : 173.212.208.17:3306
Source Database : market
Target Server Type : MYSQL
Target Server Version : 50554
File Encoding : 65001
Date: 2017-03-12 07:01:18
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for category
-- ----------------------------
DROP TABLE IF EXISTS `category`;
CREATE TABLE `category` (
`refcat` varchar(11) NOT NULL,
`name` text NOT NULL,
`type` enum('Girl','Boy','Child','Women','Men') NOT NULL,
KEY `refcat` (`refcat`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for contenu
-- ----------------------------
DROP TABLE IF EXISTS `contenu`;
CREATE TABLE `contenu` (
`Title` varchar(255) DEFAULT NULL,
`contenu` varchar(255) DEFAULT NULL,
`writer` varchar(255) DEFAULT NULL,
`img` varchar(255) DEFAULT NULL,
`Time_uplo` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for history
-- ----------------------------
DROP TABLE IF EXISTS `history`;
CREATE TABLE `history` (
`ProductId` varchar(11) NOT NULL,
`BuyDate` datetime NOT NULL,
KEY `ProductId` (`ProductId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for product
-- ----------------------------
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
`ProductId` varchar(11) NOT NULL,
`Name` text NOT NULL,
`Prix` decimal(10,0) NOT NULL,
`Ref` varchar(20) NOT NULL,
`Quant` int(11) NOT NULL,
`Img` varchar(100) NOT NULL,
`Description` varchar(100) NOT NULL,
PRIMARY KEY (`ProductId`),
KEY `Ref` (`Ref`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for sharticle
-- ----------------------------
DROP TABLE IF EXISTS `sharticle`;
CREATE TABLE `sharticle` (
`Titres` varchar(255) DEFAULT NULL,
`Class` varchar(255) DEFAULT NULL,
`Designer` varchar(255) DEFAULT NULL,
`imgs` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(64) NOT NULL,
`password` varchar(255) NOT NULL,
`name` varchar(20) DEFAULT NULL,
`lastname` varchar(35) DEFAULT NULL,
`email` varchar(50) NOT NULL,
`address` varchar(255) DEFAULT NULL,
`country` varchar(255) DEFAULT NULL,
`city` varchar(255) DEFAULT NULL,
`state` varchar(255) DEFAULT NULL,
`zip` varchar(255) DEFAULT NULL,
`birthdate` date DEFAULT NULL,
`role` enum('member','seller','admin') NOT NULL DEFAULT 'member',
`ip` varchar(255) NOT NULL,
`banned` int(11) NOT NULL DEFAULT '0',
`interest` varchar(255) DEFAULT NULL,
`sexe` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
| true |
40b6045a3ae5fb277cb130b5c21242b0647b253e | SQL | wyycode/coupon | /src/main/resources/sql/createTable.sql | UTF-8 | 1,754 | 2.765625 | 3 | [] | no_license | CREATE TABLE `coupon` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`itemId` varchar(255) DEFAULT NULL COMMENT '商品id',
`itemName` varchar(255) DEFAULT NULL COMMENT '商品名称',
`pic` varchar(512) DEFAULT NULL COMMENT '商品主图',
`detail` varchar(512) DEFAULT NULL COMMENT '商品详情页链接地址',
`topClass` varchar(255) DEFAULT NULL COMMENT '商品一级类目',
`tbkUrl` varchar(512) DEFAULT NULL COMMENT '淘宝客链接',
`price` int(11) DEFAULT NULL COMMENT '商品价格(单位:分)',
`saleCount` int(11) DEFAULT NULL COMMENT '商品月销量',
`rate` int(11) DEFAULT NULL COMMENT '收入比率(%)',
`income` int(11) DEFAULT NULL COMMENT '佣金',
`ww` varchar(255) DEFAULT NULL COMMENT '卖家旺旺',
`wwid` varchar(255) DEFAULT NULL COMMENT '卖家id',
`store` varchar(255) DEFAULT NULL COMMENT '店铺名称',
`platform` varchar(255) DEFAULT NULL COMMENT '平台类型',
`couponId` varchar(255) DEFAULT NULL COMMENT '优惠券id',
`couponCount` int(11) DEFAULT NULL COMMENT '优惠券总量',
`leftCount` int(11) DEFAULT NULL COMMENT '优惠券剩余量',
`couponPrice` varchar(255) DEFAULT NULL COMMENT '优惠券面额',
`startDate` varchar(255) DEFAULT NULL COMMENT '优惠券开始时间',
`endDate` varchar(255) DEFAULT NULL COMMENT '优惠券结束时间',
`couponUrl` varchar(512) DEFAULT NULL COMMENT '优惠券链接',
`uurl` varchar(512) DEFAULT NULL COMMENT '商品优惠券推广链接',
`state` int(11) DEFAULT NULL COMMENT '状态',
`kouling` varchar(255) DEFAULT NULL COMMENT '淘口令',
`batchNo` varchar(255) DEFAULT NULL COMMENT '文件批次',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8mb4 COMMENT='优惠券'; | true |
70acd697e3dd2db9aa51edc5540cba01fa4eafd0 | SQL | ahueteg/Datamart-MKT | /Lab SQL/INKA/inka.sql | ISO-8859-10 | 3,186 | 3.453125 | 3 | [] | no_license |
insert into [mkt].[sellout_inka]
SELECT * FROM [mkt].[sellout_inka_2014]
SELECT * into [mkt].[stock_inkax] FROM [mkt].[stock_inka]
insert into [mkt].[stock_inka]
SELECT * FROM [mkt].[stock_inka_2014]
DROP TABLE [mkt].[sellout_inka_2014]
DROP TABLE [mkt].[stock_inka_2014]
SELECT * FROM [mkt].[sellout_inka]
DROP TABLE mkt.SELLOUT_IK_HISTW
SELECT CONCAT(SUBSTRING([PERIODO],1,4),SUBSTRING(PERIODO,6,2),SUBSTRING(PERIODO,9,2)) Fecha
,[COD_PRODUCTO]
,[COD_PRODUCTO_PROVEEDOR]
,[DESCRIPCION]
,[MARCA]
,[ESTADO_PROD]
,[UMB]
,[COD_LOCAL]
,[COD_LOCAL_PROVEEDOR]
,[DESCRIPCION_LOCAL]
,[ESTADO_LOCAL]
,[FORMATO]
,[TIPO]
,[VTA_PERIODO_UNID]
,[COSTO_DE_VENTA_PERIODO_S]
into mkt.SELLOUT_IK_HISTW
FROM [genomma].[mkt].[sellout_inka]
DROP TABLE MKT.so_ik_1 ;
SELECT * INTO MKT.so_ik_1 FROM mkt.SELLOUT_IK_HISTW
WHERE COD_PRODUCTO<>'108244'
DROP TABLE MKT.so_ik_2;
SELECT
A.Fecha,
A.COD_PRODUCTO,
A.COD_LOCAL,
SUM(A.VTA_PERIODO_UNID) VTA_PERIODO_UNID,
SUM(A.COSTO_DE_VENTA_PERIODO_S) COSTO_DE_VENTA_PERIODO_S
INTO MKT.so_ik_2
FROM MKT.so_ik_1 A
GROUP BY Fecha,COD_PRODUCTO,COD_LOCAL
/* check producto*/
insert into per.MAESTRO_PRODUCTO_FUENTE
SELECT
COD_PRODUCTO,
'309' GRPID,
'0000' PROPSTID
FROM
(
SELECT DISTINCT COD_PRODUCTO FROM MKT.so_ik_2 a
LEFT JOIN [per].MAESTRO_PRODUCTO_FUENTE B
ON A.COD_PRODUCTO=B.PROIDCLIE AND B.GrpID='309'
WHERE B.PROPSTID IS NULL
) A;
/* check TIEMPO*/
/* check pdv*/
insert into [per].maestro_pdv
SELECT
NEXT VALUE FOR per.seq_PDVid OVER(ORDER BY [COD_LOCAL]),
[COD_LOCAL],
[COD_LOCAL],
[COD_LOCAL],
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
'309'
FROM
(
SELECT DISTINCT [COD_LOCAL] FROM MKT.so_ik_2 A
LEFT JOIN [per].maestro_pdv PD
ON [COD_LOCAL]=PD.PdvIDClie
WHERE PDVID IS NULL
) A;
SELECT * FROM per.MAESTRO_PDV
/*CHECK PRECIO*/
insert into [per].MAESTRO_PRODUCTO_PRECIO
SELECT
NEXT VALUE FOR [per].[seq_precioid] OVER(ORDER BY [GrpID],[ProPstID],AoSemana_GL),
A.*
FROM
(
SELECT
'309' GRPID,PROPSTID,AoSemana_GL,0 PRECIO FROM
(
SELECT Q.PROPSTID,Q.AoSemana_GL FROM
(
SELECT DISTINCT B.PROPSTID,T.AoSemana_GL FROM
mkt.so_ik_2 A
LEFT JOIN per.MAESTRO_PRODUCTO_FUENTE B
ON A.COD_PRODUCTO=B.PROIDCLIE
LEFT JOIN per.MAESTRO_TIEMPO T
ON A.FECHA=T.Fecha
) Q LEFT JOIN per.MAESTRO_PRODUCTO_PRECIO H
ON H.GrpID='309' AND H.AOSEMANA_GL=Q.AoSemana_GL AND H.ProPstID=Q.PROPSTID
WHERE H.PrecioLista IS NULL
) P
) A;
DROP TABLE per.SELLOUT_IK;
SELECT
A.Fecha,
NULL [CadenaID],
NULL [OficinaID],
NULL [GrupoTratID],
NULL [VendedorID],
G.ProPstID,
PD.PdvID,
H.PrecioID,
A.VTA_PERIODO_UNID UnidDesp,
A.COSTO_DE_VENTA_PERIODO_S MontoDespCliente,
A.VTA_PERIODO_UNID*H.PRECIOLISTA MontoDesp,
T.AoSemana_GL
into per.SELLOUT_IK
FROM [mkt].so_ik_2 A
LEFT JOIN per.maestro_producto_fuente G
ON G.[GrpID]='309' AND A.COD_PRODUCTO=G.PROIDCLIE
LEFT JOIN per.maestro_pdv PD
ON A.COD_LOCAL=PD.PdvIDClie AND PD.GrpID='309'
LEFT JOIN per.[maestro_tiempo] T
ON A.Fecha=T.Fecha
LEFT JOIN per.[maestro_producto_precio] H
ON H.GrpID='309' AND H.AOSEMANA_GL=T.AoSemana_GL AND H.ProPstID=G.PROPSTID
SELECT * FROM per.SELLOUT_IK
| true |
d790115bc83b9fcb00444e6c41b707d55d842940 | SQL | FDI-IT/fd | /one_off/342-rename_ingredient_constraints.sql | UTF-8 | 957 | 3.171875 | 3 | [] | no_license | ALTER TABLE "Raw Materials" RENAME TO "access_ingredient";
ALTER TABLE access_ingredient ADD CONSTRAINT "access_ingredient_ProductID_check" CHECK ("ProductID" >= 0);
ALTER TABLE access_ingredient DROP CONSTRAINT "Raw Materials_ProductID_check";
ALTER TABLE access_ingredient ADD CONSTRAINT "access_ingredient_RawMaterialCode_check" CHECK ("RawMaterialCode" >= 0);
ALTER TABLE access_ingredient DROP CONSTRAINT "Raw Materials_RawMaterialCode_check";
ALTER TABLE access_ingredient ADD CONSTRAINT "access_ingredient_SupplierID_check" CHECK ("SupplierID" >= 0);
ALTER TABLE access_ingredient DROP CONSTRAINT "Raw Materials_SupplierID_check";
ALTER INDEX "Raw Materials_pkey" RENAME TO "access_ingredient_pkey";
ALTER TABLE access_ingredient ADD CONSTRAINT "access_ingredient_sub_flavor_id_fkey" FOREIGN KEY (sub_flavor_id) REFERENCES access_integratedproduct(id) DEFERRABLE;
ALTER TABLE access_ingredient DROP CONSTRAINT "Raw Materials_sub_flavor_id_fkey"; | true |
6920b54378d02eb85c1938e993f322459ff1698f | SQL | manuelcasas12/ipm2122-server | /db/create_tables.sql | UTF-8 | 991 | 3.4375 | 3 | [] | no_license | SET client_encoding = 'UTF8';
CREATE EXTENSION "uuid-ossp";
CREATE TABLE users (
uuid TEXT PRIMARY KEY DEFAULT uuid_generate_v4(),
username text NOT NULL,
password text NOT NULL,
name text NOT NULL,
surname text NOT NULL,
email text NOT NULL,
is_vaccinated boolean NOT NULL,
phone text
);
CREATE TABLE facilities (
id serial PRIMARY KEY,
name text NOT NULL,
address text NOT NULL,
max_capacity integer NOT NULL,
percentage_capacity_allowed integer NOT NULL
);
CREATE TABLE access_log (
facility_id integer NOT NULL,
user_id text NOT NULL,
type text NOT NULL,
timestamp timestamp with time zone NOT NULL,
temperature text NOT NULL,
CONSTRAINT access_log_pk PRIMARY KEY (facility_id, user_id, type, timestamp),
CONSTRAINT access_log_fk1 FOREIGN KEY (facility_id) REFERENCES facilities(id) ON DELETE CASCADE,
CONSTRAINT access_log_fk2 FOREIGN KEY (user_id) REFERENCES users(uuid) ON DELETE CASCADE
);
| true |
42f6d204667b42c8fa51dc4d6c7104aebc3c22b5 | SQL | clemiblac/sql-challenge | /EmployeeSQL/Create_Tables_Scripts.sql | UTF-8 | 1,533 | 3.703125 | 4 | [] | no_license | DROP TABLE IF EXISTS titles CASCADE;
CREATE TABLE titles (
title_id varchar(10) NOT NULL PRIMARY KEY,
title varchar(50) NOT NULL
);
------------------------------------------------------------------
DROP TABLE IF EXISTS employees CASCADE;
CREATE TABLE employees (
emp_no int NOT NULL PRIMARY KEY,
emp_title varchar(10) NOT NULL REFERENCES titles(title_id),
birth_date date NOT NULL,
first_name varchar(50) NOT NULL,
last_name varchar(50) NOT NULL,
sex char(1) NOT NULL,
hire_date date NOT NULL
);
----------------------------------------------------------------------
DROP TABLE IF EXISTS salaries CASCADE;
CREATE TABLE salaries (
emp_no int NOT NULL REFERENCES employees(emp_no),
salary money NOT NULL
);
-----------------------------------------------------------------------
DROP TABLE IF EXISTS departments CASCADE;
CREATE TABLE departments (
dept_no varchar(20) NOT NULL PRIMARY KEY,
dept_name varchar(50) NOT NULL
);
------------------------------------------------------------------------
DROP TABLE IF EXISTS dept_emp CASCADE;
CREATE TABLE dept_emp (
emp_no int NOT NULL REFERENCES employees(emp_no),
dept_no varchar(20) NOT NULL REFERENCES departments(dept_no)
);
------------------------------------------------------------------------
DROP TABLE IF EXISTS dept_manager CASCADE;
CREATE TABLE dept_manager (
dept_no varchar(20) NOT NULL REFERENCES departments(dept_no),
emp_no int NOT NULL REFERENCES employees(emp_no)
);
| true |
c6bfbd96a848050c52e41f8e3a5ee586bd57770e | SQL | qwat/qwat-data-model | /value_lists/vl_pressurecontrol_type.sql | UTF-8 | 1,769 | 3.109375 | 3 | [] | no_license | /*
qWat - QGIS Water Module
SQL file :: installation pressure control auxiliary tables
*/
/* CREATE */
CREATE TABLE qwat_vl.pressurecontrol_type () INHERITS ( qwat_vl.value_list_base);
ALTER TABLE qwat_vl.pressurecontrol_type ADD CONSTRAINT vl_pressurecontrol_type_pk PRIMARY KEY (id);
/* VALUES */
INSERT INTO qwat_vl.pressurecontrol_type (id, value_en, value_fr, value_ro ) VALUES (101, 'other', 'autre', 'altul');
INSERT INTO qwat_vl.pressurecontrol_type (id, value_en, value_fr, value_ro ) VALUES (102, 'unknown', 'inconnu', 'necunoscut');
INSERT INTO qwat_vl.pressurecontrol_type (id, value_en, value_fr, value_ro ) VALUES (103, 'to be determined', 'à déterminer', 'de determinat');
INSERT INTO qwat_vl.pressurecontrol_type (id,value_en,value_fr,value_ro) VALUES (2801,'reducer' ,'réducteur' ,'reductor');
INSERT INTO qwat_vl.pressurecontrol_type (id,value_en,value_fr,value_ro) VALUES (2802,'pressure cut','coupe-pression','tăiere presiune');
INSERT INTO qwat_vl.pressurecontrol_type (id,value_en,value_fr,value_ro) VALUES (2803,'gathering' ,'rassemblement' ,'colectare/captare');
/* SIA405 codes */
UPDATE qwat_vl.pressurecontrol_type SET sia405code = 'Schacht.unbekannt' WHERE value_fr = 'autre';
UPDATE qwat_vl.pressurecontrol_type SET sia405code = 'Schacht.unbekannt' WHERE value_fr = 'inconnu';
UPDATE qwat_vl.pressurecontrol_type SET sia405code = 'Schacht.unbekannt' WHERE value_fr = 'à déterminer';
UPDATE qwat_vl.pressurecontrol_type SET sia405code = 'Schacht.Druckbrecher' WHERE value_en = 'reducer';
UPDATE qwat_vl.pressurecontrol_type SET sia405code = 'Schacht.Druckbrecher' WHERE value_en = 'pressure cut';
UPDATE qwat_vl.pressurecontrol_type SET sia405code = 'Schacht.Sammel_Spezialschacht' WHERE value_en = 'gathering';
| true |
9692ba657c505b266b6c6f421c74001634b2db82 | SQL | temistocle1998/samane-oauth2 | /oauth_samane.sql | UTF-8 | 9,693 | 2.671875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.6deb5ubuntu0.5
-- https://www.phpmyadmin.net/
--
-- Client : localhost:3306
-- Généré le : Dim 06 Juin 2021 à 15:50
-- Version du serveur : 5.7.34-0ubuntu0.18.04.1
-- Version de PHP : 7.2.24-0ubuntu0.18.04.7
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 */;
--
-- Base de données : `oauth_samane`
--
-- --------------------------------------------------------
--
-- Structure de la table `oauth_access_tokens`
--
CREATE TABLE `oauth_access_tokens` (
`id` int(11) NOT NULL,
`token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`expires` datetime NOT NULL,
`scope` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`client_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `oauth_access_tokens`
--
INSERT INTO `oauth_access_tokens` (`id`, `token`, `expires`, `scope`, `client_id`, `user_id`) VALUES
(102, '2c9db4ed7b6c009bedd49d6641948c387c572238', '2021-06-02 20:19:29', NULL, 1, 1),
(103, '2e3a486cba01bb9dcafc91165fae0f0806971b49', '2021-06-02 20:24:18', NULL, 1, 1),
(104, '80a18067024837523e6b1cb9befbc619a730bfad', '2021-06-02 20:24:34', NULL, 1, 2),
(105, '4f0efeff74b949d98b652a05eaccbf5589c16939', '2021-06-02 23:48:37', NULL, 1, 1),
(106, '2eb03e8ece6431ae5b12dcb4c679ac335c36d189', '2021-06-02 23:50:28', NULL, 1, 1),
(107, '0ebe644544dcd52892ad34851cc099053b927efb', '2021-06-03 00:42:52', NULL, 1, 1),
(108, '5b8f3406fbd6ddce10bb12166dffd3fbdbfb0fc7', '2021-06-03 00:43:00', NULL, 1, 1),
(109, '97d3c6c63e822813648a1e519e42fce7b4e59952', '2021-06-03 00:43:32', NULL, 1, 1),
(110, '88eb7514416870c4fd187a980702c7835c563561', '2021-06-03 00:43:54', NULL, 1, 1),
(111, '517c9a0b304e49bff29d3a895ad4757c5fa512b8', '2021-06-03 01:39:55', NULL, 1, 2),
(112, '5caf8f4c45085594f2773829e22f76b34f271285', '2021-06-05 10:00:46', NULL, 1, 2),
(113, '307c8f826c75e0dc46e59d2dfc94f3afe1dfd49c', '2021-06-06 16:16:31', NULL, 1, 2),
(114, 'd1e9c29e29040d7e30f14639080567a14cad5f9e', '2021-06-06 16:17:21', NULL, 1, 2),
(115, 'ad46aa7c9740503c8075258c3c7fd4e06ae790f7', '2021-06-06 16:36:54', NULL, 1, NULL),
(116, '03366ba0e40ad1bd49643de4a22e9681b230a8a6', '2021-06-06 16:37:34', NULL, 1, NULL);
-- --------------------------------------------------------
--
-- Structure de la table `oauth_authorization_codes`
--
CREATE TABLE `oauth_authorization_codes` (
`id` int(11) NOT NULL,
`client_id` int(11) DEFAULT NULL,
`code` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`user_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`expires` datetime NOT NULL,
`redirect_uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`scope` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Structure de la table `oauth_clients`
--
CREATE TABLE `oauth_clients` (
`id` int(11) NOT NULL,
`client_identifier` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`client_secret` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`redirect_uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `oauth_clients`
--
INSERT INTO `oauth_clients` (`id`, `client_identifier`, `client_secret`, `redirect_uri`) VALUES
(1, 'testclient', '$2y$10$0lcppVLiLQdIhVC3phbRWOgZ7p2iGa2ubO6ipIJXqq9C4OZ0NsipC', 'http://fake/');
-- --------------------------------------------------------
--
-- Structure de la table `oauth_refresh_tokens`
--
CREATE TABLE `oauth_refresh_tokens` (
`id` int(11) NOT NULL,
`refresh_token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`client_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`expires` datetime NOT NULL,
`scope` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `oauth_refresh_tokens`
--
INSERT INTO `oauth_refresh_tokens` (`id`, `refresh_token`, `client_id`, `user_id`, `expires`, `scope`) VALUES
(95, 'fed12b733ad20c23f90e25a4090b655e4158f66c', 1, 1, '2021-06-02 19:24:48', NULL),
(96, 'c7b3e844ee640843d9fde0439d0f3799f66f0957', 1, 2, '2021-06-02 19:25:05', NULL),
(97, '1cc4ba8f5c73ad57bc7d2b26178716d98973d7ef', 1, 1, '2021-06-02 22:49:07', NULL),
(98, 'fbc8263c21f54858ce5cffa879ca3d7636bc18e9', 1, 1, '2021-06-02 22:50:58', NULL),
(99, '4f52147733acf15c9da718845bcd2a92df9f0af8', 1, 1, '2021-06-02 23:43:22', NULL),
(100, 'ba5fd39e50e2cca6642d599af1e31b66753a1f1e', 1, 1, '2021-06-02 23:43:30', NULL),
(101, 'e7dab831ee10af14383ad450470911c4a076fa26', 1, 1, '2021-06-02 23:44:02', NULL),
(102, '7dbcd8cd8c70c4463f23ac42fd19773c2ecc5a28', 1, 1, '2021-06-02 23:44:24', NULL),
(103, '30bb5cc0b19e2c2d6ff038b561c908fc682a8c6e', 1, 2, '2021-06-03 00:40:26', NULL),
(104, '32b12f7f0eebb62f9dc435fe5df51d9cf2b6d55a', 1, 2, '2021-06-05 09:01:16', NULL),
(105, '39ba404fb931059cdf07f955657f55908a3a24e9', NULL, 2, '2021-06-19 14:59:47', NULL),
(106, 'ffbd8858a1f95b22fdb0d541dfb2e698d862ae2c', NULL, 2, '2021-06-19 15:02:12', NULL),
(107, '3fa37bf0dd56f8ac5121513dcac777fc8666287d', NULL, 1, '2021-06-19 15:25:16', NULL),
(108, '2823c1ccc95d82b810927333676de44754897f50', NULL, 2, '2021-06-19 17:35:54', NULL),
(109, '12cec0399b5e8177adf57e46e378dc91f464b261', NULL, 2, '2021-06-19 18:29:00', NULL),
(110, 'dc4ba03e86f0f241a3132e62eeecfed3b671f589', NULL, 2, '2021-06-19 18:37:47', NULL),
(111, 'c5dfd99db331cb0414d4ed2a07905ccc1e78dd67', NULL, 2, '2021-06-19 18:46:31', NULL),
(112, '9dfce8b6c3f9b3ffe70fe8224e922390035854e7', NULL, 2, '2021-06-20 14:15:43', NULL),
(113, 'c8532301663c49371120b79b3ee2de27ac19908c', 1, 2, '2021-06-20 14:19:49', NULL),
(114, '35e392adc1a97d19927a67e3886d11b16d8e1323', 1, 2, '2021-06-20 15:16:22', NULL),
(115, '70fe647085fa5bde59d7a37260354e92255b37e9', 1, 2, '2021-06-06 15:17:01', NULL),
(116, '3f2757335ac853b6a8fe2ac398c27a132f110f32', 1, 2, '2021-06-06 15:17:51', NULL),
(117, '3014151aa536cdae48ad741c6d760b5d6c3ecd2a', 1, 2, '2021-06-20 15:17:26', NULL),
(118, '919ce039d63bb0a47ce0cb1fcdf979eeb17a6f1f', 1, 2, '2021-06-20 15:39:02', NULL),
(119, '2e1ff2388eda27d0375951dbe3553bd2c82a5260', 1, 2, '2021-06-20 15:39:09', NULL);
-- --------------------------------------------------------
--
-- Structure de la table `oauth_users`
--
CREATE TABLE `oauth_users` (
`id` int(11) NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `oauth_users`
--
INSERT INTO `oauth_users` (`id`, `email`, `password`, `username`) VALUES
(1, 'laminebeye007@gmail.com', '$2y$11$LDyDdklBDi7VaeN.oD40SONa8rpP3lFrYXv03Exc1QgqL9Lm8a/2.', 'yorobo'),
(2, 'temistocle@gmail.sn', '$2y$11$LDyDdklBDi7VaeN.oD40SONa8rpP3lFrYXv03Exc1QgqL9Lm8a/2.', 'ngor');
--
-- Index pour les tables exportées
--
--
-- Index pour la table `oauth_access_tokens`
--
ALTER TABLE `oauth_access_tokens`
ADD PRIMARY KEY (`id`),
ADD KEY `IDX_CA42527C19EB6921` (`client_id`),
ADD KEY `IDX_CA42527CA76ED395` (`user_id`);
--
-- Index pour la table `oauth_authorization_codes`
--
ALTER TABLE `oauth_authorization_codes`
ADD PRIMARY KEY (`id`),
ADD KEY `IDX_98A471C419EB6921` (`client_id`);
--
-- Index pour la table `oauth_clients`
--
ALTER TABLE `oauth_clients`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `oauth_refresh_tokens`
--
ALTER TABLE `oauth_refresh_tokens`
ADD PRIMARY KEY (`id`),
ADD KEY `IDX_5AB68719EB6921` (`client_id`),
ADD KEY `IDX_5AB687A76ED395` (`user_id`);
--
-- Index pour la table `oauth_users`
--
ALTER TABLE `oauth_users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT pour les tables exportées
--
--
-- AUTO_INCREMENT pour la table `oauth_access_tokens`
--
ALTER TABLE `oauth_access_tokens`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=117;
--
-- AUTO_INCREMENT pour la table `oauth_authorization_codes`
--
ALTER TABLE `oauth_authorization_codes`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `oauth_clients`
--
ALTER TABLE `oauth_clients`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT pour la table `oauth_refresh_tokens`
--
ALTER TABLE `oauth_refresh_tokens`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=120;
--
-- AUTO_INCREMENT pour la table `oauth_users`
--
ALTER TABLE `oauth_users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Contraintes pour les tables exportées
--
--
-- Contraintes pour la table `oauth_access_tokens`
--
ALTER TABLE `oauth_access_tokens`
ADD CONSTRAINT `FK_CA42527C19EB6921` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`),
ADD CONSTRAINT `FK_CA42527CA76ED395` FOREIGN KEY (`user_id`) REFERENCES `oauth_users` (`id`);
--
-- Contraintes pour la table `oauth_authorization_codes`
--
ALTER TABLE `oauth_authorization_codes`
ADD CONSTRAINT `FK_98A471C419EB6921` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`);
--
-- Contraintes pour la table `oauth_refresh_tokens`
--
ALTER TABLE `oauth_refresh_tokens`
ADD CONSTRAINT `FK_5AB68719EB6921` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`),
ADD CONSTRAINT `FK_5AB687A76ED395` FOREIGN KEY (`user_id`) REFERENCES `oauth_users` (`id`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
6817aea19895be871f66e9fe02bf4643e3b7f6ba | SQL | vubui237/intermediate-sql-queries-afternoon | /Practice Updating Rows.sql | UTF-8 | 600 | 2.640625 | 3 | [] | no_license | --1.
-- UPDATE Customer SET Fax = null WHERE Fax IS NOT null;
--2.
-- UPDATE Customer SET Company = "Self" WHERE Company IS null;
--3.
-- SELECT CustomerId FROM Customer WHERE FirstName ="Julia" AND LastName ="Barnett" --Find her ID and update by ID.
-- UPDATE Customer SET LastName = "Thompson" WHERE CustomerId = 28;
--4.
-- UPDATE Customer SET SupportRepId = 4 WHERE Email = "luisrojas@yahoo.cl";
--5.
-- UPDATE Track SET Composer = "The darkness around us"
-- WHERE GenreId = ( SELECT GenreId FROM Genre WHERE Name = "Metal" ) AND Composer IS null;
--6.
--Refresh your page to reb00t all the databases | true |
09b76bca975b2c0aa12c6f411436df629101b4b2 | SQL | sakshamr278/Cars | /Lamborghini.sql | UTF-8 | 2,632 | 2.578125 | 3 | [] | no_license | create database Lamborghini;
use lamborghini
create table cars(S_No int,Name_Of_Car varchar (35), Top_Speed varchar (20),0_100kph Varchar (12),Power varchar (30), bhp_weight varchar (32),Displacement varchar (25),Weight varchar (25));
alter table cars add Price varchar (20);
insert into cars values (1,'Murcielago LP750 Edo','365 kph/ 227 mph','3.1 seconds','750 bhp / 551 kW','462 bhp per tonne','6.5 litre / 6496 cc','1625 kg / 3582 lbs','900 000 $');
insert into cars values(2,'Veneno Roadster','355 kph / 220 mph','2.9 seconds','750 bhp / 551 kW','503 bhp per tonne','6.5 litre / 6498 cc','1490 kg / 3285 lbs','5 000 000 $');
insert into cars values(3,'Centenario Coupe','350 kph / 217 mph','2.8 seconds','770 bhp / 566 kW','507 bhp per tonne','6.5 litre / 6498 cc','1520 kg / 3351 lbs','1 900 000 $');
insert into cars values(4,'Gallardo Dallas','376 kph / 233 mph','2.8 seconds','1220 bhp / 897 kW','797 bhp per tonne','5.2 litre / 5204 cc','1530 kg / 3373 lbs','680 000 $');
insert into cars values(5,'Huracan Mansory Torofeo','340 kph / 211 mph','2.7 seconds','1250 bhp / 919 kW','912 bhp per tonne','5.2 litre / 5204 cc','1370 kg / 3020 lbs','600 000 $');
insert into cars values(6,'Aventador LP700-4 Roadster ','350 kph / 217 mph','2.9 seconds','792 bhp / 582 kW','494 bhp per tonne','6.5 litre / 6498 cc','1605 kg / 3538 lbs','860 000 $');
insert into cars values(7,'Sesto Elemento','350 kph / 217 mph','2.5 seconds','570 bhp / 419 kW','571 bhp per tonne','5.2 litre / 5204 cc','999 kg / 2202 lbs','2 950 000 $');
insert into cars values(8,'Reventon Roadster','350 kph / 217 mph','3.4 seconds','670 bhp / 493 kW','396 bhp per tonne','6.5 litre / 6496 cc','1690 kg / 3726 lbs','1 600 000 $');
insert into cars values(9,'5-95 Zagato','325 kph / 202 mph','3.4 seconds','570 bhp / 419 kW','425 bhp per tonne','5.2 litre / 5204 cc','1340 kg / 2954 lbs','3 000 000 $');
insert into cars values(10,'Asterion LPI910-4','320 kph / 199 mph','3.0 seconds','910 bhp / 669 kW','650 bhp per tonne','5.2 litre / 5204 cc','1400 kg / 3086 lbs','3 000 000 $');
create table customer(Cust_Id varchar (20) primary key,Name varchar (50),Address varchar (50),Phone_No long ,Date_of_Purchase date,Car_Name varchar (65));
Alter table customer add city varchar (30);
Alter table customer add State varchar (30);
Alter table customer add gender char (1);
Alter Table Customer Add E_mail varchar (50);
create table login(User_ID varchar (8) primary key,Password varchar (10),User_Name varchar (30),Gender char (1),D_O_B date,Address varchar (40),Contact long );
insert into login values ('Thakur','1234','Pushpendra Thakur','M','1999-11-08','Dhar, Madhya Pradesh',9575443296);
| true |
44a362a0f5f1b8868b358befaa4aa4f7768ddf92 | SQL | John-Atha/Store-Database | /queriesCode/query14.sql | UTF-8 | 202 | 2.625 | 3 | [] | no_license | -- epilegoume ta proionta me barcode = 15168, 22753
SELECT `P_Barcode`, `Start_date`, `O_Price`, `End_date`
FROM `Older_Prices`
WHERE `P_Barcode` = '15168'
or `P_Barcode` = '22753'
order by `P_Barcode` | true |
ed77c983a9ab433ffb4a9e73d6fbe17f0705aac1 | SQL | XanaNite/reagent-server | /migrations/010.do.create_recommendations.sql | UTF-8 | 212 | 2.75 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS recommendations(
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
name TEXT,
comments TEXT NOT NULL,
agent_id INTEGER REFERENCES agents(id) ON DELETE SET NULL
); | true |
a66f98cbad21e7c8fa46bde29eee720fe730e106 | SQL | surikanda/exercise.sql_simple-queries | /part2/part2.sql | UTF-8 | 118 | 2.703125 | 3 | [] | no_license | SELECT contactFirstname, contactLastName, city
FROM customers WHERE country= "Germany"
ORDER BY contactLastName ASC; | true |
e64ec581ba360ba361e98da42e47fcd3ac680423 | SQL | IvonneSoriano/ProyectoUDB | /ProyectWeb/src/java/sv/edu/udb/database/scheduled_events.sql | UTF-8 | 1,555 | 3.640625 | 4 | [] | no_license | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Author: Rick
* Created: Mar 26, 2020
*/
SET SQL_SAFE_UPDATES = 0; # se necesita correr solo una vez, antes de ejecutar evento
CREATE EVENT tickets_vencidos_7_dias
ON SCHEDULE
EVERY 1 DAY
STARTS (TIMESTAMP(CURRENT_DATE) + INTERVAL 1 DAY + INTERVAL 7 HOUR)
ON COMPLETION PRESERVE
DO
UPDATE `gestion_tickets`.`tickets` ti
SET ti.`ticket_status` = 'VENCIDO'
WHERE ti.`ticketid` IN
(
SELECT ids_matching_criteria.id
FROM (
SELECT pks.compare,
pks.id
FROM (
SELECT now() + interval 0 day AS `now` ,
now() + interval -7 day AS `days_ago` ,
time_difference.datetimeadded ,
time_difference.datetimeadded < now() + interval -7 day AS `compare` ,
time_difference.id
FROM (
SELECT enddate AS 'DateTimeAdded',
ticketid AS 'Id'
FROM tickets
WHERE ticket_status = 'DEVUELTO_CON_OBSERVACIONES'
) time_difference
) pks
WHERE pks.compare = 1 ) ids_matching_criteria
); | true |
1fff77282a5cab9066a97f1018a54fa8df66e462 | SQL | Jilanfk/PWL | /laravel8_jilanfinian/perpustakaan.sql | UTF-8 | 5,623 | 3.046875 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 13 Jun 2021 pada 05.30
-- Versi server: 10.4.19-MariaDB
-- Versi PHP: 8.0.6
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 */;
--
-- Database: `perpustakaan`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `anggota`
--
CREATE TABLE `anggota` (
`id` int(11) NOT NULL,
`nama` varchar(45) NOT NULL,
`email` varchar(45) DEFAULT NULL,
`hp` varchar(15) DEFAULT NULL,
`foto` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `anggota`
--
INSERT INTO `anggota` (`id`, `nama`, `email`, `hp`, `foto`) VALUES
(1, 'Jilan Finian Kilani', 'jilanfiniankilani@gmail.com', '087763650459', 'Jilan Finian Kilani.jpg'),
(2, 'Ade Fikri Ramadhan', 'adefikri@gmail.com', '085651177266', 'Ade Fikri Ramadhan.jpg');
-- --------------------------------------------------------
--
-- Struktur dari tabel `buku`
--
CREATE TABLE `buku` (
`id` int(11) NOT NULL,
`isbn` varchar(100) NOT NULL,
`judul` text NOT NULL,
`tahun_cetak` varchar(45) NOT NULL,
`stok` int(11) NOT NULL,
`idpengarang` int(11) NOT NULL,
`idpenerbit` int(11) NOT NULL,
`idkategori` int(11) NOT NULL,
`cover` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `buku`
--
INSERT INTO `buku` (`id`, `isbn`, `judul`, `tahun_cetak`, `stok`, `idpengarang`, `idpenerbit`, `idkategori`, `cover`) VALUES
(1, '011', 'Godam Gundala', '2020', 750, 1, 1, 1, '011.jpg'),
(2, '012', 'Laskar Pelangi', '2007', 2000, 2, 2, 2, '012.jpg');
-- --------------------------------------------------------
--
-- Struktur dari tabel `kategori`
--
CREATE TABLE `kategori` (
`id` int(11) NOT NULL,
`nama` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `kategori`
--
INSERT INTO `kategori` (`id`, `nama`) VALUES
(1, 'Comic'),
(2, 'Novel');
-- --------------------------------------------------------
--
-- Struktur dari tabel `penerbit`
--
CREATE TABLE `penerbit` (
`id` int(11) NOT NULL,
`nama` varchar(45) NOT NULL,
`alamat` text DEFAULT NULL,
`email` varchar(45) DEFAULT NULL,
`website` varchar(45) DEFAULT NULL,
`telp` varchar(15) DEFAULT NULL,
`cp` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `penerbit`
--
INSERT INTO `penerbit` (`id`, `nama`, `alamat`, `email`, `website`, `telp`, `cp`) VALUES
(1, 'PT. Galau Terus', 'Yogjakarta', 'galauterus@gmail.com', 'www.galauterus.com', '021-2683791', 'Billy Syahputra'),
(2, 'PT. Aku Cinta Kamu', 'Jakarta Selatan', 'akucintakamu@gmail.com', 'www.akucintakamu.com', '021-7874225', 'Gading Marten');
-- --------------------------------------------------------
--
-- Struktur dari tabel `pengarang`
--
CREATE TABLE `pengarang` (
`id` int(11) NOT NULL,
`nama` varchar(45) NOT NULL,
`email` varchar(45) DEFAULT NULL,
`hp` varchar(15) DEFAULT NULL,
`foto` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `pengarang`
--
INSERT INTO `pengarang` (`id`, `nama`, `email`, `hp`, `foto`) VALUES
(1, 'Fajar Sungging', 'fajarsungging@gmail.com', '08811369886', ''),
(2, 'Andrea Kirata', 'andrekirata@gmail.com', '081316806359', '');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `anggota`
--
ALTER TABLE `anggota`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `buku`
--
ALTER TABLE `buku`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `isbn_UNIQUE` (`isbn`),
ADD KEY `fk_buku_pengarang` (`idpengarang`),
ADD KEY `fk_buku_penerbit1` (`idpenerbit`),
ADD KEY `fk_buku_kategori1` (`idkategori`);
--
-- Indeks untuk tabel `kategori`
--
ALTER TABLE `kategori`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `Nama_UNIQUE` (`nama`);
--
-- Indeks untuk tabel `penerbit`
--
ALTER TABLE `penerbit`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `pengarang`
--
ALTER TABLE `pengarang`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `anggota`
--
ALTER TABLE `anggota`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT untuk tabel `buku`
--
ALTER TABLE `buku`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT untuk tabel `kategori`
--
ALTER TABLE `kategori`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT untuk tabel `penerbit`
--
ALTER TABLE `penerbit`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `pengarang`
--
ALTER TABLE `pengarang`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--
--
-- Ketidakleluasaan untuk tabel `buku`
--
ALTER TABLE `buku`
ADD CONSTRAINT `fk_buku_kategori1` FOREIGN KEY (`idkategori`) REFERENCES `kategori` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_buku_penerbit1` FOREIGN KEY (`idpenerbit`) REFERENCES `penerbit` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_buku_pengarang` FOREIGN KEY (`idpengarang`) REFERENCES `pengarang` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
70a188f75db9ee6f4ff33f48ea12c6b4666e9a0a | SQL | PetraAbosi/Final_Exam | /mof.sql | UTF-8 | 3,007 | 3.28125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Nov 18, 2020 at 10:35 AM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.7
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 */;
--
-- Database: `mof`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE DATABASE mof;
USE mof;
CREATE TABLE `admin` (
`id` int(11) NOT NULL ,
`firstname` varchar(255) NOT NULL,
`lastname` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `file`
--
CREATE TABLE `file` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`filename` varchar(255) NOT NULL,
`company_name` varchar(255) NOT NULL,
`rep_name` varchar(255) NOT NULL,
`staff_id` int(11) NOT NULL,
`division_name` varchar(255) NOT NULL,
`department_name` varchar(255) NOT NULL,
`file_status` varchar(255) NOT NULL,
`date_received` varchar(255) NOT NULL,
`date_approved` varchar(255) NOT NULL,
`date_returned` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `staff`
--
CREATE TABLE `staff` (
`id` int(11) NOT NULL,
`firstname` varchar(255) NOT NULL,
`lastname` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`rank` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
--
--
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `file`
--
ALTER TABLE `file`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `stafff`
--
ALTER TABLE `stafff`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `file`
--
ALTER TABLE `file`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `stafff`
--
ALTER TABLE `stafff`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
a7f0d63730561e3d9f4d5aae6eeccdac2c3181f8 | SQL | AgentX-egy/four-cour-model | /Final DB/ag_project_transactionlog.sql | UTF-8 | 2,265 | 2.875 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.26, for Win64 (x86_64)
--
-- Host: localhost Database: ag_project
-- ------------------------------------------------------
-- Server version 8.0.26
/*!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 */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `transactionlog`
--
DROP TABLE IF EXISTS `transactionlog`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `transactionlog` (
`idTransactionLog` int NOT NULL,
`TransactionMessage` text,
`TransactionUserId` int DEFAULT NULL,
`TransactionDate` datetime DEFAULT CURRENT_TIMESTAMP,
`IsDeleted` tinyint DEFAULT '0',
PRIMARY KEY (`idTransactionLog`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `transactionlog`
--
LOCK TABLES `transactionlog` WRITE;
/*!40000 ALTER TABLE `transactionlog` DISABLE KEYS */;
INSERT INTO `transactionlog` VALUES (1,'You Updated your Profile',1,'2021-09-06 23:32:48',0),(2,'You Updated Salma Health Status',4,'2021-09-06 23:32:48',0);
/*!40000 ALTER TABLE `transactionlog` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-09-07 11:54:49
| true |
c4ed8f6079113f12bd6015a5f89f5ec9724af233 | SQL | Nafanjia/Database_for_analytics | /RFM.sql | UTF-8 | 1,193 | 3.578125 | 4 | [] | no_license | SELECT
b.user_id,
b.money,
b.orders,
b.last_order,
b.R,
b.F,
b.M,
CONCAT(b.R,b.F,b.M) RFM,
CASE
WHEN CONCAT(b.R,b.F,b.M) IN ('111','112','113') THEN 'Lost_New'
WHEN CONCAT(b.R,b.F,b.M) IN ('121','122','123','131','132') THEN 'Lost_Regular'
WHEN CONCAT(b.R,b.F,b.M) IN ('133') THEN 'Lost_Vip'
WHEN CONCAT(b.R,b.F,b.M) IN ('311','312','313') THEN 'New'
WHEN CONCAT(b.R,b.F,b.M) IN ('211','212','213','221','222','223','231','232','321','322','323','331','332') THEN 'Regular'
WHEN CONCAT(b.R,b.F,b.M) IN ('233','333') THEN 'Vip'
ELSE 'kek' END AS 'RFM_Group'
FROM(
SELECT
a.user_id,
CASE
WHEN TIMESTAMPDIFF(DAY,a.last_order,date('2018-01-01')) <= 30 THEN 3
WHEN TIMESTAMPDIFF(DAY,a.last_order,date('2018-01-01')) >= 60 THEN 1
ELSE 2 END AS R,
CASE
WHEN a.orders >= 48 THEN 3
WHEN a.orders <= 3 THEN 1
ELSE 2 END AS F,
CASE
WHEN a.money >= 96000 THEN 3
WHEN a.money <= 6000 THEN 1
ELSE 2 END AS M,
a.orders,
a.money,
a.last_order
FROM(
SELECT
user_id,
COUNT(id_o) orders,
SUM(price) money,
MAX(o_date) last_order
FROM orders_20190822
GROUP BY user_id) a) b | true |
e3f820603c3364f4df4635f2ebd7f2b7ea5385fd | SQL | Pengshuo510/Reseller-sales-analysis-based-on-AdventureWork2017 | /AdventureWorksDB_Insert.sql | UTF-8 | 4,157 | 3.34375 | 3 | [] | no_license | USE AdventureWorks2021
SET IDENTITY_INSERT dbo.ProductSubcategory OFF
INSERT INTO dbo.ProductSubcategory(
ProductSubcategoryID,
Name
)
SELECT ProductSubcategoryID , Name
FROM AdventureWorks2017.Production.ProductSubcategory
SET IDENTITY_INSERT dbo.ProductModel OFF
INSERT INTO dbo.ProductModel(
ProductModelID,
Name
)
SELECT ProductModelID, Name
FROM AdventureWorks2017.Production.ProductModel
SET IDENTITY_INSERT dbo.Product OFF
INSERT INTO dbo.Product(
ProductID,
Name,
ProductNumber,
Color,
ReorderPoint,
StandardCost,
ListPrice,
[Size],
Weight,
DaysToManufacture,
ProductLine,
Class,
[Style],
ProductSubcategoryID,
ProductModelID,
SellStartDate,
SellEndDate,
DiscontinuedDate
)
SELECT
ProductID,
Name,
ProductNumber,
Color,
ReorderPoint,
StandardCost,
ListPrice,
[Size],
Weight,
DaysToManufacture,
ProductLine,
Class,
[Style],
ProductSubcategoryID,
ProductModelID,
SellStartDate,
SellEndDate,
DiscontinuedDate
FROM AdventureWorks2017.Production.Product
SET IDENTITY_INSERT dbo.SpecialOffer OFF
INSERT INTO dbo.SpecialOffer(
SpecialOfferID,
Description,
DiscountPct,
[Type],
Category,
StartDate,
EndDate,
MinQty,
MaxQty
)
SELECT
SpecialOfferID,
Description,
DiscountPct,
[Type],
Category,
StartDate,
EndDate,
MinQty,
MaxQty
FROM AdventureWorks2017.Sales.SpecialOffer
SET IDENTITY_INSERT dbo.CountryRegion OFF
INSERT INTO dbo.CountryRegion(
CountryRegionCode,
Name
)
SELECT
CountryRegionCode,
Name
FROM AdventureWorks2017.Person.CountryRegion
SET IDENTITY_INSERT dbo.SalesTerritory OFF
INSERT INTO dbo.SalesTerritory(
TerritoryID,
Name,
CountryRegionCode,
[Group],
SalesYTD,
SalesLastYear,
CostYTD,
CostLastYear
)
SELECT
TerritoryID,
Name,
CountryRegionCode,
[Group],
SalesYTD,
SalesLastYear,
CostYTD,
CostLastYear
FROM AdventureWorks2017.Sales.SalesTerritory
SET IDENTITY_INSERT dbo.Person OFF
INSERT INTO dbo.Person(
PersonID,
PersonType,
Title,
FirstName,
MiddleName,
LastName,
Suffix,
EmailPromotion,
AdditionalContactInfo,
Demographics
)
SELECT
BusinessEntityID,
PersonType,
Title,
FirstName,
MiddleName,
LastName,
Suffix,
EmailPromotion,
AdditionalContactInfo,
Demographics
FROM AdventureWorks2017.Person.Person
SET IDENTITY_INSERT dbo.EmailAddress OFF
INSERT INTO dbo.EmailAddress(
PersonID,
EmailAddressID,
EmailAddress
)
SELECT
BusinessEntityID,
EmailAddressID,
EmailAddress
FROM AdventureWorks2017.Person.EmailAddress
SET IDENTITY_INSERT dbo.SalesPerson ON
INSERT INTO dbo.SalesPerson(
SalesPersonID,
SalesQuota,
Bonus,
CommissionPct,
SalesYTD,
SalesLastYear
)
SELECT
BusinessEntityID,
SalesQuota,
Bonus,
CommissionPct,
SalesYTD,
SalesLastYear
FROM AdventureWorks2017.Sales.SalesPerson
SET IDENTITY_INSERT dbo.Store ON
INSERT INTO dbo.Store(
StoreID,
Name,
SalesPersonID,
Demographics
)
SELECT
BusinessEntityID,
Name,
SalesPersonID,
Demographics
FROM AdventureWorks2017.Sales.Store
SET IDENTITY_INSERT dbo.Customer OFF
INSERT INTO dbo.Customer(
CustomerID,
PersonID,
StoreID,
AccountNumber
)
SELECT
CustomerID,
PersonID,
StoreID,
AccountNumber
FROM AdventureWorks2017.Sales.Customer
SET IDENTITY_INSERT dbo.SalesOrder OFF
INSERT INTO dbo.SalesOrder(
SalesOrderID,
RevisionNumber,
OrderDate,
Status,
OnlineOrderFlag,
SalesOrderNumber,
PurchaseOrderNumber,
AccountNumber,
CustomerID,
TerritoryID ,
SubTotal,
TaxAmt,
Freight,
TotalDue,
Comment
)
SELECT
SalesOrderID,
RevisionNumber,
OrderDate,
Status,
OnlineOrderFlag,
SalesOrderNumber,
PurchaseOrderNumber,
AccountNumber,
CustomerID,
TerritoryID ,
SubTotal,
TaxAmt,
Freight,
TotalDue,
Comment
FROM AdventureWorks2017.Sales.SalesOrderHeader
SET IDENTITY_INSERT dbo.SalesOrderDetail OFF
INSERT INTO dbo.SalesOrderDetail(
SalesOrderID,
SalesOrderDetailID,
CarrierTrackingNumber,
OrderQty,
ProductID,
SpecialOfferID,
UnitPrice,
UnitPriceDiscount,
LineTotal
)
SELECT
SalesOrderID,
SalesOrderDetailID,
CarrierTrackingNumber,
OrderQty,
ProductID,
SpecialOfferID,
UnitPrice,
UnitPriceDiscount,
LineTotal
FROM AdventureWorks2017.Sales.SalesOrderDetail
| true |
b21cd49d24e9f14248d4111771dc217501f41d23 | SQL | kimumusan/nice-vote | /src/main/resources/com/nablarch/example/dto/OpinionAndAgreements.sql | UTF-8 | 385 | 3.84375 | 4 | [] | no_license | FIND_OPINIONS=
select
TH.THEME_ID,
TH.TITLE,
OP.OPINION_ID,
OP.DESCRIPTION,
count(AG.AGREEMENT_ID) AGREEMENT_COUNT
from
THEME TH
inner join
OPINION OP
on OP.THEME_ID = TH.THEME_ID
left join
AGREEMENT AG
on AG.OPINION_ID = OP.OPINION_ID
where TH.THEME_ID = :themeId
group by
OP.OPINION_ID,
OP.DESCRIPTION
order by
OP.OPINION_ID | true |
f77f2c718cd7fbe942ea169b1c519e82223888fd | SQL | daviddominguez/springboot-cassandra-example | /src/main/resources/audit_with_tables.cql | UTF-8 | 5,966 | 3.5 | 4 | [] | no_license | CREATE KEYSPACE IF NOT EXISTS audit
WITH replication = {
'class':'SimpleStrategy',
'replication_factor':1
};
/**
* NORTH API MESSAGES TABLES
*/
// Q1. Consulta de eventos por el interfaz norte en un rango de tiempo.
CREATE TABLE IF NOT EXISTS audit.north_messages_by_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
// Q2. Consulta de eventos por el interfaz norte en un rango de tiempo y para un usuario.
CREATE TABLE IF NOT EXISTS audit.north_messages_by_user_and_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval, user), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
// Q3. Consulta de eventos por el interfaz norte en un rango de tiempo para un usuario y para un subject.
CREATE TABLE IF NOT EXISTS audit.north_messages_by_user_subject_and_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval, user, subject), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
/**
* SOUTH API MESSAGES TABLES
*/
// Q4. Consulta de eventos por los interfaces sur en un rango de tiempo.
CREATE TABLE IF NOT EXISTS audit.south_messages_by_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
// Q5. Consulta de eventos por los interfaces sur en un rango de tiempo y para un subject
CREATE TABLE IF NOT EXISTS audit.south_messages_by_subject_and_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval, subject), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
// Q6. Consulta de eventos por los interfaces sur en un rango de tiempo y para un subject y usuario.
CREATE TABLE IF NOT EXISTS audit.south_messages_by_subject_user_and_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval, subject, user), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
/**
* ALARM MESSAGES TABLES
*/
// Q7. Consulta de eventos relacionados con alarmas en un rango de tiempo.
CREATE TABLE IF NOT EXISTS audit.alarm_messages_by_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
// Q8. Consulta de eventos relacionados con alarmas en un rango de tiempo y para un subject
CREATE TABLE IF NOT EXISTS audit.alarm_messages_by_subject_and_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval, subject), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
// Q9. Consulta de eventos relacionados con alarmas en un rango de tiempo y para un subject y usuario.
CREATE TABLE IF NOT EXISTS audit.alarm_messages_by_subject_user_and_interval (
interval bigint,
id uuid,
component_type text,
msg_name text,
msg_type text,
msg_direction text,
subject text,
subject_type text,
user text,
local_correlation_id text,
global_correlation_id text,
sequence_id text,
msg_status text,
secured boolean,
msg_size_bytes int,
msg_context map<text, text>,
payload_id uuid,
occur_time timestamp,
PRIMARY KEY ((interval, subject, user), occur_time, id)
)
WITH CLUSTERING ORDER BY (occur_time DESC, id ASC);
/**
* PAYLOAD TABLE
*/
//Q10. Consulta de payloads por id
CREATE TABLE IF NOT EXISTS audit.payloads_by_id (
id uuid,
msg_payload list<text>,
PRIMARY KEY ((id))
); | true |
fdb7e1c358b4cea82d486809755db4111b870c9c | SQL | itechUnlimited/score-board | /resources/triggers.sql | UTF-8 | 1,341 | 3.5625 | 4 | [] | no_license |
// update score goals
delimiter ///
CREATE TRIGGER total_sum BEFORE INSERT ON score
FOR EACH ROW
BEGIN
UPDATE team SET total = total + NEW.score_value WHERE id=NEW.team_id;
END;
///
alter table team add total_goals INT NOT NULL; ///
// update championship goals
delimiter ///
CREATE TRIGGER total_goals BEFORE INSERT ON team_match
FOR EACH ROW
BEGIN
UPDATE team SET total_goals = total_goals + NEW.visitor_score WHERE id=NEW.visitor_team;
UPDATE team SET total_goals = total_goals + NEW.local_score WHERE id=NEW.local_team;
END;
///
alter table team add total_points INT NOT NULL; ///
// update championship points
CREATE TRIGGER total_scores BEFORE INSERT ON team_match
FOR EACH ROW
BEGIN
UPDATE team SET total_points = total_points + 3 WHERE id=NEW.visitor_team AND NEW.visitor_score > NEW.local_score;
UPDATE team SET total_points = total_points + 3 WHERE id=NEW.local_team AND NEW.visitor_score < NEW.local_score;
UPDATE team SET total_points = total_points + 1 WHERE id=NEW.visitor_team AND NEW.visitor_score = NEW.local_score;
UPDATE team SET total_points = total_points + 1 WHERE id=NEW.local_team AND NEW.visitor_score = NEW.local_score;
UPDATE team SET total_goals = total_goals + NEW.visitor_score WHERE id=NEW.visitor_team;
UPDATE team SET total_goals = total_goals + NEW.local_score WHERE id=NEW.local_team;
END;
///
| true |
a31ea028381092348b6c127475be8f1cc0f4d92b | SQL | btoztas/SIBD | /P2/function.sql | UTF-8 | 1,701 | 3.96875 | 4 | [] | no_license | DELIMITER $$
DROP FUNCTION IF EXISTS checkRegion;
CREATE FUNCTION checkRegion(Ax1 FLOAT(4,3), Ay1 FLOAT(4,3), Ax2 FLOAT(4,3), Ay2 FLOAT(4,3), Bx1 FLOAT(4,3), By1 FLOAT(4,3), Bx2 FLOAT(4,3), By2 FLOAT(4,3))
RETURNS BOOL
BEGIN
-- this block is just to guarantee that x2>x1 and y2>y1. that is necessarie for
-- all the conditions to work
IF Bx1>Bx2 THEN SET Bx1=Bx2+Bx1; SET Bx2 = Bx1-Bx2; SET Bx1= Bx1 - Bx2; END IF;-- |
IF Ax1>Ax2 THEN SET Ax1=Ax2+Ax1; SET Ax2 = Ax1-Ax2; SET Ax1= Ax1 - Ax2; END IF;-- |->if the values with index 2 are superior
IF By1>By2 THEN SET By1=By2+By1; SET By2 = By1-By2; SET By1= By1 - By2; END IF;-- | to the values with index 1 we must swap
IF Ay1>Ay2 THEN SET Ay1=Ay2+Ay1; SET Ay2 = Ay1-Bx2; SET Ay1= Ay1 - Ay2; END IF;-- | them
IF Bx1 > Ax2 OR By1 > Ay2 OR Ax1 > Bx2 OR Ay1 > By2 THEN -- check if the areas dont overlap
RETURN FALSE; -- if they dont then return false
ELSE
RETURN TRUE; -- if they overlap return true
END IF;
END $$
DELIMITER ;
DELIMITER $$
DROP FUNCTION IF EXISTS regionOverlap;
CREATE FUNCTION regionOverlap(A VARCHAR(255), B VARCHAR(255))
RETURNS BOOL
BEGIN -- put in r1 and r2 all the fregions of serie A and serie B. call the funcion.
-- if select returns any row, then there is an overlap. EXISTS returns true
-- and in the end we return the value of the EXISTS condition
RETURN EXISTS (SELECT r1.series_id, r2.series_id
FROM region AS r1, region AS r2 WHERE checkRegion(r1.x1, r1.y1, r1.x2, r1.y2, r2.x1, r2.y1, r2.x2, r2.y2) AND r1.series_id = A AND r2.series_id = B);
END $$
DELIMITER ;
| true |
375f2dc4340460281ca9dad22d385ce2848a9669 | SQL | hankmander/nextjs-pwa-graphql-sql-boilerplate | /docs/database.ddl | UTF-8 | 465 | 2.734375 | 3 | [
"ISC"
] | permissive | -- DDL generated by Postico 1.5.7
-- Not all database features are supported. Do not use for backup.
-- Table Definition ----------------------------------------------
CREATE TABLE article (
id SERIAL PRIMARY KEY,
title character varying(200),
content text
);
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX article_pkey ON article(id int4_ops);
CREATE UNIQUE INDEX article_guid_key ON article(guid text_ops);
| true |
027c329d6f2e2f8a6cbd0279f0315e955431f004 | SQL | l3acon/localquestapi | /sql/dbInitialization.sql | UTF-8 | 1,830 | 4.3125 | 4 | [] | no_license | --
-- drop tables if they exist in the database
-- these are dropped in FK > PK order
--
DROP TABLE IF EXISTS userDistance;
DROP TABLE IF EXISTS location;
DROP TABLE IF EXISTS userGame;
DROP TABLE IF EXISTS game;
DROP TABLE IF EXISTS user;
--
-- create tables
-- these are created in PK > FK order
--
CREATE TABLE user (
userId BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
email VARCHAR(250) NOT NULL,
latitude DECIMAL(8, 5) NOT NULL,
longitude DECIMAL(8, 5) NOT NULL,
PRIMARY KEY (userId),
UNIQUE (email)
);
CREATE TABLE game (
gameId BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
gameAPI VARCHAR(64) NOT NULL,
gameDesc VARCHAR(250) NOT NULL,
PRIMARY KEY (gameId),
UNIQUE (gameAPI),
UNIQUE (gameDesc)
);
CREATE TABLE userGame (
userGameId BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
userId BIGINT UNSIGNED NOT NULL,
gameId BIGINT UNSIGNED NOT NULL,
userToken VARCHAR(64) NOT NULL,
PRIMARY KEY (userGameId),
INDEX (userId),
INDEX (gameId),
INDEX (userId, gameId),
INDEX (gameId, userId),
FOREIGN KEY (userId) REFERENCES user(userId),
FOREIGN KEY (gameId) REFERENCES game(gameId)
);
CREATE TABLE userDistance (
userDistanceId BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
userId1 BIGINT UNSIGNED NOT NULL,
userId2 BIGINT UNSIGNED NOT NULL,
distance DECIMAL(8, 5) NOT NULL,
PRIMARY KEY (userDistanceId),
INDEX (userId1),
INDEX (userId2),
INDEX (userId1, userId2),
INDEX (userId2, userId1),
FOREIGN KEY (userId1) REFERENCES user(userId),
FOREIGN KEY (userId2) REFERENCES user(userId)
);
--
-- create view
--
CREATE OR REPLACE VIEW userDistanceEx
AS
SELECT userId1, userId2, distance
FROM userDistance
UNION
SELECT userId2, userId1, distance
FROM userDistance;
CREATE OR REPLACE VIEW userGameEx
AS
SELECT gameAPI, userToken, userId
FROM game
INNER JOIN userGame ON game.gameId = userGame.gameId;
| true |
a20c9243406ebcadeec8409e916105a1976fcd81 | SQL | handan2/spring-boot-sample | /spring-boot-demo/spring-boot-admin/src/main/resources/db/admin.sql | UTF-8 | 3,913 | 3.296875 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : 10.10.20.100
Source Server Version : 50721
Source Host : 125.69.73.254:33600
Source Database : admin
Target Server Type : MYSQL
Target Server Version : 50721
File Encoding : 65001
Date: 2019-01-17 18:01:00
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for BS_PERMISSION
-- ----------------------------
DROP TABLE IF EXISTS `BS_PERMISSION`;
CREATE TABLE `BS_PERMISSION` (
`ID` int(11) NOT NULL COMMENT '权限ID',
`ALIAS` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '别名',
`PERMISSION_NAME` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '名字',
`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间',
`PID` int(11) DEFAULT NULL COMMENT '父ID',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='权限表';
-- ----------------------------
-- Records of BS_PERMISSION
-- ----------------------------
INSERT INTO `BS_PERMISSION` VALUES ('1', '超级管理员', 'ADMIN', '2019-01-17 15:28:57', '0');
-- ----------------------------
-- Table structure for BS_ROLE
-- ----------------------------
DROP TABLE IF EXISTS `BS_ROLE`;
CREATE TABLE `BS_ROLE` (
`ID` int(11) NOT NULL COMMENT '角色ID',
`ROLE_NAME` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '角色名称',
`CREATE_TIME` datetime DEFAULT NULL COMMENT '角色创建时间',
`REMARK` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '角色备注',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of BS_ROLE
-- ----------------------------
INSERT INTO `BS_ROLE` VALUES ('1', '超级管理员', '2019-01-17 15:30:32', '超级管理员');
INSERT INTO `BS_ROLE` VALUES ('2', '普通用户', '2019-01-17 15:30:55', '普通用户');
-- ----------------------------
-- Table structure for BS_ROLE_PERMISSIONS
-- ----------------------------
DROP TABLE IF EXISTS `BS_ROLE_PERMISSIONS`;
CREATE TABLE `BS_ROLE_PERMISSIONS` (
`ID` int(11) NOT NULL,
`ROLE_ID` int(11) NOT NULL COMMENT '角色ID',
`PERMISSION_ID` int(11) NOT NULL COMMENT '权限ID',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='角色权限中间表';
-- ----------------------------
-- Records of BS_ROLE_PERMISSIONS
-- ----------------------------
INSERT INTO `BS_ROLE_PERMISSIONS` VALUES ('1', '1', '1');
-- ----------------------------
-- Table structure for BS_USER
-- ----------------------------
DROP TABLE IF EXISTS `BS_USER`;
CREATE TABLE `BS_USER` (
`ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`USER_NAME` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '用户名',
`PASS_WORD` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '密码',
`AVATAR` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '头像',
`ENABLED` int(2) DEFAULT NULL COMMENT '是否可用 1可用 0不可用',
`EMAIL` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '邮箱地址',
`CREATE_TIME` datetime DEFAULT NULL,
`UPDATE_TIME` datetime DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of BS_USER
-- ----------------------------
INSERT INTO `BS_USER` VALUES ('1', 'even', '123', null, '1', 'even366@qq.com', '2019-01-17 15:32:44', '2019-01-17 15:32:47');
-- ----------------------------
-- Table structure for BS_USER_ROLE
-- ----------------------------
DROP TABLE IF EXISTS `BS_USER_ROLE`;
CREATE TABLE `BS_USER_ROLE` (
`ID` int(11) NOT NULL,
`USER_ID` int(11) NOT NULL COMMENT '用户ID',
`ROLE_ID` int(11) NOT NULL COMMENT '角色ID',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of BS_USER_ROLE
-- ----------------------------
INSERT INTO `BS_USER_ROLE` VALUES ('1', '1', '1');
| true |
07f5feaec5abcf0a8d74191a062be278f0eeff19 | SQL | almostcarol/MySQL | /22.10/Exemplo.sql | UTF-8 | 556 | 3.3125 | 3 | [] | no_license | use db_acervo35;
create table tb_usuario(
id_usuario bigint auto_increment,
nome varchar (255) not null,
email varchar (255) not null,
nascimento_data date,
senha varchar (255) not null,
primary key (id_usuario)
);
select * from db_acervo35.tb_usuario;
insert into tb_usuario (nome, usuario, nascimento_data, senha)
values ("Carol", "carol@email.com" , '20/02/2000' , "12345");
delete from tb_usuario where id_usuario = 1;
update `db_acervo35`.`tb_usuario` set `senha` = 333 where (`id_usuario` = '2');
alter table tb_usuario add livro varchar (30) | true |
2e7733dc81e42b3cb048bb9615f9ef424990d68a | SQL | talitagaldino/Banco-de-Dados-2019.2 | /roteiro3-nathan-118110342.sql | UTF-8 | 4,138 | 3.75 | 4 | [] | no_license | -- Banco de Dados 2019.2 - ROTEIRO 3
-- Professor: Cláudio Campelo
-- Aluno: Nathan Fernandes
CREATE TYPE estadoPB as ENUM('paraiba', 'bahia', 'alagoas', 'pernambuco', 'sergipe', 'ceara', 'rio grande do norte', 'piaui', 'maranhao');
CREATE TABLE farmacia (
id BIGINT UNIQUE PRIMARY KEY,
nome TEXT NOT NULL,
tipo TEXT NOT NULL,
rua TEXT NOT NULL,
bairro TEXT NOT NULL UNIQUE,
numero INTEGER,
estado estadoPB,
gerenteCpf VARCHAR(11) NOT NULL UNIQUE,
EXCLUDE USING gist (tipo WITH =) WHERE (tipo = 'sede')
);
CREATE TYPE cargoType AS ENUM('farmaceutico', 'vendedor', 'entregador', 'caixa', 'administrador');
CREATE TABLE funcionario (
nome TEXT NOT NULL,
cpf CHAR(11) PRIMARY KEY,
cargo cargoType,
isGerente BOOLEAN,
farmaciaId BIGINT NOT NULL,
CONSTRAINT gerente CHECK (isGerente = TRUE AND cargo IN('administrador', 'farmaceutico') OR isGerente = FALSE)
);
ALTER TABLE funcionario ADD FOREIGN KEY (farmaciaId) REFERENCES farmacia(id);
CREATE TABLE medicamento (
id BIGINT PRIMARY KEY,
nome TEXT NOT NULL,
receita BOOLEAN NOT NULL,
fabricante TEXT
);
CREATE TABLE cliente (
cpf CHAR(11) PRIMARY KEY,
nome TEXT NOT NULL,
nascimento DATE NOT NULL,
CONSTRAINT maioridade CHECK(EXTRACT(YEAR FROM AGE(nascimento)) > 17)
);
CREATE TABLE enderecosCliente (
id CHAR(11) REFERENCES cliente(cpf),
tipo TEXT NOT NULL,
rua TEXT NOT NULL,
bairro TEXT NOT NULL,
cep BIGINT NOT NULL,
numero INTEGER NOT NULL
CONSTRAINT tipos CHECK(tipo IN ('residencia', 'trabalho', 'outro'))
);
ALTER TABLE enderecosCliente ADD PRIMARY KEY(id);
CREATE TABLE venda (
id BIGINT PRIMARY KEY,
funcionarioCpf CHAR(11) REFERENCES funcionario(cpf) NOT NULL,
funcionarioCargo cargoType NOT NULL,
clienteCpf CHAR(11) REFERENCES cliente(cpf) ON DELETE RESTRICT,
clienteTemEnd BOOLEAN NOT NULL,
medId BIGINT REFERENCES medicamento(id) ON DELETE RESTRICT,
medReceita BOOLEAN NOT NULL,
CONSTRAINT clienteOuNao CHECK(clienteCpf = NULL AND clienteTemEnd = FALSE OR clienteCpf != NULL AND clienteTemEnd = TRUE),
CONSTRAINT receitaReq CHECK(medReceita = TRUE AND clienteCpf != NULL OR medReceita = FALSE),
CONSTRAINT funcionario CHECK(funcionarioCargo = 'vendedor')
);
CREATE TABLE entrega (
clienteCpf CHAR(11) REFERENCES cliente(cpf),
medId BIGINT REFERENCES medicamento(id),
clienteTemEnd BOOLEAN NOT NULL,
CONSTRAINT clienteTemEndereco CHECK(clienteTemEnd = TRUE)
);
ALTER TABLE farmacia ADD CONSTRAINT tipos CHECK(tipo IN ('sede', 'filial'));
-- TESTES:
-- Deve funcionar:
INSERT INTO farmacia VALUES(0, 'farmacia dias', 'filial', 'alguma rua', 'algum bairro',
158, 'paraiba', '56734523410');
INSERT INTO funcionario VALUES('alfredo', '12345678923', 'vendedor', FALSE, 0);
INSERT INTO funcionario VALUES('Patricia', '12345678543', 'administrador', TRUE, 0);
INSERT INTO farmacia VALUES(1, 'drogasil', 'sede', 'jose de alguma coisa', 'centro',
451, 'paraiba', '32345678543');
INSERT INTO funcionario VALUES('Jorge', '32345678543', 'farmaceutico', TRUE, 1);
INSERT INTO medicamento VALUES(1, 'alprazolam', TRUE, 'ems');
INSERT INTO medicamento VALUES(30, 'neosoro', FALSE, 'n sei');
INSERT INTO cliente VALUES('54612345678', 'JOAO', '2000-08-22');
INSERT INTO cliente VALUES('54612345666', 'Matheus', '1999-02-20');
INSERT INTO venda VALUES(1, '32345678543', 'vendedor', '54612345678', FALSE, 30, FALSE);
INSERT INTO venda VALUES(2, '12345678923', 'vendedor', '54612345666', FALSE, 30, TRUE);
-- Deve dar erro:
INSERT INTO farmacia VALUES(0, 'redefarma' , 'sede' , 'alguma rua2', 'algum bairro',
300, 'bahia', '45678912345');
INSERT INTO cliente VALUES('54612345679', 'Antonio', '2004-08-22');
INSERT INTO cliente VALUES('54612345678', 'Maria', '2000-08-22');
DELETE FROM medicamento WHERE id = 30;
INSERT INTO entrega VALUES('54612345678', 1, FALSE); | true |
b3da5fe7a8f7ba6c1c882e18c13d7c14b0c42ba7 | SQL | derco19/blog-site | /harshblogs.sql | UTF-8 | 3,499 | 3.28125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 24, 2021 at 12:02 PM
-- Server version: 10.4.19-MariaDB
-- PHP Version: 8.0.6
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 */;
--
-- Database: `harshblogs`
--
-- --------------------------------------------------------
--
-- Table structure for table `blogsdata`
--
CREATE TABLE `blogsdata` (
`sno` int(11) NOT NULL,
`title` text NOT NULL,
`subtitle` text NOT NULL,
`slug` varchar(25) NOT NULL,
`content` text NOT NULL,
`date` datetime NOT NULL DEFAULT current_timestamp(),
`img` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `blogsdata`
--
INSERT INTO `blogsdata` (`sno`, `title`, `subtitle`, `slug`, `content`, `date`, `img`) VALUES
(0, '', '', '', '', '2021-06-05 18:34:40', ''),
(1, 'Being a special child', 'Myths and facts', 'Myths and facts', 'Standing out in a class of 50 students to solve the trickiest math problems of having magical talents in arts and music or anything of admiration are some traits defined by the society of a special child.\r\n\r\nBut what really makes a child special', '2021-06-24 14:31:49', ''),
(2, 'Family and Career', 'Importance and Priority', 'Importance and Priority', 'Well our family is what has actually made us this capable to pursue a career from our parents to our elders we were guided to pursue a career then what happens that somehow when we are actually passionate about making our career strive in the early stages of adulthood there comes this unsaid rift between us and family.', '2021-06-24 14:47:23', ''),
(3, 'Expense Manager App', 'manage your day to day expenses', 'manage your day to day ex', 'It is an app built to manage your day-to-day expenses by keeping a track of your expenses and notifying you about the expenditure and the due bills and the manages the in and out of money.', '2021-06-24 15:16:08', '');
-- --------------------------------------------------------
--
-- Table structure for table `contactsdata`
--
CREATE TABLE `contactsdata` (
`sno` int(11) NOT NULL,
`name` text NOT NULL,
`email` varchar(40) NOT NULL,
`phno` varchar(256) NOT NULL,
`message` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `contactsdata`
--
INSERT INTO `contactsdata` (`sno`, `name`, `email`, `phno`, `message`) VALUES
(1, 'Harsh', 'harsh@gmail.com', '9999999999', 'Hi this is dummy check text'),
--
-- Indexes for dumped tables
--
--
-- Indexes for table `blogsdata`
--
ALTER TABLE `blogsdata`
ADD PRIMARY KEY (`sno`);
--
-- Indexes for table `contactsdata`
--
ALTER TABLE `contactsdata`
ADD PRIMARY KEY (`sno`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `blogsdata`
--
ALTER TABLE `blogsdata`
MODIFY `sno` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `contactsdata`
--
ALTER TABLE `contactsdata`
MODIFY `sno` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
cac4b5ad9930a3edbdf7eb2aa879955f7871ce7d | SQL | AdvancedDatabases/ZSBD-studies-course | /benchmark/test-sets/set1-geo/4.sql | UTF-8 | 527 | 4.09375 | 4 | [] | no_license | -- number and count of different products in each country inventories
SELECT COUNTR.COUNTRY_ID, PC.CATEGORY_NAME, SUM(I.QUANTITY) quantity, COUNT(P.PRODUCT_ID) diff_products
FROM WAREHOUSES W
JOIN LOCATIONS L on W.LOCATION_ID = L.LOCATION_ID
JOIN COUNTRIES COUNTR on L.COUNTRY_ID = COUNTR.COUNTRY_ID
JOIN INVENTORIES I on W.WAREHOUSE_ID = I.WAREHOUSE_ID
JOIN PRODUCTS P on I.PRODUCT_ID = P.PRODUCT_ID
JOIN PRODUCT_CATEGORIES PC on P.CATEGORY_ID = PC.CATEGORY_ID
GROUP BY COUNTR.COUNTRY_ID, PC.CATEGORY_NAME; | true |
37b33bc7273afc0419a5849c6e40ed5fa0ae8241 | SQL | johnathancurtis/DoD-AutoRoute | /DoDARDB/User.sql | UTF-8 | 379 | 3.140625 | 3 | [] | no_license | CREATE TABLE [User]
(
DODID INT
, [UIC] VARCHAR(10)
, [Command Name] VARCHAR(80)
, [AO] BIT
, [EMAIL] VARCHAR (80)
, [PHONE] VARCHAR(12)
, [Rank] VARCHAR (10)
, [First Name] VARCHAR (80)
, [Middle Name] VARCHAR(3)
, [Last Name] VARCHAR (80),
PRIMARY KEY CLUSTERED (DODID ASC),
CONSTRAINT [FK_USER_REQUEST_UIC] FOREIGN KEY (UIC)
REFERENCES [REQUEST](UIC) ON DELETE CASCADE
) | true |
3073e9d4433583832d1515ae0d2a3565a0c9cf0a | SQL | hongtao12310/mlcloud | /deploy/db/mlcloud.sql | UTF-8 | 1,596 | 3.65625 | 4 | [] | no_license | drop database if exists mlcloud;
create database mlcloud charset = utf8;
use mlcloud;
create table user (
id int NOT NULL AUTO_INCREMENT,
username varchar(32),
password varchar(40) NOT NULL,
salt varchar(40) DEFAULT NULL,
sys_admin tinyint(1) DEFAULT 0 NOT NULL,
creation_time datetime NOT NULL,
update_time datetime NOT NULL,
primary key (id),
UNIQUE (username)
);
create table tensorflow_job (
id int NOT NULL AUTO_INCREMENT,
num_ps int DEFAULT 0 NOT NULL,
num_workers int DEFAULT 1 NOT NULL,
image varchar(256),
log_dir varchar(256) NOT NULL,
data_dir varchar(256),
command varchar(256) NOT NULL,
arguments varchar(256) NOT NULL,
num_gpu int DEFAULT 0 NOT NULL,
tensorboard BOOL DEFAULT FALSE NOT NULL,
tensorboard_host VARCHAR(256) DEFAULT NULL,
has_master BOOL DEFAULT FALSE NOT NULL,
PRIMARY KEY (id)
);
create table mxnet_job (
id int NOT NULL AUTO_INCREMENT,
mode varchar(32) NOT NULL,
num_ps int DEFAULT 0 NOT NULL,
num_workers int DEFAULT 1 NOT NULL,
image varchar(256),
log_dir varchar(256) NOT NULL,
data_dir varchar(256),
command varchar(256) NOT NULL,
arguments varchar(256) NOT NULL,
num_gpu int DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
create table job (
id int NOT NULL AUTO_INCREMENT,
name varchar(32),
type varchar(32), # 'tensorflow', 'mxnet'
user_id int,
user_name varchar(32),
creation_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES user (`id`) ON UPDATE CASCADE ON DELETE CASCADE
);
| true |
eddc42e85752f6320ddd5762d6476c28fdf556c5 | SQL | sircanist/clipper | /clipper-cli/src/test/scripts/v_takesCourse.sql | UTF-8 | 346 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | DROP VIEW v_takesCourse CASCADE;
CREATE OR REPLACE VIEW v_takesCourse AS
SELECT innerRel.x2 AS att1, innerRel.x1 AS att2
FROM (
SELECT ora_0.b AS x1, ora_0.a AS x2
FROM object_role_assertion ora_0
WHERE ora_0.object_role=155
UNION
SELECT ora_0.b AS x1, ora_0.a AS x2
FROM object_role_assertion ora_0
WHERE ora_0.object_role=147
) as innerRel
| true |
6dbb09350ab62599444730c0d4fdcfa865d25540 | SQL | giovanirguz/SistemaInventarios | /db/DbSchema.sql | UTF-8 | 489 | 2.765625 | 3 | [] | no_license |
if exists (select * from dbo.sysobjects where id = object_id(N'Clientes') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table Clientes
create table Clientes (
Id INT IDENTITY NOT NULL,
NoControl INT null,
Nombre NVARCHAR(255) null,
ApellidoPaterno NVARCHAR(255) null,
ApellidoMaterno NVARCHAR(255) null,
Rfc NVARCHAR(255) null,
Direccion NVARCHAR(255) null,
Telefono NVARCHAR(255) null,
primary key (Id)
)
| true |
fcc2e227e21b663397f547c64c27b7de188beac8 | SQL | mahimavyas001/Basic-banking-system | /spark_bank.sql | UTF-8 | 1,240 | 3.484375 | 3 | [] | no_license | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
CREATE TABLE `transaction` (
`sno` int(3) NOT NULL,
`sender` text NOT NULL,
`receiver` text NOT NULL,
`balance` int(8) NOT NULL,
`datetime` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `users` (
`id` int(3) NOT NULL,
`name` text NOT NULL,
`email` varchar(30) NOT NULL,
`balance` int(8) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `name`, `email`, `balance`) VALUES
(1, 'Abhishek', 'abhisheka@gmail.com', 99000),
(2, 'Bhushan', 'bhushan@gmail.com', 54000),
(3, 'Ganesh', 'ganesh@gmail.com', 60000),
(4, 'Chaitanya', 'chaitanya@gmail.com', 72000),
(5, 'Mayur', 'mayur@gmail.com', 46000),
(6, 'Nitsh', 'nitish@gmail.com', 100000),
(7, 'Sarthak', 'sarthak@gmail.com', 88000),
(8, 'Yash', 'yash@gmail.com', 59000),
(9, 'Parth', 'parth@gmail.com', 66000),
(10, 'Yuvraj', 'yuvraj@gmail.com', 250000);
ALTER TABLE `transaction`
ADD PRIMARY KEY (`sno`);
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
ALTER TABLE `transaction`
MODIFY `sno` int(3) NOT NULL AUTO_INCREMENT;
ALTER TABLE `users`
MODIFY `id` int(3) NOT NULL AUTO_INCREMENT;
COMMIT;
| true |
2aff7ba9de00a8b94519ab3a482e23a39a79bf01 | SQL | simonaditia/SQL-Projects | /create-table.sql | UTF-8 | 250 | 2.9375 | 3 | [] | no_license | CREATE DATABASE School;
USE School;
CREATE TABLE Student {
student_id int PRIMARY KEY,
full_name TEXT,
birthday DATE,
parent_name varchar(255),
};
INSERT INTO Student('Github', '2017-12-31 23:59:59', 'Git');
SELECT * FROM Student; | true |
7b8a81be4f2e1e9dcf5b932a798052b1b02577b6 | SQL | leo-from-spb/demo-db | /Postgres/schema/create-Geo.sql | UTF-8 | 2,715 | 4 | 4 | [] | no_license | set search_path to Geo, public;
create table Country_ISO
(
Iso_2 char(2) not null primary key,
Iso_3 char(3) not null unique,
Iso_Num smallint not null unique,
Name varchar(48) not null,
Name_Prefix varchar(26),
Name_Suffix varchar(26),
Name_Alias varchar(26),
Global_Region_Code smallint not null,
Global_SubRegion_Code smallint
);
create index Country_ISO_Name_i on Country_ISO (Name);
create index Country_ISO_Name_Prefix_i on Country_ISO (Name_Prefix);
create index Country_ISO_Name_Suffix_i on Country_ISO (Name_Suffix);
create index Country_ISO_Name_Alias_i on Country_ISO (Name_Alias);
create view Country_ISO_FN as
select Iso_2, Iso_3, Iso_Num,
Name, Name_Prefix, Name_Suffix,
(case when Name_Prefix is not null then Name_Prefix||' ' else '' end) || Name || (case when Name_Suffix is not null then ' ('||Name_Suffix||')' else '' end) as Name_Full,
Name_Alias,
Global_Region_Code, Global_SubRegion_Code
from Country_ISO
with check option;
create table Country_ISO_Area
(
Iso_Num smallint not null,
Year smallint not null,
Area numeric(11) not null,
primary key (Iso_Num, Year),
foreign key (Iso_Num) references Country_ISO(Iso_Num)
);
create materialized view Country_ISO_Area_Last as
select distinct Iso_Num,
first_value(Year) over C as Area_Year,
first_value(Area) over C as Area
from Country_ISO_Area
window C as (partition by Iso_Num order by Year desc);
refresh materialized view Country_ISO_Area_Last;
create unique index Country_ISO_Area_Last_Iso_ui on Country_ISO_Area_Last (Iso_Num);
create table Country_ISO_Population
(
Iso_Num smallint not null,
Year smallint not null,
Population bigint not null,
primary key (Iso_Num, Year),
foreign key (Iso_Num) references Country_ISO(Iso_Num)
);
create materialized view Country_ISO_Population_Last as
select distinct Iso_Num,
first_value(Year) over C as Population_Year,
first_value(Population) over C as Population
from Country_ISO_Population
window C as (partition by Iso_Num order by Year desc);
refresh materialized view Country_ISO_Population_Last;
create unique index Country_ISO_Population_Last_Iso_ui on Country_ISO_Population_Last (Iso_Num);
create view Country_ISO_F as
select C.*,
A.Area, A.Area_Year,
P.Population, P.Population_Year,
round(case when A.Area > 0 and P.Population > 0
then P.Population * 1.0 / A.Area
end::numeric, 3) as Population_Density
from Country_ISO_FN C
left join Country_ISO_Area_Last A using (Iso_Num)
left join Country_ISO_Population_Last P using (Iso_Num);
| true |
31216da7ba2bcd16a3be7dcafca5726f042ba74c | SQL | Soliloquiess/SF_Record | /SF_PDF/0407/starwars_ex2.sql | UTF-8 | 2,005 | 3.265625 | 3 | [] | no_license | -- 1. 전 스타워즈 시리즈의 상영년도, 에피소드이름, 배역, 출연배우 이름
-- 2. 에피소드 4에 출연한 배우는 모두 몇 명인지 구하는 쿼리
-- 3. 각 배우 별 출연횟수를 조회하는 쿼리
-- 4. 에피소드별 이름과 출연자 수
-- 5. 출연자수가 10명 이상인 에피소드의 이름과 출연자수
-- 6.제국의 역습에 등장하는 배우 이름
-- 7. '아미달라 여왕'이 등장했던 에피소드 id, 에피소드 이름과 상영연도
-- 8. 해리슨 포드가 등장했던 에피소드의 id와 에피소드 이름
-- 9. 각 에피소드의 id와 출연한 인원 수
-- 10. 각 에피소드각에 출연한 인원 수 중 가장 많은 인원수
-- 11. 가장 많은 인원이 출연한 에피소드의 id와 인원 수
-- 12. 가장 많은 인원이 출연한 에피소드 id, 그 에피소드에 출연한 배우명
-- 13. 출연했던 횟수가 가장 많은 배우 TOP 5의 이름과 횟수를 조회
-- 14. 출연했던 횟수가 가장 많은 배우 TOP 6-10의 이름과 횟수를 조회
-- 15. 캐릭터에 role값을 부여하여 update(롤의 이름을 활용한다.)
-- 1,4,13 제다이
-- 2,9 반란군
-- 5,12,18 시스
-- 16. 캐릭터와 마스터 연결하여 update
-- 아나킨 스카이워커 13 오비완 케노비 4
-- 루크 스카이워커 1 오비완 케노비 4
-- 마스터 윈두 20 요다 11
-- 듀크백작 21 요다 11
-- 다스 베이더 5 다스 시디어스 12
-- 다스 몰 18 다스 시디어스 12
-- 오비완 캐노비 4 콰이곤 진 14
-- 콰이콘 진 14 듀크백작 21
-- 17. 마스터 역할의 배역이름
-- 18. 오비완 케노비의 제자는
-- 19. 오비완 케노비의 제자는 몇명
-- 20. 모든 배역과 해당 배역의 마스터 역할배역의 이름을 함께 조회(단, 마스터가 없는 배역도 포함)
| true |
e5498a9934682977590574373894376da7ff42c6 | SQL | woodroof/babcom | /db/data/actions.sql | UTF-8 | 978 | 3.59375 | 4 | [] | no_license | -- drop table data.actions;
create table data.actions(
id integer not null generated always as identity,
code text not null,
function text not null,
default_params jsonb,
constraint actions_pk primary key(id),
constraint actions_unique_code unique(code)
);
comment on column data.actions.function is 'Имя функции для выполнения действия. Функция вызывается с параметрами (client_id, request_id, params, user_params, default_params), где params - параметры, передаваемые на клиент и возвращаемые с него в неизменном виде, user_params - параметры, вводимые пользователем, default_params - параметры, прописанные в данной таблице. Функция должна либо бросить исключение, либо сгенерировать сообщение клиенту.';
| true |
fa26f14bd99e34d23a64606ad04e800e3453b425 | SQL | TrembitaUA/examples | /Oracle/5-USER_test-1_select.sql | UTF-8 | 941 | 2.984375 | 3 | [] | no_license | set echo on
set pagesize 0 embedded on
set linesize 5000
ALTER SESSION SET NLS_NUMERIC_CHARACTERS=', ';
ALTER SESSION SET NLS_DATE_FORMAT = 'DD.MM.YYYY';
COLUMN tab NEW_VALUE tab NOPRINT
SELECT CHR(9) tab FROM DUAL;
SET COLSEP ';'
WITH xml AS (
SELECT uxp_client.UXP_CALL('getPersonInfoPy', CURSOR (SELECT 'personId' item, '12345672' value FROM dual)) responce FROM dual
)
SELECT x.*
FROM xml
CROSS JOIN xmltable('/*:Envelope/*:Body/*:getPersonInfoPyResponse/*:getPersonInfoPyResult'
PASSING responce
COLUMNS INN VARCHAR2(10) path '*:inn' ,
FIRSTNAME VARCHAR2(64) path '*:firstname',
SURNAME VARCHAR2(64) path '*:surname',
PATRONYMIC VARCHAR2(64) path '*:patronymic',
BIRTHDATE DATE path '*:birthdate',
PASSPORT_SER VARCHAR2(5) path '*:passport_ser',
PASSPORT_NUM VARCHAR2(10) path '*:passport_num'
) x;
quit;
| true |
7167b5f3ddfa6eae26a133b063c59b75632d2c9e | SQL | JPHebert32/sql-challenge | /EmployeeSQL/individual_queries/employee_info.sql | UTF-8 | 365 | 4.09375 | 4 | [] | no_license | --List the following details of each employee: employee number, last name, first name, sex, and salary.
DROP VIEW employee_info;
CREATE VIEW employee_info AS
SELECT e.emp_no, e.last_name, e.first_name, e.sex, Max(s.salary)AS "Salary"
FROM employees e
JOIN salaries s
ON e.emp_no = s.emp_no
GROUP BY e.emp_no
ORDER BY e.emp_no ASC;
SELECT * FROM employee_info; | true |
3d053865bee2be33377ce5d2df5b583791d799cb | SQL | vietplayfuri/dnt-backend | /dnt.database/migration/schema/V1.9/V1.9.8__Create_South_Africa_SMO.sql | UTF-8 | 512 | 2.703125 | 3 | [] | no_license | INSERT INTO smo(id, region_id, "key", "value")
VALUES (uuid_generate_v4(),
(SELECT id FROM region WHERE "name" = 'IMEA'),
'SOUTHERN AFRICA CLUSTER',
'SOUTHERN AFRICA CLUSTER');
UPDATE smo
SET "key" = 'EAST WEST WHITESPACE AFRICA',
"value" = 'EAST WEST WHITESPACE AFRICA'
WHERE "key" = 'SOUTH AFRICA & SSA EXPANSION MARKETS GROUP';
UPDATE country
SET smo_id = (SELECT id FROM smo WHERE "key" = 'SOUTHERN AFRICA CLUSTER')
WHERE iso IN ('NA', 'MZ', 'ZA', 'SZ', 'ZM', 'LS', 'BW', 'AO', 'ZW'); | true |
07554a3fdc91f7cf6a67be53426302e255663309 | SQL | mineiro25/bd | /tp/relacional/FUNCTIONS_GELATUM.sql | UTF-8 | 7,655 | 3.671875 | 4 | [] | no_license | SET SQL_SAFE_UPDATES =0;
SET GLOBAL log_bin_trust_function_creators = 1;
-- vai buscar o extra pretendido (caso o deseje)
DELIMITER $$
CREATE FUNCTION Gelatum.escolheExtra(nomeE VARCHAR(30)) RETURNS VARCHAR(50) NOT DETERMINISTIC
BEGIN
DECLARE resultado VARCHAR(50);
SELECT nome_extra INTO resultado
FROM Extra
WHERE nome_extra REGEXP nomeE;
RETURN resultado;
END $$
-- vai buscar o preco de um extra atraves do nome
DELIMITER $$
CREATE FUNCTION Gelatum.precoExtra(nomeE VARCHAR(20)) RETURNS VARCHAR(30) NOT DETERMINISTIC
BEGIN
DECLARE resultado VARCHAR(50);
SELECT preco_extra INTO resultado
FROM Extra
WHERE nome_extra REGEXP nomeE;
RETURN resultado;
END $$
-- vai buscar o gelado escolhido
DELIMITER $$
CREATE FUNCTION Gelatum.escolheGelado(nomeG VARCHAR(30)) RETURNS VARCHAR(50) NOT DETERMINISTIC
BEGIN
DECLARE resultado VARCHAR(50);
SELECT nome_gelado into resultado
FROM Gelado_Base
WHERE nome_gelado LIKE CONCAT('Gelado',' ', nomeG);
RETURN resultado;
END $$
-- vai buscar o preco de um gelado com um dado nome
DELIMITER $$
CREATE FUNCTION Gelatum.getPrecoG(nomeG VARCHAR(20)) RETURNS INT NOT DETERMINISTIC
BEGIN
DECLARE resultado INT;
SELECT preco_gelado into resultado
FROM Gelado_Base
WHERE nome_gelado LIKE CONCAT('Gelado',' ', nomeG);
RETURN resultado;
END $$
DELIMITER $$
-- vai retornar um tempo aleatorio
CREATE FUNCTION calcTempo() RETURNS INT NOT DETERMINISTIC
BEGIN
DECLARE tempo INT DEFAULT FLOOR(RAND() * 10) + 1;
RETURN tempo;
END $$
-- vai buscar o gelado pretendido(junção do nome do gelado base e extra
DELIMITER $$
CREATE FUNCTION Gelatum.geladoFinal(nomeG VARCHAR(30), nomeE1 VARCHAR(30), nomeE2 VARCHAR(30), nomeE3 VARCHAR(30)) RETURNS VARCHAR(100) NOT DETERMINISTIC
BEGIN
DECLARE extra VARCHAR(35) DEFAULT ' ';
DECLARE quer INT DEFAULT 1;
DECLARE geladoCompleto VARCHAR(100);
IF (quer AND nomeE1=extra AND nomeE2=extra AND nomeE3=extra) -- quer um gelado sem extras
THEN SELECT Gelatum.escolheGelado(nomeG) INTO geladoCompleto; -- vai buscar o nome do gelado
ELSE IF (quer AND nomeE1!=extra AND nomeE2!=extra AND nomeE3!=extra AND nomeE2!=nomeE3 AND nomeE1!=nomeE3 AND nomeE1!=nomeE2) -- quer um gelado com 3 extras diferentes
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE1), ', ', Gelatum.escolheExtra(nomeE2), ' e ',Gelatum.escolheExtra(nomeE3)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1=nomeE2 AND nomeE2=nomeE3 AND nomeE1!=extra) -- quer um gelado com 3 extras iguais
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE1)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1!=extra AND nomeE2=extra AND nomeE3=extra) -- quer um gelado com 1 extra
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE1)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1=extra AND nomeE2!=extra AND nomeE3=extra) -- quer um gelado com 1 extra
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE2)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1=extra AND nomeE2=extra AND nomeE3!=extra) -- quer um gelado com 1 extra
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE3)) INTO geladoCompleto;
ELSE IF (quer AND nomeE3=extra AND nomeE2!=extra AND nomeE1!=extra AND nomeE1!=nomeE2) -- quer um gelado com 2 extra diferentes
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE1), ' e ', Gelatum.escolheExtra(nomeE2)) INTO geladoCompleto;
ELSE IF (quer AND nomeE2=extra AND nomeE3!=extra AND nomeE1!=extra AND nomeE1!=nomeE3) -- quer um gelado com 2 extra diferentes
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE1), ' e ', Gelatum.escolheExtra(nomeE3)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1=extra AND nomeE2!=extra AND nomeE3!=extra AND nomeE3!=nomeE2) -- quer um gelado com 2 extra diferentes
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE2), ' e ', Gelatum.escolheExtra(nomeE3)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1=nomeE2 AND nomeE3=extra AND nomeE1!=extra) -- quer um gelado com 2 extra iguais
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE1)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1=nomeE2 AND nomeE3!=extra AND nomeE1!=extra) -- quer um gelado com 2 extra iguais
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE1)) INTO geladoCompleto;
ELSE IF (quer AND nomeE1=extra AND nomeE2=nomeE3 AND nomeE2!=extra) -- quer um gelado com 2 extra iguais
THEN SELECT CONCAT(Gelatum.escolheGelado(nomeG), ' com ',Gelatum.escolheExtra(nomeE2)) INTO geladoCompleto;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
RETURN geladoCompleto;
END $$
-- vai retornar um bool indicando se o pedido foi pago ou nao
DELIMITER $$
CREATE FUNCTION setPago() RETURNS BOOL NOT DETERMINISTIC
BEGIN
DECLARE num INT DEFAULT FLOOR(RAND() * 2);
DECLARE pago BOOL;
IF num=1
THEN SET pago=TRUE;
ELSE SET pago=FALSE;
END IF;
RETURN pago;
END $$
SELECT setPago();
-- vai retornar um bool indicando se o pedido foi recolhido
DELIMITER $$
CREATE FUNCTION setRecolhido() RETURNS BOOL NOT DETERMINISTIC
BEGIN
DECLARE num INT DEFAULT FLOOR(RAND() * 2);
DECLARE rec BOOL;
IF (setPago() AND num=1)
THEN SET rec=TRUE;
ELSE IF (setPago() AND num=0)
THEN SET rec=FALSE;
ELSE
SET rec=FALSE;
END IF;
END IF;
RETURN rec;
END $$
DELIMITER $$
CREATE FUNCTION valorTot(id_pedido INT) RETURNS DECIMAL(5,2) NOT DETERMINISTIC
BEGIN
DECLARE resultado DECIMAL(5,2);
SELECT SUM((PCG.quantidade_criacao * CG.valor_criacao) * (1 - P.desconto))
INTO resultado
FROM Pedido AS P
INNER JOIN Pedido__Criacao_Gelado AS PCG
ON P.id_pedido = PCG.id_pedido
INNER JOIN Criacao_Gelado AS CG
ON PCG.id_criacao = CG.id_criacao
WHERE (id_pedido = PCG.id_pedido);
RETURN resultado;
END $$
/*
-- DROP FUNCTION valorTot;
INSERT INTO Pedido
(id_pedido, dataP , valor_total , tempo ,pago,recolhido , desconto, id_funcionario, nif )
VALUES
(87, '1993-01-01 00:00:00', valorTot(88), 5, 1, 1, 0.2 , 1 , 2320);
INSERT INTO Pedido__Criacao_Gelado
(id_pedido, id_criacao, quantidade_criacao)
VALUES
(1101, 3, 2);
SELECT * FROM Pedido;*/
| true |
f850b5261fe6c9601b1659bd5c6501ab70128554 | SQL | solangemarcillo/discurso-del-universo | /basededatoscompleta.sql | UTF-8 | 19,097 | 3.59375 | 4 | [] | no_license | /*==============================================================*/
/* DBMS name: PostgreSQL 8 */
/* Created on: 28/06/2021 23:44:38 */
/*==============================================================*/
/*==============================================================*/
/* Table: CEMENTERIO */
/*==============================================================*/
create table CEMENTERIO (
FUN_ID INT4 not null,
NOMBRE_CEMENTERIO CHAR(30) not null,
DIRECCION_CEMENTERIO CHAR(50) not null,
TELEFONO_CEMENTERIO NUMERIC(12) not null,
EMAIL_CEMENTERIO CHAR(50) not null,
constraint PK_CEMENTERIO primary key (FUN_ID)
);
/*==============================================================*/
/* Table: DETALLEENTIERRO */
/*==============================================================*/
create table DETALLEENTIERRO (
ID_DEALLEENTIERRO INT4 not null,
F_ID INT4 not null,
EM_ID INT4 null,
OBSERVACIONES CHAR(100) not null,
FECHA_DETALLEEN DATE not null,
HORA_DETALLEEN TIME not null,
constraint PK_DETALLEENTIERRO primary key (ID_DEALLEENTIERRO)
);
/*==============================================================*/
/* Table: DETALLEMANTENIMIENTO */
/*==============================================================*/
create table DETALLEMANTENIMIENTO (
ID_TUMBA INT4 not null,
ID_MANTENIMIENTO INT4 not null,
EM_ID INT4 not null,
OBSERVACION_DETALLEMANTE CHAR(500) not null,
constraint PK_DETALLEMANTENIMIENTO primary key (ID_TUMBA, ID_MANTENIMIENTO)
);
/*==============================================================*/
/* Table: DETALLE_FACTURA */
/*==============================================================*/
create table DETALLE_FACTURA (
SER_ID INT4 not null,
FAC_ID INT4 not null,
DETALLE_CANTIDADSERVI CHAR(500) not null,
constraint PK_DETALLE_FACTURA primary key (SER_ID, FAC_ID)
);
/*==============================================================*/
/* Table: EMPLEADO */
/*==============================================================*/
create table EMPLEADO (
EM_ID INT4 not null,
FUN_ID INT4 null,
TIPO_ID INT4 null,
EM_NOMBRE TEXT not null,
EM_APELLIDO TEXT not null,
EM_DIRECCION TEXT not null,
EM_INGRESOLABORAL DATE not null,
constraint PK_EMPLEADO primary key (EM_ID)
);
/*==============================================================*/
/* Table: FACTURA */
/*==============================================================*/
create table FACTURA (
FAC_ID INT4 not null,
FUN_ID INT4 not null,
ID_FAMILIAR INT4 null,
NUMERO_FACTURA CHAR(20) not null,
IVA_FACTURA DECIMAL not null,
FECHA_FACTURA DATE not null,
SUBTOTAL MONEY not null,
TOTAL MONEY not null,
constraint PK_FACTURA primary key (FAC_ID)
);
/*==============================================================*/
/* Table: FALLECIDO */
/*==============================================================*/
create table FALLECIDO (
F_ID INT4 not null,
ID_FAMILIAR INT4 null,
NOMBRE_FALLECIDO CHAR(50) not null,
APELLIDO_FALLECIDO CHAR(50) not null,
SEXO_FALLECIDO CHAR(10) not null,
CAUSA_MUERTE CHAR(100) not null,
F_EDAD INT4 not null,
FECHA_MUERTE DATE not null,
constraint PK_FALLECIDO primary key (F_ID)
);
/*==============================================================*/
/* Table: FAMILIAR */
/*==============================================================*/
create table FAMILIAR (
ID_FAMILIAR INT4 not null,
NOMBRE_FAMILIAR CHAR(50) not null,
APELLIDO_FAMILIAR CHAR(50) not null,
DIRECCION_FAMILIAR CHAR(50) not null,
TELEFONO_FAMILIAR NUMERIC(12) not null,
PARENTESCO_FAMILIAR CHAR(20) not null,
constraint PK_FAMILIAR primary key (ID_FAMILIAR)
);
/*==============================================================*/
/* Table: MANTENIMIENTO */
/*==============================================================*/
create table MANTENIMIENTO (
ID_MANTENIMIENTO INT4 not null,
FECHA_MANTEMIENTO DATE not null,
SECTOR_MANTENIMENTO CHAR(50) not null,
HORA_MANTENIMIENTO TIME not null,
constraint PK_MANTENIMIENTO primary key (ID_MANTENIMIENTO)
);
/*==============================================================*/
/* Table: PAQUETEEXEQUIAL */
/*==============================================================*/
create table PAQUETEEXEQUIAL (
ID_PAQUETESERVICIO INT4 not null,
SER_ID INT4 null,
DESCRIPCION_PAQUETESERVICIO CHAR(500) not null,
DESCUENTO_PAQUETE MONEY not null,
PRECIO_PAQUETE MONEY not null,
constraint PK_PAQUETEEXEQUIAL primary key (ID_PAQUETESERVICIO)
);
/*==============================================================*/
/* Table: SECTOR */
/*==============================================================*/
create table SECTOR (
ID_SECTOR INT4 not null,
DESCRIPCION_SECTOR CHAR(50) not null,
N_MANZANA CHAR(50) not null,
constraint PK_SECTOR primary key (ID_SECTOR)
);
/*==============================================================*/
/* Table: SERVICIO */
/*==============================================================*/
create table SERVICIO (
SER_ID INT4 not null,
FUN_ID INT4 null,
DESCRIPCION CHAR(100) not null,
PRECIO MONEY not null,
constraint PK_SERVICIO primary key (SER_ID)
);
/*==============================================================*/
/* Table: TIPOEMPLEADO */
/*==============================================================*/
create table TIPOEMPLEADO (
TIPO_ID INT4 not null,
DESCRIPCION_TIPOEMPLEADO CHAR(50) not null,
constraint PK_TIPOEMPLEADO primary key (TIPO_ID)
);
/*==============================================================*/
/* Table: TUMBA */
/*==============================================================*/
create table TUMBA (
ID_TUMBA INT4 not null,
F_ID INT4 null,
ID_SECTOR INT4 null,
DESCRIPCION_TUMBA CHAR(50) not null,
CAPACIDAD_TUMBA NUMERIC not null,
constraint PK_TUMBA primary key (ID_TUMBA)
);
alter table DETALLEENTIERRO
add constraint FK_DETALLEE_RELATIONS_EMPLEADO foreign key (EM_ID)
references EMPLEADO (EM_ID)
on delete restrict on update restrict;
alter table DETALLEENTIERRO
add constraint FK_DETALLEE_SE_FALLECID foreign key (F_ID)
references FALLECIDO (F_ID)
on delete restrict on update restrict;
alter table DETALLEMANTENIMIENTO
add constraint FK_DETALLEM_RELATIONS_EMPLEADO foreign key (EM_ID)
references EMPLEADO (EM_ID)
on delete restrict on update restrict;
alter table DETALLEMANTENIMIENTO
add constraint FK_DETALLEM_SE_LE_DA_TUMBA foreign key (ID_TUMBA)
references TUMBA (ID_TUMBA)
on delete restrict on update restrict;
alter table DETALLEMANTENIMIENTO
add constraint FK_DETALLEM_SE_LE_DA2_MANTENIM foreign key (ID_MANTENIMIENTO)
references MANTENIMIENTO (ID_MANTENIMIENTO)
on delete restrict on update restrict;
alter table DETALLE_FACTURA
add constraint FK_DETALLE__DETALLE_F_SERVICIO foreign key (SER_ID)
references SERVICIO (SER_ID)
on delete restrict on update restrict;
alter table DETALLE_FACTURA
add constraint FK_DETALLE__DETALLE_F_FACTURA foreign key (FAC_ID)
references FACTURA (FAC_ID)
on delete restrict on update restrict;
alter table EMPLEADO
add constraint FK_EMPLEADO_CONTIENE_TIPOEMPL foreign key (TIPO_ID)
references TIPOEMPLEADO (TIPO_ID)
on delete restrict on update restrict;
alter table EMPLEADO
add constraint FK_EMPLEADO_TIENE_CEMENTER foreign key (FUN_ID)
references CEMENTERIO (FUN_ID)
on delete restrict on update restrict;
alter table FACTURA
add constraint FK_FACTURA_GENERA_CEMENTER foreign key (FUN_ID)
references CEMENTERIO (FUN_ID)
on delete restrict on update restrict;
alter table FACTURA
add constraint FK_FACTURA___GENERA_FAMILIAR foreign key (ID_FAMILIAR)
references FAMILIAR (ID_FAMILIAR)
on delete restrict on update restrict;
alter table FALLECIDO
add constraint FK_FALLECID_TIENE4_FAMILIAR foreign key (ID_FAMILIAR)
references FAMILIAR (ID_FAMILIAR)
on delete restrict on update restrict;
alter table PAQUETEEXEQUIAL
add constraint FK_PAQUETEE_RELATIONS_SERVICIO foreign key (SER_ID)
references SERVICIO (SER_ID)
on delete restrict on update restrict;
alter table SERVICIO
add constraint FK_SERVICIO_RELATIONS_CEMENTER foreign key (FUN_ID)
references CEMENTERIO (FUN_ID)
on delete restrict on update restrict;
alter table TUMBA
add constraint FK_TUMBA_PERTENECE_FALLECID foreign key (F_ID)
references FALLECIDO (F_ID)
on delete restrict on update restrict;
alter table TUMBA
add constraint FK_TUMBA__TIENE_SECTOR foreign key (ID_SECTOR)
references SECTOR (ID_SECTOR)
on delete restrict on update restrict;
/*CEMENTERIO */
INSERT INTO CEMENTERIO VALUES (1,'CIELO AZUL','JOCAY',0987654321,'cieloazul@gmail.com' );
/*TIPOEMPLEADO*/
INSERT INTO TIPOEMPLEADO VALUES(1,'ADMINISTRATIVO');
INSERT INTO TIPOEMPLEADO VALUES(2,'JARDINEROS');
INSERT INTO TIPOEMPLEADO VALUES(3,'SEPULTADORES');
INSERT INTO TIPOEMPLEADO VALUES(4,'GUARDIAS');
INSERT INTO TIPOEMPLEADO VALUES(5,'LIMPIEZA Y CUIDADO DE TUMBAS');
/*EMPLEADO*/
INSERT INTO EMPLEADO VALUES (1,1,1,'JOSE','PEREZ','CUBA','10/05/2021');
INSERT INTO EMPLEADO VALUES (2,1,2,'ANTHONY','MOREIRA','LA BAHIA','1/04/2021');
INSERT INTO EMPLEADO VALUES (3,1,3,'LUIS','VELEZ','JOCAY','08/05/2021');
INSERT INTO EMPLEADO VALUES (4,1,4,'JUAN','ARCENTALES','LA AURORA','09/06/2021');
INSERT INTO EMPLEADO VALUES (5,1,5,'DYLAN','RODRIGUEZ','SAN PEDRO','15/06/2021');
/*FAMILIAR*/
INSERT INTO FAMILIAR VALUES (1, 'PAUL','CORRALES','SAN PEDRO',0987654321,'TIO');
INSERT INTO FAMILIAR VALUES (2, 'KARLA','MORA','LA AURORA',0987654321,'TIA');
INSERT INTO FAMILIAR VALUES (3, 'CORINA','ALAY','JOCAY',0987654321,'HERMANA');
INSERT INTO FAMILIAR VALUES (4, 'ALEJANDRO','ALCIVAR','ELEGOLE',0987654321,'HERMANO');
INSERT INTO FAMILIAR VALUES (5, 'RICKY','RIVADENEIRA','SAN PATRICIO',0987654321,'HERMANO');
INSERT INTO FAMILIAR VALUES (6, 'IRINA','GONZALES','LOS ELECTRICOS',0987654321,'TIA');
INSERT INTO FAMILIAR VALUES (7, 'ELIANA','PARRALES','LOS CEIBOS',0987654321,'ABUELA');
INSERT INTO FAMILIAR VALUES (8, 'SAUL','PEREZ','PROAÑO',0987654321,'ABUELO');
INSERT INTO FAMILIAR VALUES (9, 'FELIPE','CAICEDO','PALMAR',0987654321,'TIO');
INSERT INTO FAMILIAR VALUES (10, 'ROBERTO','CATAGUA','LA PRADERA',0987784321,'PRIMO');
/*FACTURA*/
INSERT INTO FACTURA VALUES (1,1,1,'RE45622',12,'10/6/2021',500,500);
INSERT INTO FACTURA VALUES (2,1,2,'RE45622',12,'10/6/2021',600,600);
INSERT INTO FACTURA VALUES (3,1,3,'RE45622',12,'10/6/2021',400,400);
INSERT INTO FACTURA VALUES (4,1,4,'RE45622',12,'10/6/2021',1000,1000);
INSERT INTO FACTURA VALUES (5,1,5,'RE45622',12,'10/6/2021',500,500);
INSERT INTO FACTURA VALUES (6,1,6,'RE45622',12,'10/6/2021',700,700);
INSERT INTO FACTURA VALUES (7,1,7,'RE45622',12,'10/6/2021',600,600);
INSERT INTO FACTURA VALUES (8,1,8,'RE45622',12,'10/6/2021',500,500);
SELECT * FROM FALLECIDO;
/*FALLECIDO*/
INSERT INTO FALLECIDO VALUES (1,1,'JUAN','CORRALES','MASCULINO','INFARTO',14,'10/06/2021');
INSERT INTO FALLECIDO VALUES (2,2,'NICOLE','MORA','FEMENINO','DERRAME CEREBRAL',80,'15/05/2021');
INSERT INTO FALLECIDO VALUES (3,3,'SERGIO','ALAY','MASCULINO','INFARTO',17,'07/06/2021');
INSERT INTO FALLECIDO VALUES (4,4,'JAIME','ALCIVAR','MASCULINO','INFARTO',44,'10/06/2021');
INSERT INTO FALLECIDO VALUES (5,5,'ARTURO','RIVADENEIRA','MASCULINO','INFARTO',05,'10/06/2021');
INSERT INTO FALLECIDO VALUES (6,6,'CAROLINA','GONZALES','FEMENINO','CANCER DE SENO',85,'10/06/2021');
INSERT INTO FALLECIDO VALUES (7,7,'ALEX','PARRALES','MASCULINO','INFARTO',08,'10/06/2021');
INSERT INTO FALLECIDO VALUES (8,8,'NATASHA','PEREZ','FEMENINO','CANCER DE UTERO',40,'10/06/2021');
INSERT INTO FALLECIDO VALUES (9,9,'ABEL','CAICEDO','MASCULINO','INFARTO',15,'12/06/2021');
INSERT INTO FALLECIDO VALUES (10,10,'JHON','VERA','MASCULINO','INFARTO',03,'10/01/2021');
/*SERVCIO*/
INSERT INTO SERVICIO VALUES (1,1,'ACOMPAÑAMIENTO CON MUSICA',200);
INSERT INTO SERVICIO VALUES (2,1,'FLORALES',100);
INSERT INTO SERVICIO VALUES (3,1,'CREMACION',200);
INSERT INTO SERVICIO VALUES (4,1,'CARROZA FUNEBRE',300);
INSERT INTO SERVICIO VALUES (5,1,'REFRIGERACION',200);
INSERT INTO SERVICIO VALUES (6,1,'TRANSPORTE',150);
INSERT INTO SERVICIO VALUES (7,1,'COFRES MORTUORIOS',500);
INSERT INTO SERVICIO VALUES (8,1,'MAQUILLAJES',200);
INSERT INTO SERVICIO VALUES (9,1,'EMBALSAMIENTO',600);
/*PAQUETE EXEQUIAL*/
INSERT INTO PAQUETEEXEQUIAL VALUES (1,1,'BASICO',100,800);
INSERT INTO PAQUETEEXEQUIAL VALUES (2,2,'INTERMEDIO',200,1000);
INSERT INTO PAQUETEEXEQUIAL VALUES (3,3,'COMPLETO',250,1500);
INSERT INTO PAQUETEEXEQUIAL VALUES (4,4,'DIAMANTE',300,2000);
/*DETALLE FACTURA
INSERT INTO DETALLE_FACTURA VALUES (1,1'SE ELEIGIO UN PAQUETE BASICO');
******/
INSERT INTO DETALLE_FACTURA VALUES (2,1,'SE ELEIGIO UN PAQUETE BASICO');
INSERT INTO DETALLE_FACTURA VALUES (2,2,'SE ELEIGIO UN PAQUETE BASICO');
INSERT INTO DETALLE_FACTURA VALUES (2,3,'SE ELEIGIO UN PAQUETE BASICO');
INSERT INTO DETALLE_FACTURA VALUES (2,4,'SE ELEIGIO UN PAQUETE BASICO');
/*SECTOR*/
INSERT INTO SECTOR VALUES (1,'PANTEON','MANZANA 9');
INSERT INTO SECTOR VALUES (2,'NICHO','MANZANA 10');
INSERT INTO SECTOR VALUES (3,'PANTEON','MANZANA 11');
INSERT INTO SECTOR VALUES (4,'FOSA COMUN','MANZANA 12');
INSERT INTO SECTOR VALUES (5,'PANTEON','MANZANA 17');
INSERT INTO SECTOR VALUES (6,'PANTEON','MANZANA 18');
INSERT INTO SECTOR VALUES (7,'PANTEON','MANZANA 7');
INSERT INTO SECTOR VALUES (8,'NICHO','MANZANA 25');
INSERT INTO SECTOR VALUES (9,'PANTEON','MANZANA 11');
INSERT INTO SECTOR VALUES (10,'PANTEON','MANZANA 13');
INSERT INTO SECTOR VALUES (11,'PANTEON','MANZANA 1');
INSERT INTO SECTOR VALUES (12,'NICHO','MANZANA 2');
/*TUMBA*/
INSERT INTO TUMBA VALUES (1,1,1,'TUMBA REMODELADA',4);
INSERT INTO TUMBA VALUES (2,2,2,'TUMBA REMODELADA',2);
INSERT INTO TUMBA VALUES (3,3,3,'TUMBA REMODELADA',8);
INSERT INTO TUMBA VALUES (4,4,4,'TUMBA REMODELADA',20);
INSERT INTO TUMBA VALUES (5,5,5,'TUMBA REMODELADA',20);
INSERT INTO TUMBA VALUES (6,6,6,'TUMBA REMODELADA',20);
INSERT INTO TUMBA VALUES (7,7,7,'TUMBA REMODELADA',20);
INSERT INTO TUMBA VALUES (8,8,9,'TUMBA REMODELADA',20);
/*DETALLE ENTIERRO*/
INSERT INTO DETALLEENTIERRO VALUES(1,1,3,'CEREMONIA SENCILLA','10/05/2021','12:30:10');
INSERT INTO DETALLEENTIERRO VALUES(2,2,3,'CEREMONIA COMPLETA','14/06/2021','10:50:11');
INSERT INTO DETALLEENTIERRO VALUES(3,3,3,'CEREMONIA COMPLETA','15/04/2021','12:30:10');
INSERT INTO DETALLEENTIERRO VALUES(4,4,3,'CEREMONIA SENCILLA','12/03/2021','12:30:10');
INSERT INTO DETALLEENTIERRO VALUES(5,5,3,'CEREMONIA SENCILLA','11/06/2021','09:20:25');
INSERT INTO DETALLEENTIERRO VALUES(6,6,3,'CEREMONIA COMPLETA','10/02/2021','14:00:00');
/*MANTENIMEINTO*/
INSERT INTO MANTENIMIENTO VALUES(1,'25/05/2021','MANZANA 9','10:00:00');
INSERT INTO MANTENIMIENTO VALUES(2,'28/06/2021','MANZANA 10','11:00:00');
INSERT INTO MANTENIMIENTO VALUES(3,'25/04/2021','MANZANA 11','11:00:00');
INSERT INTO MANTENIMIENTO VALUES(4,'05/06/2021','MANZANA 12','12:00:00');
INSERT INTO MANTENIMIENTO VALUES(5,'01/04/2021','MANZANA 12','13:00:00');
/*DETALLE MANTENIMIENTO*/
INSERT INTO DETALLEMANTENIMIENTO VALUES (1,1,5,'SE PINTO LA VOBEDA EN LA TUMBA CON CRUZ DORADA');
INSERT INTO DETALLEMANTENIMIENTO VALUES (2,2,5,'SE LE REPARO EL CERCADO AL PANTEON');
INSERT INTO DETALLEMANTENIMIENTO VALUES (3,3,5,'CORTE DE MALEZA EN EL NICHO');
INSERT INTO DETALLEMANTENIMIENTO VALUES (4,4,5,'SE HIZO LIMPIEZA A LOS ALREDEDORES ');
/*consulta*/
/*Cuantos cuerpos han sido enterrados y cuales son lo de genero femenino?*/
SELECT
OBSERVACIONES AS OBSERVACION,
SEXO_FALLECIDO AS SEXO_FALLECIDO,
COUNT(SEXO_FALLECIDO)as CANTIDAD
FROM
PUBLIC.DETALLEENTIERRO
INNER JOIN PUBLIC.FALLECIDO ON FALLECIDO.F_ID = DETALLEENTIERRO.F_ID
WHERE
(SEXO_FALLECIDO like '%F%') OR (SEXO_FALLECIDO like '%M%')
GROUP BY
OBSERVACIONES,SEXO_FALLECIDO
ORDER BY
OBSERVACIONES ASC;
/*Cuantos clientes cuentan con panteón ?*/
SELECT
DESCRIPCION_TUMBA AS DESCRIPCION_TUMBA,
DESCRIPCION_SECTOR AS TIPO_TUMBA,
COUNT(DESCRIPCION_SECTOR)as CLIENTE_CON_PANTEON
FROM
PUBLIC.TUMBA
INNER JOIN PUBLIC.SECTOR ON SECTOR.ID_SECTOR = TUMBA.ID_TUMBA
WHERE
SECTOR.DESCRIPCION_SECTOR = 'PANTEON'
GROUP BY
DESCRIPCION_TUMBA,DESCRIPCION_SECTOR;
/*Cuantos fallecidos son menores de edad ?*/
SELECT
SEXO_FALLECIDO AS SEXO_FALLECIDO,
COUNT(SEXO_FALLECIDO)as FALLECIDOS_MENORES_DE_EDAD
FROM
PUBLIC.DETALLEENTIERRO
INNER JOIN PUBLIC.FALLECIDO ON FALLECIDO.F_ID = DETALLEENTIERRO.F_ID
WHERE
(SEXO_FALLECIDO like '%F%') OR (SEXO_FALLECIDO like '%M%') OR FALLECIDO.F_EDAD<18
GROUP BY
SEXO_FALLECIDO;
/*MANTENIMIENTOS REALIZADOS POR LOS EMPLEADOS*/
SELECT
EM_NOMBRE AS NOMBRE_EMPLEADO,
EM_APELLIDO AS APELLIADO_EMPLEADO,
OBSERVACION_DETALLEMANTE AS MANTENIMIENTO
FROM DETALLEMANTENIMIENTO
INNER JOIN EMPLEADO ON DETALLEMANTENIMIENTO.ID_MANTENIMIENTO = EMPLEADO.EM_ID | true |
065b4962675c5b91e204a744cd0eee26d7ba7ff6 | SQL | vsolv/BigFin | /Bigflow/DB/SPS/ATMA/sp_Atma_Pending_To_Approval_Set.sql | UTF-8 | 41,693 | 2.859375 | 3 | [] | no_license | CREATE PROCEDURE `sp_Atma_Pending_To_Approval_Set`(in li_Action varchar(30),
in lj_filter json,in lj_classification json,out Message varchar(1000))
sp_Atma_Pending_To_Approval_Set:BEGIN#####MOVE TO MST TABLE SP
declare Query_Insert varchar(10000);
Declare countRow varchar(6000);
declare Query_Update varchar(10000);
declare Query_Update1 varchar(10000);
declare Query_delete varchar(1000);
declare Query_Value varchar(1000);
declare Query_Column varchar(1000);
declare new_insert_gid varchar(1000);
Declare v_director_gid,v_director_partnergid,v_director_name,v_director_isactive,v_director_isremoved,v_create_by,v_entity_gid,v_main_director_gid varchar(128) ;
DECLARE finished INTEGER DEFAULT 0;
Declare p_partnerbranch_gid,p_partnerbranch_gstno,p_partnerbranch_panno,p_partnerbranch_addressgid,p_partnerbranch_contactgid,p_partnerbranch_name
,p_partnerbranch_creditperiod,p_partnerbranch_creditlimit,p_partnerbranch_paymentterms,p_partnerbranch_code
varchar(150);
DECLARE finished1 INTEGER DEFAULT 0;
Declare a_address_gid,a_address_ref_code,a_address_1, a_address_2, a_address_3, a_address_pincode,
a_address_district_gid,a_address_city_gid, a_address_state_gid, a_entity_gid,
a_create_by,a_update_by,a_main_address_gid varchar(150);
Declare c_contact_gid,c_Contact_ref_gid,c_Contact_reftable_gid,
c_contact_reftablecode,c_Contact_contacttype_gid,
c_Contact_personname,c_Contact_designation_gid,c_Contact_landline,
c_Contact_landline2,c_Contact_mobileno,
c_Contact_mobileno2,c_Contact_email,c_Contact_DOB,c_Contact_WD,
c_entity_gid,c_create_by,c_update_by,c_main_contact_gid varchar(150);
DECLARE finished_partnerproduct INTEGER DEFAULT 0;
declare m_mpartnerproduct_product_gid,m_mpartnerproduct_unitprice,
m_mpartnerproduct_packingprice,m_mpartnerproduct_validfrom,m_mpartnerproduct_validto,
m_mpartnerproduct_deliverydays,m_mpartnerproduct_capacitypw,m_mpartnerproduct_dts varchar(150);
DECLARE finished_supplierpayment INTEGER DEFAULT 0;
Declare p_payment_gid,p_payment_partnergid,p_payment_partnerbranchgid,p_payment_paymodegid,p_payment_bankgid,p_payment_bankbranchgid,p_payment_acctype,p_payment_accnumber,
p_payment_benificiaryname,p_entity_gid,p_create_by varchar(150);
Declare errno int;
Declare msg varchar(1000);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET CURRENT DIAGNOSTICS CONDITION 1 errno = MYSQL_ERRNO, msg = MESSAGE_TEXT;
set Message = concat(errno , msg);
ROLLBACK;
END;
IF li_Action='Pending_To_Approval_Insert' then
START TRANSACTION;
select JSON_LENGTH(lj_filter,'$') into @lj_filter_json_count;
select JSON_LENGTH(lj_classification,'$') into @lj_classification_json_count;
if @lj_filter_json_count = 0 or @lj_filter_json_count is null then
set Message = '1.No Data In filter Json. ';
leave sp_Atma_Pending_To_Approval_Set;
End if;
select JSON_UNQUOTE(JSON_EXTRACT(lj_filter,CONCAT('$.Partner_Gid'))) into @Partner_Gid;
select JSON_UNQUOTE(JSON_EXTRACT(lj_filter,CONCAT('$.Partner_Status'))) into @Partner_Status;
select JSON_UNQUOTE(JSON_EXTRACT(lj_classification,CONCAT('$.Entity_Gid'))) into @Entity_Gid;
select JSON_UNQUOTE(JSON_EXTRACT(lj_classification,CONCAT('$.Update_By'))) into @Update_By;
/*
###renewal process
select partner_requestfor from atma_tmp_tpartner where
partner_gid=@Partner_Gid and partner_isactive='Y' into @requestfor;
#select @requestfor;
if @requestfor='RENEWAL PROCESS' then
SET SQL_SAFE_UPDATES = 0;
update atma_tmp_tpartner set partner_status= @Partner_Status
where partner_gid=@Partner_Gid ;
set Message='SUCCESS';
commit;
leave sp_Atma_Pending_To_Approval_Set;
End if;
###renewal end
*/
if @Partner_Gid = '' or @Partner_Gid is null or @Partner_Gid=0 then
set Message = '1.Partner is not provided';
leave sp_Atma_Pending_To_Approval_Set;
End if;
if @partner_status = '' or @partner_status is null then
set Message = '1.Partner Status Is Not Provided';
leave sp_Atma_Pending_To_Approval_Set;
End if;
set @Pr_Gid='';
select partner_gid from atma_tmp_tpartner where partner_gid=@Partner_Gid into @Pr_Gid;
if @Pr_Gid = '' or @Pr_Gid is null or @Pr_Gid=0 then
set Message = '1.2 - Partner is not available(Temp)';
leave sp_Atma_Pending_To_Approval_Set;
End if;
select main_partner_gid from atma_tmp_tpartner where partner_gid=@Partner_Gid into @Main_partner_gid;
SELECT partner_addressgid,partner_contactgid into @partneraddressgid,@partnercontactgid
FROM atma_tmp_tpartner where Partner_Gid=@Partner_Gid;
#####start address and contact
select address_gid,address_ref_code,address_1,address_2,address_3,address_pincode,
address_district_gid,address_city_gid,address_state_gid,entity_gid,
create_by,update_by,main_address_gid
into a_address_gid,a_address_ref_code,a_address_1,a_address_2,a_address_3,
a_address_pincode,a_address_district_gid,a_address_city_gid,
a_address_state_gid,a_entity_gid,a_create_by ,a_update_by,a_main_address_gid
from atma_tmp_mst_taddress where address_gid=@partneraddressgid ;
#select a_main_address_gid;
if a_main_address_gid = '' or a_main_address_gid is null or a_main_address_gid=0 then
set Query_Column='';
set Query_Value ='';
if a_address_1 is not null and a_address_1 <> '' then
set Query_Column = concat(Query_Column,',address_1 ');
set Query_Value=concat(Query_Value,', ''',a_address_1,''' ');
end if;
if a_address_2 is not null and a_address_2 <> '' then
set Query_Column = concat(Query_Column,',address_2 ');
set Query_Value=concat(Query_Value,', ''',a_address_2,''' ');
end if;
if a_address_3 is not null and a_address_3 <> '' then
set Query_Column = concat(Query_Column,',address_3 ');
set Query_Value=concat(Query_Value,', ''',a_address_3,''' ');
end if;
if a_address_pincode is not null and a_address_pincode <> '' then
set Query_Column = concat(Query_Column,',address_pincode ');
set Query_Value=concat(Query_Value,', ',a_address_pincode,' ');
end if;
if a_address_city_gid is not null and a_address_city_gid <> '' then
set Query_Column = concat(Query_Column,',address_city_gid ');
set Query_Value=concat(Query_Value,', ',a_address_city_gid,' ');
end if;
if a_address_state_gid is not null and a_address_state_gid <> '' then
set Query_Column = concat(Query_Column,',address_state_gid ');
set Query_Value=concat(Query_Value,', ',a_address_state_gid,' ');
end if;
#select Query_Column,Query_Value;
set Query_Update = concat('INSERT INTO gal_mst_taddress
( address_ref_code,address_district_gid,entity_gid, create_by, create_date ',Query_Column,')
values (''',a_address_ref_code,''',',a_address_district_gid,',
',a_entity_gid,',',a_create_by,',''',Now(),'''
',Query_Value,')'
);
else
set Query_Update = concat('Update gal_mst_taddress
set address_1 = ''',ifnull(a_address_1,''),''',
address_2 = ''',ifnull(a_address_2,''),''',
address_3 = ''',ifnull(a_address_3,''),''',
address_pincode =''',ifnull(a_address_pincode,''),''',
address_city_gid = ',ifnull(a_address_city_gid,0),',
address_state_gid = ',ifnull(a_address_state_gid,0),',
address_district_gid = ',a_address_district_gid,',
update_date = CURRENT_TIMESTAMP,
Update_By = ',@Update_By,'
where address_gid=',a_main_address_gid,' ');
# select Query_Update;
end if;
#select Query_Update,'ADD';
set @Insert_query = Query_Update;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
else
set Message = 'FAILED-1.4';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
if a_main_address_gid = '' or a_main_address_gid is null or a_main_address_gid=0 then
set @Address_Gid='';
select last_insert_id() into @Address_Gid;
else
set @Address_Gid=a_main_address_gid;
end if;
SET SQL_SAFE_UPDATES = 0;
set Query_delete=concat('DELETE FROM atma_tmp_mst_taddress WHERE address_gid=',a_address_gid,'');
set @Insert_query = Query_delete;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
#select 'partner add -address -success';
else
set Message = ' FAILED-1.5';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
select contact_gid,Contact_ref_gid,Contact_reftable_gid,
contact_reftablecode,Contact_contacttype_gid,
Contact_personname,Contact_designation_gid,Contact_landline,
Contact_landline2,Contact_mobileno,
Contact_mobileno2,Contact_email,Contact_DOB,Contact_WD,
entity_gid,create_by,update_by,main_contact_gid
into c_contact_gid,c_Contact_ref_gid,c_Contact_reftable_gid,
c_contact_reftablecode,c_Contact_contacttype_gid,
c_Contact_personname,c_Contact_designation_gid,c_Contact_landline,
c_Contact_landline2,c_Contact_mobileno,
c_Contact_mobileno2,c_Contact_email,c_Contact_DOB,c_Contact_WD,
c_entity_gid,c_create_by,c_update_by,c_main_contact_gid
from atma_tmp_mst_tcontact
where contact_gid=@partnercontactgid ;
if c_main_contact_gid = '' or c_main_contact_gid is null or c_main_contact_gid=0 then
set Query_Column='';
set Query_Value ='';
if c_Contact_personname is not null and c_Contact_personname<>'' then
set Query_Column = concat(Query_Column,',Contact_personname');
set Query_Value=concat(Query_Value,', ''',c_Contact_personname,''' ');
end if;
if c_Contact_landline is not null and c_Contact_landline <>'' then
set Query_Column = concat(Query_Column,',Contact_landline');
set Query_Value=concat(Query_Value,', ',c_Contact_landline,' ');
end if;
if c_Contact_landline2 is not null and c_Contact_landline2 <>'' then
set Query_Column = concat(Query_Column,',Contact_landline2');
set Query_Value=concat(Query_Value,', ',c_Contact_landline2,' ');
end if;
if c_Contact_mobileno is not null and c_Contact_mobileno <>'' then
set Query_Column = concat(Query_Column,',Contact_mobileno');
set Query_Value=concat(Query_Value,', ',c_Contact_mobileno,' ');
end if;
if c_Contact_mobileno2 is not null and c_Contact_mobileno2 <>'' then
set Query_Column = concat(Query_Column,',Contact_mobileno2');
set Query_Value=concat(Query_Value,', ',c_Contact_mobileno2,' ');
end if;
if c_Contact_email is not null and c_Contact_email <>'' then
set Query_Column = concat(Query_Column,',Contact_email');
set Query_Value=concat(Query_Value,', ''',c_Contact_email,''' ');
end if;
if c_Contact_DOB is not null and c_Contact_DOB <>'' then
set Query_Column = concat(Query_Column,',Contact_DOB');
set Query_Value=concat(Query_Value,', ''',c_Contact_DOB,''' ');
end if;
if c_Contact_WD is not null and c_Contact_WD <>'' then
set Query_Column = concat(Query_Column,',Contact_WD');
set Query_Value=concat(Query_Value,', ''',c_Contact_WD,''' ');
end if;
set Query_Update = concat('INSERT INTO gal_mst_tcontact
( Contact_ref_gid, Contact_reftable_gid, contact_reftablecode,
Contact_contacttype_gid, Contact_designation_gid,
entity_gid, create_by, create_date ',Query_Column,')
values (',c_Contact_ref_gid,',',c_Contact_reftable_gid,',
''',c_contact_reftablecode,''',',c_Contact_contacttype_gid,',
',c_Contact_designation_gid,',',c_entity_gid,',',c_create_by,' ,
''',Now(),''' ',Query_Value,')'
);
else
set Query_Update1='';
if c_Contact_DOB is null then
set Query_Update1 = concat('Contact_DOB = null,');
else
set Query_Update1 = concat('Contact_DOB = ''',c_Contact_DOB,''',');
end if;
if c_Contact_WD is null then
set Query_Update1 = concat(Query_Update1,'Contact_WD = null,');
else
set Query_Update1 = concat(Query_Update1,'Contact_WD = ''',c_Contact_WD,''',');
end if;
#Contact_DOB = ''',ifnull(c_Contact_DOB,'0000-00-00 00:00:00'),''',
# Contact_WD = ''',ifnull(C_Contact_WD,'0000-00-00 00:00:00'),''',
set Query_Update = concat(' Update gal_mst_tcontact
set Contact_contacttype_gid = ',c_Contact_contacttype_gid,',
Contact_designation_gid = ',c_Contact_designation_gid,',
Contact_personname = ''',ifnull(c_Contact_personname,''),''',
Contact_landline = ''',ifnull(c_Contact_landline,''),''',
Contact_landline2 = ''',ifnull(c_Contact_landline2,''),''',
Contact_mobileno = ''',ifnull(c_Contact_mobileno,''),''',
Contact_mobileno2 = ''',ifnull(c_Contact_mobileno2,''),''',
Contact_email = ''',ifnull(c_Contact_email,''),''',
',Query_Update1,'
Update_By=',@Update_By,',
update_date = ''',now(),'''
Where contact_gid = ',c_main_contact_gid,'
');
#select Query_Update;
end if;
#select Query_Update,'CON';
set @Insert_query = Query_Update;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
#select 'partner add -contact -success';
else
set Message = ' FAILED_BR';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
SET SQL_SAFE_UPDATES = 0;
set Query_delete=concat('DELETE FROM atma_tmp_mst_tcontact
WHERE contact_gid=',c_contact_gid,'');
#select Query_delete,c_contact_gid;
set @Insert_query = Query_delete;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
else
set Message = ' FAILED_PARTNER_C deletion';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
set @Contact_Gid='';
select last_insert_id() into @Contact_Gid;
SELECT partner_code,partner_name,partner_addressgid,partner_contactgid,partner_contractdatefrom,partner_contractdateto
into @partner_code,@partner_name,@partner_addressgid,@partner_contactgid,@partner_contractdatefrom,@partner_contractdateto
FROM atma_tmp_tpartner
where Partner_Gid=@Partner_Gid;
if @Main_partner_gid = '' or @Main_partner_gid is null or @Main_partner_gid=0 then
set Query_Insert='';
set Query_Insert=concat('INSERT INTO atma_mst_tpartner (partner_code,partner_name,partner_panno,partner_compregno,
partner_group,partner_custcategorygid,partner_compositevendor,
partner_Classification,partner_type,partner_web,partner_activecontract,
partner_reason_no_contract,partner_contractdatefrom,
partner_contractdateto,partner_aproxspend,partner_actualspend,
partner_noofdir,partner_orgtype,partner_renewaldate,partner_remarks,
partner_requestfor,partner_status,partner_mainstatus,partner_renewdate,
partner_rmname,partner_addressgid,partner_contactgid,
partner_isactive,partner_isremoved,entity_gid,
create_by,create_date,update_by,update_date)
SELECT partner_code,partner_name,partner_panno,partner_compregno,partner_group,
partner_custcategorygid,partner_compositevendor,
partner_Classification,partner_type,partner_web,partner_activecontract,
partner_reason_no_contract,partner_contractdatefrom,
partner_contractdateto,partner_aproxspend,partner_actualspend,partner_noofdir,
partner_orgtype,partner_renewaldate,partner_remarks,
partner_requestfor,''',@Partner_Status,''',''APPROVED'',partner_renewdate,
partner_rmname,',@Address_Gid,',',@Contact_Gid,',
partner_isactive,partner_isremoved,entity_gid,
create_by,create_date,update_by,update_date FROM atma_tmp_tpartner
where Partner_Gid=',@Partner_Gid,' ');
select Query_Insert,'partner';
set @Insert_query = Query_Insert;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
#select 'partner add -success';
else
set Message = 'FAILED PAR';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
set @NEWPartnergid='';
select LAST_INSERT_ID() into @NEWPartnergid;
#select @NEWPartnergid;
set Query_Insert=concat('INSERT INTO atma_mst_tdirectors (director_partnergid,director_name,director_isactive,
director_isremoved,entity_gid,create_by,create_date,update_by,update_date) SELECT
',@NEWPartnergid,',director_name,director_isactive,director_isremoved,entity_gid,create_by,
create_date,update_by,update_date FROM atma_tmp_mst_tdirectors
where director_partnergid=',@Partner_Gid,' ');
set @Insert_query = Query_Insert;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
#select 'partner add -director -success';
else
set Message = 'FAILED DIR';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
SET SQL_SAFE_UPDATES = 0;
set Query_delete=concat('DELETE FROM atma_tmp_mst_tdirectors WHERE director_partnergid=',@Partner_Gid,'');
set @Insert_query = Query_delete;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'DELETED';
else
set Message = ' FAILED_DIR deletion';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
else
set Query_Update = concat('Update atma_mst_tpartner as A, atma_tmp_tpartner as B set
A.partner_code=B.partner_code,A.partner_name=B.partner_name,
A.partner_panno=B.partner_panno,A.partner_compregno=B.partner_compregno,
A.partner_group=B.partner_group,A.partner_custcategorygid=B.partner_custcategorygid,
A.partner_compositevendor=B.partner_compositevendor,
A.partner_Classification=B.partner_Classification,
A.partner_type=B.partner_type,A.partner_web=B.partner_web,
A.partner_activecontract=B.partner_activecontract,
A.partner_reason_no_contract=B.partner_reason_no_contract,
A.partner_contractdatefrom=B.partner_contractdatefrom,
A.partner_contractdateto=B.partner_contractdateto,
A.partner_aproxspend=B.partner_aproxspend,
A.partner_actualspend=B.partner_actualspend,
A.partner_noofdir=B.partner_noofdir,
A.partner_orgtype=B.partner_orgtype,
A.partner_remarks=B.partner_remarks,
A.partner_requestfor=B.partner_requestfor,
A.partner_status=''',@Partner_Status,''',
A.partner_mainstatus=''APPROVED'',
A.partner_renewdate=B.partner_renewdate,
A.partner_rmname=B.partner_rmname,A.partner_isactive=B.partner_isactive,
A.partner_isremoved=B.partner_isremoved,A.entity_gid=B.entity_gid,
A.create_by=B.create_by,A.create_date=B.create_date,A.update_by=',@Update_By,',A.update_date=B.update_date where
A.partner_gid= B.main_partner_gid and B.main_partner_gid=',@Main_partner_gid,'');
#select Query_Update;
set @Insert_query = Query_Update;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
else
set Message = 'FAILED UPDATE_PAR1';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
BEGIN
Declare Cursor_atma CURSOR FOR
select director_gid,director_partnergid,director_name,director_isactive,director_isremoved,create_by,entity_gid,
main_director_gid from atma_tmp_mst_tdirectors where director_partnergid=@Partner_Gid ;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;
OPEN Cursor_atma;
atma_looop:loop
fetch Cursor_atma into v_director_gid,v_director_partnergid,v_director_name,v_director_isactive,v_director_isremoved,v_create_by,v_entity_gid,v_main_director_gid;
if finished = 1 then
leave atma_looop;
End if;
if v_main_director_gid = '' or v_main_director_gid is null or v_main_director_gid=0 then
set Query_Update = concat('INSERT INTO atma_mst_tdirectors (director_partnergid,director_name,director_isactive,
director_isremoved,create_by,entity_gid)values (',@Main_partner_gid,',
''',v_director_name,''',''',v_director_isactive,''',''',v_director_isremoved,''',',v_create_by,',',v_entity_gid,')');
#select Query_Update;
SET SQL_SAFE_UPDATES = 0;
set Query_delete=concat('DELETE FROM atma_tmp_mst_tdirectors WHERE director_gid=',v_director_gid,'');
set @Insert_query = Query_delete;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'DELETED';
else
set Message = ' FAILED_DIR DELETION';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
else
SET SQL_SAFE_UPDATES = 0;
set Query_Update = concat('Update atma_mst_tdirectors set
director_name=''',v_director_name,''',
director_isactive=''',v_director_isactive,''',
director_isremoved=''',v_director_isremoved,''',
update_by=',@Update_By,',
update_date=''',Now(),''',
entity_gid=',v_entity_gid,' where
director_gid=',v_main_director_gid,'');
#select Query_Update,'direct';
SET SQL_SAFE_UPDATES = 0;
set Query_delete=concat('DELETE FROM atma_tmp_mst_tdirectors WHERE director_gid=',v_director_gid,'');
set @Insert_query = Query_delete;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'DELETED';
else
set Message = ' FAILED_DIR DELETION';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
end if;
set @Insert_query = Query_Update;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
else
set Message = 'UPDATE FAILED PARTNER_DIR';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
End loop atma_looop;
close Cursor_atma;
end;
end if;
select main_partner_gid from atma_tmp_tpartner where partner_gid=@Partner_Gid into @maingid;
if @maingid > 0 then
set new_insert_gid=@maingid;
else
set new_insert_gid=@NEWPartnergid;
end if;
#select new_insert_gid;
call sp_Atma_Pending_To_Approval_profile_Set('insert',lj_filter,new_insert_gid,lj_classification,@Message);
select @Message into @Out_Message_profile;
if @Out_Message_profile <> 'SUCCESS' then
#select @Out_Message_profile;
set Message = @Out_Message_profile;
rollback;
leave sp_Atma_Pending_To_Approval_Set;
else
select 'profile_Set -success';
End if;
call sp_Atma_Pending_To_Approval_PR_Client_Set(lj_filter,new_insert_gid,lj_classification,@Message);
select @Message into @Out_Message_Client;
#select @Out_Message_Client;
if @Out_Message_Client <> 'SUCCESS' then
set Message = @Out_Message_Client;
rollback;
leave sp_Atma_Pending_To_Approval_Set;
else
select 'Client_Set -success';
End if;
call sp_Atma_Pending_To_Approval_PR_Product_Set(lj_filter,new_insert_gid,lj_classification,@Message);
select @Message into @Out_Message_Product;
#select @Out_Message_Product;
if @Out_Message_Product <> 'SUCCESS' then
set Message = @Out_Message_Product;
rollback;
leave sp_Atma_Pending_To_Approval_Set;
else
select 'PR_Product_Set -success';
End if;
call sp_Atma_Pending_To_Approval_partnercontractor_Set('insert',lj_filter,new_insert_gid,lj_classification,@Message);
select @Message into @Out_Message_partnercontractor;
if @Out_Message_partnercontractor <> 'SUCCESS' then
#select @Out_Message_partnercontractor;
set Message = @Out_Message_partnercontractor;
rollback;
leave sp_Atma_Pending_To_Approval_Set;
else
select 'contractor -success';
End if;
call sp_Atma_Pending_To_Approval_Taxdetails_Set('Insert',lj_filter,lj_classification,@Message);
select @Message into @Out_Message_Taxdetails;
##select @Out_Message_Taxdetails;
if @Out_Message_Taxdetails <> 'SUCCESS' then
set Message = @Out_Message_Taxdetails;
rollback;
leave sp_Atma_Pending_To_Approval_Set;
else
select 'tax -success';
End if;
call sp_Atma_Pending_To_Approval_Document_Set('Insert',lj_filter,new_insert_gid,lj_classification,@Message);
select @Message into @Out_Message_Document;
#select @Out_Message_Document;
if @Out_Message_Document <> 'SUCCESS' then
set Message = @Out_Message_Document;
rollback;
leave sp_Atma_Pending_To_Approval_Set;
else
select 'document -success';
End if;
call sp_Atma_Pending_To_Approval_PR_Branch_Set(lj_filter,new_insert_gid,lj_classification,@Message);
select @Message into @Out_Message_Branch;
#select @Out_Message_Branch;
if @Out_Message_Branch <> 'SUCCESS' then
set Message = @Out_Message_Branch;
rollback;
leave sp_Atma_Pending_To_Approval_Set;
else
select 'branch -success';
#rollback;#remove
End if;
SET SQL_SAFE_UPDATES = 0;
set Query_delete=concat('DELETE FROM atma_tmp_tpartner WHERE partner_gid=',@Partner_Gid,'');
set @Insert_query = Query_delete;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
else
set Message = ' FAILED_PARTNER deletion';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
select JSON_UNQUOTE(JSON_EXTRACT(lj_filter,CONCAT('$.TRAN_Remarks')))
into @TRAN_Remarks;
select JSON_UNQUOTE(JSON_EXTRACT(lj_classification,CONCAT('$.Create_By')))
into @Create_By;
set @trn_partner_gid ='';
if @Main_partner_gid is null then
set @trn_partner_gid=@NEWPartnergid;
else
set @trn_partner_gid=@Main_partner_gid;
end if;
select fn_REFGid('PARTNER_NAME_TRAN_MST') into @partner_ref_gid_mst;
select fn_REFGid('PARTNER_NAME_TRAN') into @partner_ref_gid_tmp;
#select fn_REFGid('PARTNER_NAME_TRAN') into @partner_ref_gid_tmp;
#### checking rights
set @checker='';
select max(tran_gid) from gal_trn_ttran where
tran_ref_gid=@partner_ref_gid_tmp and tran_reftable_gid=@Partner_Gid
and tran_status='PENDING-RM' into @trangid;
#select @trangid,'trainid';
select tran_by from gal_trn_ttran where tran_gid>=@trangid and
tran_ref_gid=@partner_ref_gid_tmp and tran_reftable_gid=@Partner_Gid and tran_by=@Create_By
into @checker;
#select @checker,'more then rows';
if @checker=@Create_By then
set Message = 'NO RIGHTS';
#rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
#### checking rights end
update gal_trn_ttran set tran_ref_gid=@partner_ref_gid_mst,tran_reftable_gid= @trn_partner_gid
where tran_ref_gid=@partner_ref_gid_tmp and tran_reftable_gid=@Partner_Gid ;
call sp_Trans_Set('Update','PARTNER_NAME_TRAN_MST',@trn_partner_gid,
@Partner_Status,'C',@Create_By,ifnull(@TRAN_Remarks,''),@Entity_Gid,@Create_By,@message);
select @message into @out_msg_tran ;
#select @out_msg_tran,'trn';
if @out_msg_tran = 'FAIL' then
set Message = 'Failed On Tran Insert';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
#if @out_msg_tran = 'SUCCESS' then
if @out_msg_tran > 0 then
select @out_msg_tran,'in tran success' ;
if @Main_partner_gid = '' or @Main_partner_gid is null or @Main_partner_gid=0 then
SET @Supplier_capacity=0;
set @lj_supplier= concat('{"Supplier_Group_Name":"',@partner_name,'","Supplier_Capacity":0,
"AtmaSupplierGrp_Code":"',@partner_code,'"}');
set @lj_address=concat('{"supplier_add_gid":',@Address_Gid,'}');
set @lj_contact=concat('{"supplier_contact_gid":',@Contact_Gid,'}');
#select @lj_supplier,@lj_address,@lj_contact;
call sp_SupplierSPS_Set('SUPPLIER_GROUP_INSERT',@lj_supplier,@lj_address,@lj_contact,lj_Classification,@Message);
select @Message into @Out_Msg_SupplierGROUP ;
select @Out_Msg_SupplierGROUP,'group';
if @Out_Msg_SupplierGROUP >0 then
set @Msg_SupplierGROUP='SUCCESS';
#select @Msg_SupplierGROUP'su';
else
set @Msg_SupplierGROUP='FAIL';
rollback;
end if;
else
###UPDATE SUPPLIER GROUP
######Deactivation and Activation
/* if @Partner_Status='DEACTIVATION' OR @Partner_Status='TERMINATION' then
update gal_mst_tsuppliergroup set suppliergroup_isactive='N',suppliergroup_isremoved='Y' where
suppliergroup_isactive='Y'and suppliergroup_isremoved='N' and suppliergroup_gid=@supp_grp_gid;
end if;
if @Partner_Status='ACTIVATION' then
update gal_mst_tsuppliergroup set suppliergroup_isactive='Y',suppliergroup_isremoved='N' where
suppliergroup_isactive='N'and suppliergroup_isremoved='Y' and suppliergroup_gid=@supp_grp_gid;
end if;*/
#####end
set @lj_supplier= concat('{"SupplierGrp_Name":"',@partner_name,'"
,"AtmaSupplierGrp_Code":"',@partner_code,'",
"Supplier_Capacity":0,"SupplierGrp_Gid":',@supp_grp_gid,'}');
#select @lj_supplier,'sup_grp update';
set @lj_address=concat('{"supplier_add_gid":',@Address_Gid,'}');
set @lj_contact=concat('{"supplier_contact_gid":',@Contact_Gid,'}');
#select @lj_supplier,@lj_address,@lj_contact,1;
call sp_SupplierSPS_Set('SUPPLIER_GROUP_UPDATE',
@lj_supplier,@lj_address,@lj_contact,lj_Classification,@Message);
select @Message into @Msg_SupplierGROUP ;
#select @Out_Msg_SupplierGROUP;
#if @Out_Msg_SupplierGROUP ='SUCCESS' then
# set @out_msg_suppgroup='SUCCESS';
#else
#set @out_msg_suppgroup='FAIL';
#end if;
#set @out_msg_suppgroup='FAIL';
#commit;
end if;
end if;#if @out_msg_tran = 'SUCCESS' then
if @Msg_SupplierGROUP='SUCCESS' then
if @Out_Msg_SupplierGROUP is null then#### new insert supplier
set @Out_Msg_SupplierGROUP=@supp_grp_gid;
end if;
set @Supplier_msg ='';
SET finished1 =0;
BEGIN
Declare Cursor_atma1 CURSOR FOR
select partnerbranch_gid,partnerbranch_gstno,partnerbranch_panno,partnerbranch_addressgid,partnerbranch_contactgid,
partnerbranch_name,partnerbranch_creditperiod,partnerbranch_creditlimit,partnerbranch_paymentterms,
partnerbranch_code
from atma_mst_tpartnerbranch
where partnerbranch_partnergid=new_insert_gid and partnerbranch_isactive='Y'
and partnerbranch_isremoved='N';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished1 = 1;
OPEN Cursor_atma1;
atma_looop1:loop
fetch Cursor_atma1 into p_partnerbranch_gid,p_partnerbranch_gstno,p_partnerbranch_panno,p_partnerbranch_addressgid,
p_partnerbranch_contactgid,p_partnerbranch_name,p_partnerbranch_creditperiod,p_partnerbranch_creditlimit,
p_partnerbranch_paymentterms,p_partnerbranch_code;
if finished1 = 1 then
leave atma_looop1;
End if;
select fn_supplier(p_partnerbranch_code) into @up_supp_gid ;
if @up_supp_gid =0 then
set @lj_supplier= concat('{"Supplier_Name":"',@partner_name,'","Supplier_Capacity":0,
"atmaSupplier_Code":"',p_partnerbranch_code,'","Supplier_Group_Gid":',@Out_Msg_SupplierGROUP,',
"Supplier_Branch_Name":"',p_partnerbranch_name,'","Supplier_GST_No":"',ifnull(p_partnerbranch_gstno,''),'",
"Supplier_Panno":"',ifnull(p_partnerbranch_panno,''),'"}');
set @lj_address=concat('{"supplier_add_gid":',p_partnerbranch_addressgid,'}');
set @lj_contact=concat('{"supplier_contact_gid":',p_partnerbranch_contactgid,'}');
#select @lj_supplier,@lj_address,@lj_contact,lj_Classification;
call sp_SupplierSPS_Set('SUPP_INSERT',@lj_supplier,@lj_address,@lj_contact,lj_Classification,@Message);
select @Message into @Supplier_partner ;
select @Supplier_partner,'insert';
else
#select p_partnerbranch_code,'code';
#select fn_supplier(p_partnerbranch_code) into @up_supp_gid ;
####supplier Deactivation and Activation
select suppliergroup_gid from gal_mst_tsuppliergroup where
suppliergroup_code=@partner_code into @supp_grp_gid;
if @Partner_Status='DEACTIVATION' OR @Partner_Status='TERMINATION' then
# select 1;
SET SQL_SAFE_UPDATES=0;
update gal_mst_tsupplier set supplier_isactive='N',supplier_isremoved='Y' where
supplier_isactive='Y'and supplier_isremoved='N' and supplier_groupgid=@supp_grp_gid;
#select @Partner_Status='DEACTIVATION',@supp_grp_gid;
end if;
if @Partner_Status='ACTIVATION' then
SET SQL_SAFE_UPDATES=0;
# select @Partner_Status,'activation';
update gal_mst_tsupplier set supplier_isactive='Y',supplier_isremoved='N' where
supplier_isactive='N'and supplier_isremoved='Y' and supplier_groupgid=@supp_grp_gid;
end if;
####end supplier Deactivation and Activation
set @lj_supplier= concat('{"Supplier_Gid":',@up_supp_gid,',
"Supplier_Name":"',@partner_name,'",
"Supplier_Capacity":0,
"Supplier_Group_Gid":',@supp_grp_gid,',
"atmaSupplier_Code":"',p_partnerbranch_code,'",
"Supplier_Branch_Name":"',p_partnerbranch_name,'",
"Supplier_GST_No":"',ifnull(p_partnerbranch_gstno,''),'",
"Supplier_Panno":"',ifnull(p_partnerbranch_panno,''),'"}');
set @lj_address=concat('{"supplier_add_gid":',p_partnerbranch_addressgid,'}');
set @lj_contact=concat('{"supplier_contact_gid":',p_partnerbranch_contactgid,'}');
call sp_SupplierSPS_Set('SUPP_UPDATE',@lj_supplier,@lj_address,@lj_contact,lj_Classification,@Message);
select @Message into @Supplier_partner ;
end if;
SET @suppliergid = (SELECT SPLIT_STR((@Supplier_partner), ',', 2));
SET @Supplier_msg = (SELECT SPLIT_STR((@Supplier_partner), ',', 1));
select @Supplier_msg,'insert';
#SET @suppliergid=(select SUBSTRING_INDEX(@Supplier_partner,',',-1));
#SET @Supplier_msg=(select SUBSTRING_INDEX(@Supplier_partner,',',1));
if @Supplier_msg = 'SUCCESS' or @Supplier_partner= 'SUCCESS' then
select @Supplier_msg,'check';
####update map_table
if @suppliergid is null or @suppliergid =''then
set @suppliergid=@up_supp_gid;
#else
#set @sup_id=@suppliergid;
end if;
SET SQL_SAFE_UPDATES = 0;
Update gal_map_tsupplierproduct
set supplierproduct_isactive= 'N' ,supplierproduct_isremoved='Y'
Where supplierproduct_supplier_gid =@suppliergid;
SET finished_partnerproduct =0;
BEGIN
Declare Cursor_atma_partnerproduct CURSOR FOR
select mpartnerproduct_product_gid,mpartnerproduct_unitprice,
mpartnerproduct_packingprice,mpartnerproduct_validfrom,mpartnerproduct_validto,
mpartnerproduct_deliverydays,mpartnerproduct_capacitypw,mpartnerproduct_dts
from atma_map_tpartnerproduct where mpartnerproduct_partner_gid=new_insert_gid
and mpartnerproduct_partnerbranch_gid=p_partnerbranch_gid;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished_partnerproduct = 1;
OPEN Cursor_atma_partnerproduct;
atma_looopsupplier:loop
fetch Cursor_atma_partnerproduct into m_mpartnerproduct_product_gid,m_mpartnerproduct_unitprice,
m_mpartnerproduct_packingprice,m_mpartnerproduct_validfrom,m_mpartnerproduct_validto,
m_mpartnerproduct_deliverydays,m_mpartnerproduct_capacitypw,m_mpartnerproduct_dts;
if finished_partnerproduct = 1 then
leave atma_looopsupplier;
End if;
set @lj_supplier_map= concat('{"supplierproduct_supplier_gid":"',@suppliergid,'",
"supplierproduct_product_gid":"',m_mpartnerproduct_product_gid,'",
"supplierproduct_unitprice":"',m_mpartnerproduct_unitprice,'",
"supplierproduct_packingprice":"',m_mpartnerproduct_packingprice,'",
"supplierproduct_validfrom":"',m_mpartnerproduct_validfrom,'",
"supplierproduct_validto":"',m_mpartnerproduct_validto,'",
"supplierproduct_dts":"',m_mpartnerproduct_dts,'"
}');
call sp_SupplierProductMap_Set('Insert',@lj_supplier_map,@Entity_Gid,@Create_By, @Message);
select @Message into @Out_Message_supplier_map;
SET @Out_msg = (SELECT SPLIT_STR((@Out_Message_supplier_map), ',', 2));
#select @Out_msg;
if @Out_msg <> 'SUCCESS' then
set Message = concat('Error On supplier_map',@Out_msg);
rollback;
leave sp_Atma_Pending_To_Approval_Set;
End if;
End loop atma_looopsupplier;
close Cursor_atma_partnerproduct;
end;
#####paymentDetails open
SET finished_supplierpayment =0;
BEGIN
Declare Cursor_atma_supplierpayment CURSOR FOR
select payment_gid,payment_partnergid,payment_partnerbranchgid,payment_paymodegid,
payment_bankgid,payment_bankbranchgid,
payment_acctype,payment_accnumber,payment_benificiaryname,entity_gid,create_by
from atma_mst_tpayment where payment_partnergid=new_insert_gid
and payment_partnerbranchgid=p_partnerbranch_gid;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished_supplierpayment = 1;
OPEN Cursor_atma_supplierpayment;
atma_looopsupplierpayment:loop
fetch Cursor_atma_supplierpayment into p_payment_gid,p_payment_partnergid,p_payment_partnerbranchgid,
p_payment_paymodegid,p_payment_bankgid,p_payment_bankbranchgid,p_payment_acctype,p_payment_accnumber,
p_payment_benificiaryname,p_entity_gid,p_create_by;
if finished_supplierpayment = 1 then
leave atma_looopsupplierpayment;
End if;
set @partner_ref_gid_supp_payment='';
select fn_REFGid('SUPPLIER_PAYMENT')into @partner_ref_gid_supp_payment;
select fn_bankdetails(p_partnerbranch_code) into @bankdetailsgid ;
###gal_trn_tbankdetails
if @bankdetailsgid =0 then
set Query_Update='';
set Query_Update = concat('INSERT INTO gal_trn_tbankdetails (bankdetails_ref_gid,bankdetails_reftable_gid,
bankdetails_reftable_code,bankdetails_paymode_gid,
bankdetails_bank_gid,bankdetails_bankbranch_gid,bankdetails_acno,
bankdetails_beneficiaryname,entity_gid,create_by,create_date)
values (',@partner_ref_gid_supp_payment,',',@suppliergid,',''',p_partnerbranch_code,''',',p_payment_paymodegid,',
',p_payment_bankgid,',''',p_payment_bankbranchgid,''',
''',ifnull(p_payment_accnumber,''),''',''',ifnull(p_payment_benificiaryname,''),''',
',p_entity_gid,',',p_create_by,',
''',Now(),''')');
#select Query_Update;
else
set Query_Update = concat('Update gal_trn_tbankdetails
set bankdetails_paymode_gid=',p_payment_paymodegid,',
bankdetails_bank_gid=''',p_payment_bankgid,''',
bankdetails_bankbranch_gid=''',p_payment_bankbranchgid,''',
bankdetails_acno=''',ifnull(p_payment_accnumber,''),''',
bankdetails_beneficiaryname=''',ifnull(p_payment_benificiaryname,''),''' ,
update_by=''',@Update_By,''', Update_date = now()
Where bankdetails_gid =',@bankdetailsgid,';
');
end if;###tbankdetails @up_supp_gid
#select Query_Update,'update,bankdetails';
set @Insert_query = Query_Update;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
else
set Message = ' FAILED supplier payment';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
End loop atma_looopsupplierpayment;
close Cursor_atma_supplierpayment;
end;
#####paymentDetails close
### gal_trn_tcreditlimit###open##
select fn_creditlimit(p_partnerbranch_code) into @creditlimitgid;
if @creditlimitgid =0 then
set Query_Update='';
set Query_Update = concat('INSERT INTO gal_trn_tcreditlimit (creditlimit_ref_gid,creditlimit_reftable_gid,
creditlimit_reftable_code,
creditlimit_limit,
creditlimit_days,
creditlimit_creditterms,
creditlimit_validfrom,creditlimit_validto,
entity_gid,create_by,create_date)
values (',@partner_ref_gid_supp_payment,',',@suppliergid,',
''',p_partnerbranch_code,''',
''',p_partnerbranch_creditlimit,''',
''',p_partnerbranch_creditperiod,''',
''',ifnull(p_partnerbranch_paymentterms,''),''',
',if(ifnull(@partner_contractdatefrom,null) IS NULL,'NULL',CONCAT('''',@partner_contractdatefrom,'''')),',
',if(ifnull(@partner_contractdateto,null) IS NULL,'NULL',CONCAT('''',@partner_contractdateto,'''')),',
',p_entity_gid,',',p_create_by,',
''',Now(),''')');
#select Query_Update,'credit';
else
set Query_Update = concat('Update gal_trn_tcreditlimit
set creditlimit_limit=''',p_partnerbranch_creditlimit,''',
creditlimit_days= ''',p_partnerbranch_creditperiod,''',
creditlimit_creditterms= ''',ifnull(p_partnerbranch_paymentterms,''),''',
creditlimit_validfrom=',if(ifnull(@partner_contractdatefrom,null) IS NULL,'NULL',CONCAT('''',@partner_contractdatefrom,'''')),' ,
creditlimit_validto=',if(ifnull(@partner_contractdateto,null) IS NULL,'NULL',CONCAT('''',@partner_contractdateto,'''')),' ,
update_by=''',@Update_By,''', Update_date = now()
Where creditlimit_gid =',@creditlimitgid,'
');
end if;
###@creditlimit_gid
#select Query_Update,'update creditlimit';
set @Insert_query = Query_Update;
PREPARE stmt FROM @Insert_query;
EXECUTE stmt;
set countRow = (select ROW_COUNT());
DEALLOCATE PREPARE stmt;
if countRow > 0 then
set Message = 'SUCCESS';
else
set Message = ' FAILED supplier creditlimit ';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
else
set Message = 'Failed On Supplier Insert1';
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;#if @Supplier_msg = 'SUCCESS' then
End loop atma_looop1;
close Cursor_atma1;
end;
else #if @out_msg_suppgroup='SUCCESS' then
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;#if @out_msg_suppgroup='SUCCESS' then
#select @Msg_SupplierGROUP,@Supplier_msg;
if @Msg_SupplierGROUP='SUCCESS' and @Supplier_msg = 'SUCCESS' then
#rollback;
commit;
else
rollback;
leave sp_Atma_Pending_To_Approval_Set;
end if;
END IF;#IF li_Action='Pending_To_Approval_Insert' then
END | true |
60eba113e1a8de7553668903c213f9f16d123002 | SQL | argentinaluiz/HeimdallOAuth2DoctrineAcl | /Dump20190121/Heimdall_OAuth2_3_Email_User.sql | UTF-8 | 2,692 | 2.859375 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `Heimdall_OAuth2_3` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `Heimdall_OAuth2_3`;
-- MySQL dump 10.13 Distrib 8.0.13, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: Heimdall_OAuth2_3
-- ------------------------------------------------------
-- Server version 5.5.5-10.1.34-MariaDB-0ubuntu0.18.04.1
/*!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 */;
SET NAMES utf8 ;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `Email_User`
--
DROP TABLE IF EXISTS `Email_User`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `Email_User` (
`user_id` int(11) DEFAULT NULL,
`emailId` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(254) COLLATE utf8_unicode_ci NOT NULL,
`isFirst` tinyint(1) DEFAULT NULL,
`checked` tinyint(1) DEFAULT NULL,
`hash` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`updatedAt` datetime DEFAULT NULL,
`mailing` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`emailId`),
KEY `IDX_FDCA5A22A76ED395` (`user_id`),
CONSTRAINT `FK_FDCA5A22A76ED395` FOREIGN KEY (`user_id`) REFERENCES `User` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Email_User`
--
LOCK TABLES `Email_User` WRITE;
/*!40000 ALTER TABLE `Email_User` DISABLE KEYS */;
INSERT INTO `Email_User` VALUES (1,1,'prazeres@gmail.com',1,NULL,NULL,NULL,NULL),(1,2,'prazeres2@gmail.com',NULL,NULL,NULL,NULL,NULL),(2,3,'lauoliveiraa@gmail.com',1,NULL,NULL,NULL,NULL),(2,4,'lauoliveiraa@hotmaill.com',NULL,NULL,NULL,NULL,NULL);
/*!40000 ALTER TABLE `Email_User` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-01-21 18:17:51
| true |
33ad13f2c64e8d2946eac319730628e3462203b4 | SQL | ProgRB/SalProject | /AddRetention/Queries/SelectSalaryPayNote.sql | UTF-8 | 941 | 3.671875 | 4 | [] | no_license | select
a1
from
(
select code_subdiv||per_num||sum_sal||p1||p2||p3||fio||p4||sign_comb a1
from
(select
lpad(code_subdiv,4,'0') code_subdiv,
lpad(per_num, 6, '0') per_num,
to_char(NVL(sum(sum_sal),0)*100, 'FM000000000000') sum_sal,
'000000000000' p1,
'000000000000' p2,
'000000000000' p3,
rpad(emp_last_name||' '||substr(emp_first_name,1,1)||' '||substr(emp_middle_name,1,1),22,' ') FIO,
'0' p4,
decode(sign_comb,1,'2',' ') sign_comb,
count(per_num) over (partition by code_subdiv) rn
from
{1}.view_salary_transfer vst
join apstaff.transfer using (transfer_id)
join apstaff.emp using (per_num)
join apstaff.subdiv s on (vst.subdiv_id=s.subdiv_id)
where cartulary_id = :p_cartulary_id
group by code_subdiv, per_num, emp_last_name, emp_first_name, emp_middle_name, sign_comb
having sum(sum_sal)!=0
order by code_subdiv, per_num)
where rn>1
)
union all
select chr(26) from dual | true |
c0fe56651e1b848f8544066a7530cd3446f827cc | SQL | parthisri744/SKP_Hospital | /vendor/SQL/Hospital.sql | UTF-8 | 10,115 | 3 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Oct 06, 2021 at 02:26 PM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 */;
--
-- Database: `Hospital`
--
-- --------------------------------------------------------
--
-- Table structure for table `doctorsdetails`
--
CREATE TABLE `doctorsdetails` (
`ID` int(11) NOT NULL,
`docname` varchar(255) DEFAULT NULL,
`docid` varchar(255) DEFAULT NULL,
`docdob` date DEFAULT NULL,
`docphoneno` varchar(25) DEFAULT NULL,
`docemail` varchar(255) DEFAULT NULL,
`docsplist` text DEFAULT NULL,
`docqualifi` varchar(255) DEFAULT NULL,
`docaddress` text DEFAULT NULL,
`docstatus` varchar(25) DEFAULT NULL,
`docusername` varchar(255) DEFAULT NULL,
`docpassword` varchar(255) DEFAULT NULL,
`submit_name` varchar(255) DEFAULT NULL,
`submit_time` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `doctorsdetails`
--
INSERT INTO `doctorsdetails` (`ID`, `docname`, `docid`, `docdob`, `docphoneno`, `docemail`, `docsplist`, `docqualifi`, `docaddress`, `docstatus`, `docusername`, `docpassword`, `submit_name`, `submit_time`) VALUES
(1, 'Parthiban S', 'DOC12345', '2021-10-06', '06383117625', 'parthibans452@gmail.com', 'General Physician', 'MBBS', '293, thanigai amman kovil\r\nNeikuppi village Anupuram', 'Active', 'parthisri', '$2y$10$7DbOpQJhkmqZ1myUdD/jXu2vyZ5x/07llPPM9Rcn7qYrFy111Xrpu', 'admin', '2021-10-05 15:09:29');
-- --------------------------------------------------------
--
-- Table structure for table `feesdeatils`
--
CREATE TABLE `feesdeatils` (
`ID` int(11) NOT NULL,
`feestype` varchar(255) DEFAULT NULL,
`feesname` varchar(11) DEFAULT NULL,
`feesdesc` text DEFAULT NULL,
`feesamount` float DEFAULT NULL,
`submit_by` varchar(255) DEFAULT NULL,
`submit_time` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `feesdeatils`
--
INSERT INTO `feesdeatils` (`ID`, `feestype`, `feesname`, `feesdesc`, `feesamount`, `submit_by`, `submit_time`) VALUES
(1, 'Doctor Fees', 'FEES', 'DOCTOR PAYMENT', 105, 'Admin', '2021-10-05 06:46:39'),
(2, 'Lab Fees', 'Bood test', 'LAB', 50, 'Admin', '2021-10-05 06:18:39');
-- --------------------------------------------------------
--
-- Table structure for table `fileupload`
--
CREATE TABLE `fileupload` (
`ID` int(11) NOT NULL,
`patientID` int(11) DEFAULT NULL,
`filedesc` text DEFAULT NULL,
`fuploadname` varchar(255) DEFAULT NULL,
`fuploadtime` datetime DEFAULT NULL,
`filepath` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `fileupload`
--
INSERT INTO `fileupload` (`ID`, `patientID`, `filedesc`, `fuploadname`, `fuploadtime`, `filepath`) VALUES
(1, 1, 'OKOK TESTING ...', 'Parthiban', '2021-10-05 06:16:07', 'Paymentbill.pdf'),
(2, 2, 'OKOK TESTING', 'Admin', '2021-10-05 06:52:13', 'SKP- Hospital.pdf'),
(3, 2, 'OKOK TESTING', 'Admin', '2021-10-05 07:07:56', 'SKP- Hospital.pdf'),
(4, 2, 'OKOK TESTING', 'Admin', '2021-10-05 07:08:28', 'SKP- Hospital.pdf'),
(5, 2, 'OKOK TESTING', 'Admin', '2021-10-05 07:17:21', 'SKP- Hospital.pdf');
-- --------------------------------------------------------
--
-- Table structure for table `patientdetails`
--
CREATE TABLE `patientdetails` (
`ID` int(11) NOT NULL,
`patientname` varchar(255) DEFAULT NULL,
`hpatientid` varchar(255) DEFAULT NULL,
`patientid` int(11) NOT NULL DEFAULT 1,
`patientage` varchar(255) DEFAULT NULL,
`patientphno` varchar(11) NOT NULL,
`patientadd` text DEFAULT NULL,
`submitname` varchar(255) DEFAULT NULL,
`submitime` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `patientdetails`
--
INSERT INTO `patientdetails` (`ID`, `patientname`, `hpatientid`, `patientid`, `patientage`, `patientphno`, `patientadd`, `submitname`, `submitime`) VALUES
(4, 'Parthiban S', 'SKP/10/2021/1', 1, '21', '9790339185', 'NO : 293 Thanigai Amman Kovil Street Anupuram', 'admin', '2021-10-05 15:04:40');
-- --------------------------------------------------------
--
-- Table structure for table `patients`
--
CREATE TABLE `patients` (
`ID` int(11) NOT NULL,
`pid` int(11) DEFAULT NULL,
`patientID` varchar(255) DEFAULT NULL,
`docname` varchar(255) DEFAULT NULL,
`vtime` datetime DEFAULT NULL,
`ptoken` int(11) DEFAULT NULL,
`tocname` varchar(255) DEFAULT NULL,
`toctime` datetime DEFAULT NULL,
`docdesc` text DEFAULT NULL,
`docproname` varchar(255) DEFAULT NULL,
`docprotime` datetime DEFAULT NULL,
`patstatus` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `patients`
--
INSERT INTO `patients` (`ID`, `pid`, `patientID`, `docname`, `vtime`, `ptoken`, `tocname`, `toctime`, `docdesc`, `docproname`, `docprotime`, `patstatus`) VALUES
(1, 4, 'SKP/10/2021/1', 'Parthiban S', '2021-10-05 22:41:00', 1, 'admin', '2021-10-05 05:09:51', 'TESTING FOR DOCTOR SECTION', 'Parthiban S', '2021-10-05 05:36:27', 'Completed'),
(2, 4, 'SKP/10/2021/1', 'admin', '2021-10-14 01:22:00', 2, 'Admin', '2021-10-05 06:49:31', 'OKOKOKOK SUCCESS', 'Admin', '2021-10-06 06:51:21', 'Completed'),
(3, 4, 'SKP/10/2021/1', 'Parthiban S', '2021-10-06 01:52:00', 3, 'Admin', '2021-10-05 07:19:49', NULL, NULL, NULL, 'Waiting For Doctor Process');
-- --------------------------------------------------------
--
-- Table structure for table `patinetsfeesdeatils`
--
CREATE TABLE `patinetsfeesdeatils` (
`ID` int(11) NOT NULL,
`patinetID` int(11) DEFAULT NULL,
`feestype` varchar(255) DEFAULT NULL,
`feesname` varchar(11) DEFAULT NULL,
`feesquant` int(11) DEFAULT NULL,
`feesamount` float DEFAULT NULL,
`totalamount` float DEFAULT NULL,
`submit_by` varchar(255) DEFAULT NULL,
`submit_time` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `patinetsfeesdeatils`
--
INSERT INTO `patinetsfeesdeatils` (`ID`, `patinetID`, `feestype`, `feesname`, `feesquant`, `feesamount`, `totalamount`, `submit_by`, `submit_time`) VALUES
(1, 1, 'Doctor Fees', 'FEES', 12, 100, 1200, 'Parthiban', '2021-10-05 06:24:44'),
(2, 1, 'Lab Fees', 'Bood test', 25, 50, 1250, 'Parthiban', '2021-10-06 06:24:55'),
(3, 2, 'Doctor Fees', 'Bood test', 1, 50, 50, 'Admin', '2021-10-05 06:52:28');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`ID` int(11) NOT NULL,
`category` varchar(25) DEFAULT NULL,
`uname` varchar(255) DEFAULT NULL,
`usermail` varchar(255) DEFAULT NULL,
`birthdate` date DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`phoneno` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`uaddress` text DEFAULT NULL,
`created_by` varchar(255) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`pflag` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`ID`, `category`, `uname`, `usermail`, `birthdate`, `username`, `phoneno`, `password`, `uaddress`, `created_by`, `created_at`, `pflag`) VALUES
(1, 'Admin', 'Admin', 'admin452@gmail.com', '2021-09-16', 'admin', '06383117625', '$2y$10$czX1grNavKivzXV26g7zdeEmSroJGNNpZx.BqCgEqMGXykOo3zG9m', '293, thanigai amman kovil\r\nNeikuppi village Anupuram', 'admin', '2021-10-05 00:25:06', NULL),
(16, 'Doctor', 'Parthiban S', 'parthibans452@gmail.com', '2021-10-06', 'parthisri', '06383117625', '$2y$10$KYrg.bpc8/Kluf3Pxt1t7OyU/tkVccMR645r1G9IfWH4ZybdqbGAy', '293, thanigai amman kovil\r\nNeikuppi village Anupuram', 'Parthiban S', '2021-10-05 00:03:01', 0),
(17, 'Staff', 'Parthiban', 'test@igcar.gov.in', '2021-10-06', 'parthiban', '0123645758', '$2y$10$Xsc.86C7SpsqlmbP1Bteoe.GqeffMpgnCHKEelhYb3Qy5C1g8gYKi', 'IGCAR, Kalpakkam', 'Admin', '2021-10-05 15:45:48', 0);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `doctorsdetails`
--
ALTER TABLE `doctorsdetails`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `feesdeatils`
--
ALTER TABLE `feesdeatils`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `fileupload`
--
ALTER TABLE `fileupload`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `patientdetails`
--
ALTER TABLE `patientdetails`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `patients`
--
ALTER TABLE `patients`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `patinetsfeesdeatils`
--
ALTER TABLE `patinetsfeesdeatils`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`ID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `doctorsdetails`
--
ALTER TABLE `doctorsdetails`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `feesdeatils`
--
ALTER TABLE `feesdeatils`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `fileupload`
--
ALTER TABLE `fileupload`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `patientdetails`
--
ALTER TABLE `patientdetails`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `patients`
--
ALTER TABLE `patients`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `patinetsfeesdeatils`
--
ALTER TABLE `patinetsfeesdeatils`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
22a40e161b885f9f203b7f294f368a5186cd1d02 | SQL | cutting-dsa/mumsched | /src/main/resources/db/migration/V1__init.sql | UTF-8 | 8,516 | 3.28125 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS app_user (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
active INT NOT NULL,
email VARCHAR(255) NOT NULL,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
role VARCHAR(255) NOT NULL
);
INSERT INTO app_user (active,email,first_name,last_name, password, role) values (1,'scheduleadmin@miu.edu','Schedule', 'Admin', '$2a$10$Q0AhVP0h49r9E3O5yVq86uiXQFoQZCXSRGnEzdNNA2GQq9Bb/hdMS', 'ADMIN');
INSERT INTO app_user (active,email,first_name,last_name, password, role)
values (1,'student.one@miu.edu','Student', 'One', '$2a$10$Q0AhVP0h49r9E3O5yVq86uiXQFoQZCXSRGnEzdNNA2GQq9Bb/hdMS', 'STUDENT');
INSERT INTO app_user (active,email,first_name,last_name, password, role)
values (1,'student.two@miu.edu','Student', 'Two', '$2a$10$Q0AhVP0h49r9E3O5yVq86uiXQFoQZCXSRGnEzdNNA2GQq9Bb/hdMS', 'STUDENT');
INSERT INTO app_user (active,email,first_name,last_name, password, role)
values (1,'faculty.one@miu.edu','Faculty', 'One', '$2a$10$Q0AhVP0h49r9E3O5yVq86uiXQFoQZCXSRGnEzdNNA2GQq9Bb/hdMS', 'FACULTY');
INSERT INTO app_user (active,email,first_name,last_name, password, role)
values (1,'faculty.two@miu.edu','Faculty', 'Two', '$2a$10$Q0AhVP0h49r9E3O5yVq86uiXQFoQZCXSRGnEzdNNA2GQq9Bb/hdMS', 'FACULTY');
# create entry table
CREATE TABLE IF NOT EXISTS `entry` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`capacity` int(11) DEFAULT NULL,
`date` date DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# insert into entry table
INSERT INTO `entry` (`capacity`, `date`, `name`) VALUES (150, '2021-02-01', 'February_2021');
# create block table
CREATE TABLE IF NOT EXISTS `block` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`start_date` date DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# insert into blocks table
INSERT INTO `block` (`date`, `end_date`, `name`, `start_date`) VALUES ('2021-05-01', '2021-06-01', 'May_Block', '2021-05-01');
INSERT INTO `block` (`date`, `end_date`, `name`, `start_date`) VALUES ('2021-06-01', '2021-07-01', 'June_Block', '2021-06-01');
INSERT INTO `block` (`date`, `end_date`, `name`, `start_date`) VALUES ('2021-07-01', '2021-08-01', 'July_Block', '2021-07-01');
INSERT INTO `block` (`date`, `end_date`, `name`, `start_date`) VALUES ('2021-08-01', '2021-09-01', 'August_Block', '2021-08-01');
CREATE TABLE IF NOT EXISTS `course` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`code` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# insert into courses table
INSERT INTO `course` (`code`, `description`, `name`) VALUES ('CS425', 'Software Engineering', 'Software Engineering');
INSERT INTO `course` (`code`, `description`, `name`) VALUES ('CS435', 'Algorithms', 'Algorithms');
INSERT INTO `course` (`code`, `description`, `name`) VALUES ('CS590', 'Software Architecture', 'Software Architecture');
INSERT INTO `course` (`code`, `description`, `name`) VALUES ('CS472', 'Web Application Programming', 'Web Application Programming');
# create faculty table
CREATE TABLE IF NOT EXISTS `faculty` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`biography` varchar(255) NOT NULL,
`end_date` date DEFAULT NULL,
`staff_id` bigint(20) NOT NULL,
`start_date` date DEFAULT NULL,
`user_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_staff_id` (`staff_id`),
KEY `FK_app_user_faculty` (`user_id`),
CONSTRAINT `FK_app_user_faculty` FOREIGN KEY (`user_id`) REFERENCES `app_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# insert into faculty table
INSERT INTO `faculty` (`biography`, `staff_id`, `user_id`, `end_date`, `start_date`) VALUES ('Algorithm and compilers researcher', 20398,
(SELECT u.id FROM `app_user` u WHERE u.`email` = "faculty.one@miu.edu"), '2021-11-30', '2021-05-25');
INSERT INTO `faculty` (`biography`, `staff_id`, `user_id`, `end_date`, `start_date`) VALUES ('Machine learning expert', 30568,
(SELECT u.id FROM `app_user` u WHERE u.`email` = "faculty.two@miu.edu"), '2021-11-30', '2021-05-25');
# create student table
CREATE TABLE IF NOT EXISTS `student` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`is_active` bit(1) NOT NULL,
`has_registered_courses` bit(1) NOT NULL,
`registration_number` decimal(19,2) NOT NULL,
`track` varchar(255) NOT NULL,
`creator_id` bigint(20) DEFAULT NULL,
`entry_id` bigint(20) DEFAULT NULL,
`user_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_registration_number` (`registration_number`),
KEY `FK_creator_id_app_user_student` (`creator_id`),
KEY `FK_entry_student` (`entry_id`),
KEY `FK_app_user_student` (`user_id`),
CONSTRAINT `FK_entry_student` FOREIGN KEY (`entry_id`) REFERENCES `entry` (`id`),
CONSTRAINT `FK_creator_id_app_user_student` FOREIGN KEY (`creator_id`) REFERENCES `app_user` (`id`),
CONSTRAINT `FK_app_user_student` FOREIGN KEY (`user_id`) REFERENCES `app_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# insert into students table
INSERT INTO `student` (`is_active`, `registration_number`, `track`, `user_id`, `has_registered_courses`, `creator_id`, `entry_id`)
VALUES (1, 612363, "FPP", (SELECT u.id FROM `app_user` u WHERE u.`email` = "student.one@miu.edu"), 0,
(SELECT u.id FROM `app_user` u WHERE u.`email` = "scheduleadmin@miu.edu"),
(SELECT e.id FROM entry e WHERE e.`name` = "January_2021"));
INSERT INTO `student` (`is_active`, `registration_number`, `track`, `user_id`, `has_registered_courses`, `creator_id`, `entry_id`)
VALUES (1, 612310, "MPP", (SELECT u.id FROM `app_user` u WHERE u.`email` = "student.two@miu.edu"), 0,
(SELECT u.id FROM `app_user` u WHERE u.`email` = "scheduleadmin@miu.edu"),
(SELECT e.id FROM entry e WHERE e.`name` = "January_2021"));
# create table faculty course
CREATE TABLE `faculty_course` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`block_id` bigint(20) NOT NULL,
`course_id` bigint(20) NOT NULL,
`faculty_id` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_block_faculty_course` (`block_id`),
KEY `FK_course_faculty_course` (`course_id`),
KEY `FK_facult_faculty_course` (`faculty_id`),
CONSTRAINT `FK_facult_faculty_course` FOREIGN KEY (`faculty_id`) REFERENCES `faculty` (`id`),
CONSTRAINT `FK_course_faculty_course` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`),
CONSTRAINT `FK_block_faculty_course` FOREIGN KEY (`block_id`) REFERENCES `block` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# insert faculty course table
INSERT INTO `faculty_course` (`block_id`, `course_id`, `faculty_id`)
VALUES ((SELECT b.`id` FROM `block` b ORDER BY b.`start_date` LIMIT 0,1),
(SELECT c.`id` FROM `course` c ORDER BY c.`code` LIMIT 0,1),
(SELECT f.`id` FROM `faculty` f ORDER BY f.`staff_id` LIMIT 0,1)); | true |
d0d8e79c7a25c94cf80fdcb1e287747008091aac | SQL | misterx/time-management-app | /docker/db/src/security/privileges.sql | UTF-8 | 1,959 | 3.53125 | 4 | [] | no_license | -- Разрешаем использование схемы
grant usage on schema api,auth to time_anon;
-- Разрешаем логинится для анонимуса
grant execute on function api.login(text,text) to time_anon;
-- Отладочная инфа
grant select on table api.debug to time_anon;
-- Разрешаем выборку проджектов для юзера
grant select on table api.projects to time_user;
-- Разрешаем круд для юзера
grant all on table api.tasks to time_user;
-- Разрешаем круд проджектов для адина
grant all on table api.projects to time_admin;
-- Разрешаем круд юзеров для админа
grant all on table api.users to time_admin;
-- Даем доступ к репортам
grant select on table api.report_by_day,api.report_by_month to time_admin;
grant execute on function api.report_by_range(text,text) to time_admin;
-- У всех view которые должны использовать RLS должен быть владелец api
-- а также нужно дать права на зпись для этого пользователя, т.к. запись в дочернюю таблицу
-- производится от имени владельца view
-- Воркфлоу
-- Request
-- View access as JWT user
-- Pivot table access as View owner
alter table data.tasks enable row level security;
grant all on data.tasks to api;
drop policy if exists tasks_access_policy on data.tasks;
create policy tasks_access_policy on data.tasks to api
using
(
(request.user_role()='time_user' and request.user_id()::uuid = user_id)
OR
(request.user_role()='time_admin')
)
with check
(
(
(request.user_role()='time_user' and request.user_id()::uuid = user_id)
AND
( (current_date - interval '7 days') < "date" )
)
OR
(request.user_role()='time_admin')
);
| true |
0d676a75bc1e7d04b3d7d70a8368ca50d1855442 | SQL | Jin-wei/chumuu | /db/upgrades/21.up.sql | UTF-8 | 617 | 2.53125 | 3 | [] | no_license | /**
* Created by ibm on 14-8-11.
*/
CREATE TABLE `feedback` (
`id` bigint(11) NOT NULL AUTO_INCREMENT,
`cust_id` bigint(11) DEFAULT NULL,
`contact_email` varchar(200) DEFAULT NULL,
`contact_phone` varchar(20) DEFAULT NULL,
`content` varchar(1000) NOT NULL,
`level` int(1) NOT NULL DEFAULT '0',
`active` tinyint(1) NOT NULL DEFAULT '1',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE bw.business
MODIFY COLUMN bw.business.desc varchar(1000);
insert into db_upgrade (version) values (21); | true |
46d18416e9aa06baeb0e40ef57594d7ebe962f38 | SQL | xitrii/test | /2/db.sql | UTF-8 | 2,325 | 3.46875 | 3 | [] | no_license | -- MySQL Script generated by MySQL Workbench
-- 10/01/15 02:34:30
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`books`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`books` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '',
`book_name` VARCHAR(255) NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '',
UNIQUE INDEX `id_UNIQUE` (`id` ASC) COMMENT '')
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`authors`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`authors` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '',
`name` VARCHAR(255) NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '')
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`connect`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`connect` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT '',
`author_id` INT NULL COMMENT '',
`book_id` INT NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '',
INDEX `fkey_author_idx` (`author_id` ASC) COMMENT '',
INDEX `fkey_book_idx` (`book_id` ASC) COMMENT '',
INDEX `index` (`author_id` ASC, `book_id` ASC) COMMENT '',
CONSTRAINT `fkey_author`
FOREIGN KEY (`author_id`)
REFERENCES `mydb`.`authors` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fkey_book`
FOREIGN KEY (`book_id`)
REFERENCES `mydb`.`books` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
b0a5805e60638a9d41adbe1274d052acb6425f81 | SQL | HimalPerera/Store-Transactions-Management-System | /SQL Dump/store_transactions_database.sql | UTF-8 | 2,619 | 3.734375 | 4 | [] | no_license | 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 utf8 */;
CREATE DATABASE IF NOT EXISTS `store_transactions_database` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `store_transactions_database`;
CREATE TABLE IF NOT EXISTS `purchases` (
`transaction_ID` varchar(10) NOT NULL,
`itemCode` varchar(10) NOT NULL,
`amount` int(11) NOT NULL,
`totalPrice` double NOT NULL,
PRIMARY KEY (`transaction_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `purchases` (`transaction_ID`, `itemCode`, `amount`, `totalPrice`) VALUES
('P-1', 'AA1111', 10, 1000),
('P-2', 'BB2222', 20, 2000),
('P-3', 'CC3333', 3, 3000),
('P-4', 'DD4444', 4, 4000),
('P-5', 'EE5555', 55, 5000);
CREATE TABLE IF NOT EXISTS `sales` (
`transaction_ID` varchar(10) NOT NULL,
`itemCode` varchar(10) NOT NULL,
`amount` int(11) NOT NULL,
`totalPrice` double NOT NULL,
`givenDiscount` double NOT NULL DEFAULT '0',
PRIMARY KEY (`transaction_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `sales` (`transaction_ID`, `itemCode`, `amount`, `totalPrice`, `givenDiscount`) VALUES
('S-1', 'AA1111', 2, 200, 0),
('S-10', 'EE5555', 7, 2800, 700),
('S-11', 'EE5555', 6, 2400, 600),
('S-2', 'BB2222', 4, 800, 0),
('S-3', 'EE5555', 3, 1200, 300),
('S-4', 'EE5555', 4, 1600, 400),
('S-5', 'EE5555', 6, 2400, 600),
('S-6', 'EE5555', 8, 3200, 800),
('S-7', 'BB2222', 2, 400, 0),
('S-8', 'EE5555', 11, 4400, 1100),
('S-9', 'AA1111', 1, 100, 0);
CREATE TABLE IF NOT EXISTS `stock` (
`itemCode` varchar(10) NOT NULL,
`itemName` varchar(20) NOT NULL,
`unitPrice` double NOT NULL,
`discountRate` double NOT NULL,
`discountLevel` int(11) NOT NULL,
`currentStock` int(11) NOT NULL,
PRIMARY KEY (`itemCode`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `stock` (`itemCode`, `itemName`, `unitPrice`, `discountRate`, `discountLevel`, `currentStock`) VALUES
('AA1111', 'aaaa', 100, 10, 10, 7),
('BB2222', 'bbbb', 200, 20, 5, 14),
('CC3333', 'cccc', 300, 30, 3, 3),
('DD4444', 'dddd', 400, 25, 10, 4),
('EE5555', 'eeee', 500, 20, 2, 10),
('FF6666', 'ffff', 600, 10, 6, 0),
('GG7777', 'gggg', 700, 20, 7, 0),
('HH8888', 'hhhh', 800, 30, 8, 0),
('II9999', 'iiii', 900, 40, 5, 0);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
9d7585d73cd53719d8cbaa0268063066efa46914 | SQL | saschenbeck/database-exercises | /delete_exercises.sql | UTF-8 | 843 | 2.875 | 3 | [] | no_license | USE codeup_test_db;
-- SELECT 'Albums released after 1991' AS 'INFO';
-- SELECT name, release_date
-- FROM albums
-- WHERE release_date > 1991;
--
-- DELETE FROM albums
-- WHERE release_date > 1991;
-- SELECT 'Albums released after 1991' AS 'INFO';
-- SELECT name, release_date
-- FROM albums
-- WHERE release_date > 1991;
-- SELECT 'Albums with disco genre' AS 'Info';
-- SELECT name
-- FROM albums
-- WHERE genre = 'Disco';
--
-- DELETE FROM albums
-- WHERE genre = 'Disco';
--
-- SELECT 'Albums with disco genre' AS 'Info';
-- SELECT name
-- FROM albums
-- WHERE genre = 'Disco';
-- SELECT 'Albums by Madonna' AS 'Info';
-- SELECT name
-- FROM albums
-- WHERE artist = 'Madonna';
--
-- DELETE FROM albums
-- WHERE artist = 'Madonna';
--
-- SELECT 'Albums by Madonna' AS 'Info';
-- SELECT name
-- FROM albums
-- WHERE artist = 'Madonna'; | true |
9f8cf500f915b1e9c9a10fe2ee4309a399dde261 | SQL | masa0422/shikiriya_linebot | /_sql/createtable.sql | UTF-8 | 2,339 | 3.125 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS `lba_users` (
`id` bigint(20) unsigned NOT NULL,
`timestamp` text DEFAULT NULL,
`userid` varchar(255) DEFAULT NULL,
`keyword` varchar(200) DEFAULT NULL,
`displayName` varchar(200) DEFAULT NULL,
`pictureUrl` text DEFAULT NULL,
`statusMessage` text DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`created_by` varchar(200) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`updated_by` varchar(200) DEFAULT NULL,
`flg` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `lba_schedule` (
`id` bigint(20) unsigned NOT NULL,
`keyword` varchar(200) DEFAULT NULL,
`data` text DEFAULT NULL,
`status` tinyint(3) unsigned DEFAULT '0',
`result` varchar(20) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`created_by` varchar(200) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`updated_by` varchar(200) DEFAULT NULL,
`flg` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `lba_rawdata` (
`id` bigint(20) unsigned NOT NULL,
`data` text DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`created_by` varchar(200) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`updated_by` varchar(200) DEFAULT NULL,
`flg` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `db_log_error` (
`id` bigint(20) unsigned NOT NULL,
`url` text,
`file_path` varchar(255) DEFAULT NULL,
`line_number` varchar(255) DEFAULT NULL,
`error_content` text,
`created_at` datetime DEFAULT NULL,
`created_by` varchar(255) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`updated_by` varchar(255) DEFAULT NULL,
`flg` tinyint(1) unsigned DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
ALTER TABLE `lba_users`
ADD PRIMARY KEY (`id`);
ALTER TABLE `lba_schedule`
ADD PRIMARY KEY (`id`);
ALTER TABLE `lba_rawdata`
ADD PRIMARY KEY (`id`);
ALTER TABLE `db_log_error`
ADD PRIMARY KEY (`id`);
ALTER TABLE `lba_users`
MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `lba_schedule`
MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `lba_rawdata`
MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `db_log_error`
MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT; | true |
33d51fb9f300d66c1546da1fbdc25d8477c53a97 | SQL | YaroslavTir/msh122 | /metro-core/target/classes/db/migration/V00035__create_plan_settings.sql | UTF-8 | 387 | 3.203125 | 3 | [] | no_license | create sequence station_plan_settings_seq start 1 increment by 1;
CREATE TABLE if not exists station_plan_settings
(
id bigint NOT NULL DEFAULT nextval('station_plan_settings_seq') primary key,
rus_url text,
eng_url text,
owner_type text NOT NULL,
owner_id bigint NOT NULL
);
create unique index i_station_plan_settings_owner on station_plan_settings (owner_type, owner_id); | true |
77354ec02dca964e1a085b6fdb3912985de0459b | SQL | ahbaid/learn | /oracle/recycle_pool_candidates.sql | UTF-8 | 323 | 2.96875 | 3 | [] | no_license | Col object_name format a30
Col object_type format a20
SELECT o.owner, object_name, object_type, COUNT(*) buffers
FROM SYS.x$bh, dba_objects o
WHERE (tch = 1 OR (tch = 0 AND lru_flag < 8)) AND
obj = o. object_id AND
o.owner not in ('SYSTEM','SYS')
GROUP BY o.owner, object_name, object_type
ORDER BY buffers;
| true |
64a7838c48e97ce3cf05d54d8f032c8bc6391395 | SQL | averaart/INFPRG03-Herkansing | /src/data/infprg03.sql | UTF-8 | 9,464 | 3.015625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Machine: localhost
-- Genereertijd: 16 jan 2012 om 21:54
-- Serverversie: 5.5.16
-- PHP-Versie: 5.3.8
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 utf8 */;
--
-- Database: `infprg03`
--
DROP TABLE IF EXISTS `answer_option`;
DROP TABLE IF EXISTS `answer_scale`;
DROP TABLE IF EXISTS `answer`;
DROP TABLE IF EXISTS `option`;
DROP TABLE IF EXISTS `scale`;
DROP TABLE IF EXISTS `question`;
DROP TABLE IF EXISTS `user_survey`;
DROP TABLE IF EXISTS `survey`;
DROP TABLE IF EXISTS `user`;
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `answer`
--
CREATE TABLE IF NOT EXISTS `answer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`question_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`text` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `question_id` (`question_id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=28 ;
--
-- Gegevens worden uitgevoerd voor tabel `answer`
--
INSERT INTO `answer` (`id`, `question_id`, `user_id`, `text`) VALUES
(1, 1, 1, NULL),
(2, 1, 2, NULL),
(3, 2, 1, NULL),
(4, 2, 2, NULL),
(5, 3, 1, NULL),
(6, 3, 2, NULL),
(7, 4, 1, NULL),
(8, 4, 2, NULL),
(9, 5, 1, 'Daar wordt ik heel blij van'),
(10, 5, 2, 'Daar denk ik nooit zo over na'),
(11, 6, 1, NULL),
(12, 6, 2, NULL),
(13, 7, 1, NULL),
(14, 7, 2, NULL),
(15, 8, 1, NULL),
(16, 8, 2, NULL),
(17, 9, 1, NULL),
(18, 9, 2, NULL),
(19, 10, 1, 'Uhm, Steve wie?'),
(20, 10, 2, 'Ik vertrouw die gast gewoon niet.'),
(21, 11, 1, NULL),
(22, 11, 2, NULL),
(23, 12, 1, NULL),
(24, 12, 2, NULL),
(25, 13, 1, NULL),
(26, 14, 1, NULL),
(27, 15, 1, 'Matt is gewoon cooler dan Trey.');
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `answer_option`
--
CREATE TABLE IF NOT EXISTS `answer_option` (
`answer_id` int(11) NOT NULL,
`option_id` int(11) NOT NULL,
PRIMARY KEY (`answer_id`),
KEY `option_id` (`option_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Gegevens worden uitgevoerd voor tabel `answer_option`
--
INSERT INTO `answer_option` (`answer_id`, `option_id`) VALUES
(22, 1),
(21, 4),
(23, 5),
(24, 6),
(1, 7),
(2, 10),
(5, 12),
(6, 13),
(11, 14),
(12, 15),
(14, 16),
(13, 18),
(15, 21),
(16, 22),
(25, 24);
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `answer_scale`
--
CREATE TABLE IF NOT EXISTS `answer_scale` (
`answer_id` int(11) NOT NULL,
`value` int(11) NOT NULL,
PRIMARY KEY (`answer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Gegevens worden uitgevoerd voor tabel `answer_scale`
--
INSERT INTO `answer_scale` (`answer_id`, `value`) VALUES
(3, 3),
(4, 4),
(7, 5),
(8, 2),
(17, 4),
(18, 2),
(26, 2);
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `option`
--
CREATE TABLE IF NOT EXISTS `option` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`question_id` int(11) NOT NULL,
`text` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `question_id` (`question_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;
--
-- Gegevens worden uitgevoerd voor tabel `option`
--
INSERT INTO `option` (`id`, `question_id`, `text`) VALUES
(1, 11, 'Stan'),
(2, 11, 'Kyle'),
(3, 11, 'Cartman'),
(4, 11, 'Kenny'),
(5, 12, 'Ja'),
(6, 12, 'Nee'),
(7, 1, 'Rood'),
(8, 1, 'Groen'),
(9, 1, 'Geel'),
(10, 1, 'Blauw'),
(11, 1, 'Paars'),
(12, 3, 'Ja'),
(13, 3, 'Nee'),
(14, 6, 'Mac'),
(15, 6, 'PC'),
(16, 7, 'Windows'),
(17, 7, 'Linux'),
(18, 7, 'OSX'),
(19, 8, 'Geen'),
(20, 8, '1'),
(21, 8, '2'),
(22, 8, '3'),
(23, 8, '4 of meer'),
(24, 13, 'Ja'),
(25, 13, 'Nee');
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `question`
--
CREATE TABLE IF NOT EXISTS `question` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`survey_id` int(11) NOT NULL,
`text` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `survey_id` (`survey_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;
--
-- Gegevens worden uitgevoerd voor tabel `question`
--
INSERT INTO `question` (`id`, `survey_id`, `text`) VALUES
(1, 1, 'Welke kleur vind je het leukst?'),
(2, 1, 'Hoe leuk vind je de kleur beige?'),
(3, 1, 'Vind je de kleur bruin leuk?'),
(4, 1, 'Hoe licht is de kleur van de tafel?'),
(5, 1, 'Beschrijf je gemoedstoestand als je denkt aan de kleur turquoise:'),
(6, 2, 'Mac of PC?'),
(7, 2, 'Windows, Linux of OSX?'),
(8, 2, 'Hoeveel computers bezit u?'),
(9, 2, 'Windows zuigt...'),
(10, 2, 'Waarom vindt u dat Steve Balmer ontslagen moet worden?'),
(11, 3, 'Stan, Kyle, Cartman of Kenny?'),
(12, 3, 'Moet Kenny echt iedere aflevering dood gaan?'),
(13, 3, 'Is het je ooit opgevallen dat alleen Cartman altijd zijn achternaam wordt genoemd?'),
(14, 3, 'Hoe waarschijnlijk is het dat South Park eerder stopt dan dat het stop met grappig zijn?'),
(15, 3, 'Beschrijf waarom Matt Stone een betere presidentskandidaat is dan Trey Parker:');
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `scale`
--
CREATE TABLE IF NOT EXISTS `scale` (
`question_id` int(11) NOT NULL,
`count` int(11) NOT NULL,
`low` varchar(255) NOT NULL,
`high` varchar(255) NOT NULL,
PRIMARY KEY (`question_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Gegevens worden uitgevoerd voor tabel `scale`
--
INSERT INTO `scale` (`question_id`, `count`, `low`, `high`) VALUES
(2, 5, 'Helemaal niet', 'Fantastisch'),
(4, 5, 'Heel donker', 'Heel licht'),
(9, 5, 'Best veel', 'Ontzettend veel'),
(14, 5, 'Helemaal niet waarschijnlijk', 'Zeer waarschijnlijk');
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `survey`
--
CREATE TABLE IF NOT EXISTS `survey` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Gegevens worden uitgevoerd voor tabel `survey`
--
INSERT INTO `survey` (`id`, `title`) VALUES
(1, 'Kleuren'),
(2, 'Computers'),
(3, 'South Park');
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Gegevens worden uitgevoerd voor tabel `user`
--
INSERT INTO `user` (`id`, `name`, `password`) VALUES
(1, 'andra', 'andra'),
(2, 'maarten', 'maarten');
-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `user_survey`
--
CREATE TABLE IF NOT EXISTS `user_survey` (
`user_id` int(11) NOT NULL,
`survey_id` int(11) NOT NULL,
`completed` bit(1) NOT NULL DEFAULT b'0',
`question_pointer` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`user_id`,`survey_id`),
KEY `survey_id` (`survey_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Gegevens worden uitgevoerd voor tabel `user_survey`
--
INSERT INTO `user_survey` (`user_id`, `survey_id`, `completed`, `question_pointer`) VALUES
(1, 1, b'1', 1),
(1, 2, b'1', 1),
(2, 1, b'1', 1),
(2, 2, b'1', 1),
(2, 3, b'0', 1);
--
-- Beperkingen voor gedumpte tabellen
--
--
-- Beperkingen voor tabel `answer`
--
ALTER TABLE `answer`
ADD CONSTRAINT `answer_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `answer_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Beperkingen voor tabel `answer_option`
--
ALTER TABLE `answer_option`
ADD CONSTRAINT `answer_option_ibfk_1` FOREIGN KEY (`answer_id`) REFERENCES `answer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `answer_option_ibfk_2` FOREIGN KEY (`option_id`) REFERENCES `option` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Beperkingen voor tabel `answer_scale`
--
ALTER TABLE `answer_scale`
ADD CONSTRAINT `answer_scale_ibfk_1` FOREIGN KEY (`answer_id`) REFERENCES `answer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Beperkingen voor tabel `option`
--
ALTER TABLE `option`
ADD CONSTRAINT `option_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Beperkingen voor tabel `question`
--
ALTER TABLE `question`
ADD CONSTRAINT `question_ibfk_1` FOREIGN KEY (`survey_id`) REFERENCES `survey` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Beperkingen voor tabel `scale`
--
ALTER TABLE `scale`
ADD CONSTRAINT `scale_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Beperkingen voor tabel `user_survey`
--
ALTER TABLE `user_survey`
ADD CONSTRAINT `user_survey_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `user_survey_ibfk_2` FOREIGN KEY (`survey_id`) REFERENCES `survey` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
509e4b703eba56330deab2edafe4eedf1941b28d | SQL | jeisux92/store-api | /Store.SqlScripts/i1/CreateSaleTable.sql | UTF-8 | 388 | 3.609375 | 4 | [] | no_license | USE Store
IF NOT EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'dbo.Sale')
)
BEGIN
CREATE TABLE dbo.Sale(
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
CustomerId BIGINT NOT NULL,
Total BIGINT NOT NULL,
CreatedOn DATETIME DEFAULT GETDATE(),
CONSTRAINT FK_SalesCustomer FOREIGN KEY (CustomerId) REFERENCES Customer(IdentificationNumber)
)
END | true |
db26f1cbaa9200573a239ef3e7be74abc6ff3f17 | SQL | cristidrincu/gamersmarket | /src/main/resources/db/migrations/V4.1__AddHardwareItemIdFKToMouse.sql | UTF-8 | 214 | 3 | 3 | [] | no_license | ALTER TABLE gamers_market.hw_item_mouse
ADD COLUMN hw_item_id INTEGER;
ALTER TABLE gamers_market.hw_item_mouse
ADD CONSTRAINT fk_hardware_item_id FOREIGN KEY(hw_item_id)
REFERENCES gamers_market.hardware_item(id); | true |
7d5c716ffcc0980c5aea913b8f5e06e2ec376705 | SQL | dhoer/flyway | /flyway-core/src/test/resources/org/flywaydb/core/internal/dbsupport/saphana/procedures/procedure.sql | UTF-8 | 1,781 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | --
-- Copyright 2010-2017 Boxfuse GmbH
--
-- 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 agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- just to have one statement before the actual test statement
CREATE VIEW all_misters AS SELECT * FROM test_user WHERE name LIKE 'Mr.%';
-- create statement with embedded ';'
-- it is expected that this statement is read as a single statement ending after 'END;'
-- and not broken into separate statements ending after each ';' withing the BEGIN...END-block.
-- this example statement is borrowed from the HANA reference for
-- CREATE PROCEDURE (http://help-legacy.sap.com/saphelp_hanaplatform/helpdata/en/20/d467407519101484f190f545d54b24/content.htm)
CREATE PROCEDURE orchestrationProc
LANGUAGE SQLSCRIPT AS
BEGIN
DECLARE v_id BIGINT;
DECLARE v_name VARCHAR(30);
DECLARE v_pmnt BIGINT;
DECLARE v_msg VARCHAR(200);
DECLARE CURSOR c_cursor1 (p_payment BIGINT) FOR
SELECT id, name, payment FROM control_tab
WHERE payment > :p_payment ORDER BY id ASC;
CALL init_proc();
OPEN c_cursor1(250000);
FETCH c_cursor1 INTO v_id, v_name, v_pmnt; v_msg := :v_name || ' (id ' || :v_id || ') earns ' || :v_pmnt || ' $.';
CALL ins_msg_proc(:v_msg);
CLOSE c_cursor1;
END;
-- just to have a trailing statement for testing
DROP VIEW all_misters; | true |
e3f74249b6a597fdac78fa276e619ed1a2e5e133 | SQL | duke326/SWE-241 | /SWE-243/ex_solutions/ch12/ex12-01.sql | UTF-8 | 304 | 3.296875 | 3 | [] | no_license | CREATE OR REPLACE VIEW open_items
AS
SELECT vendor_name, invoice_number, invoice_total,
invoice_total - payment_total - credit_total AS balance_due
FROM vendors JOIN invoices
ON vendors.vendor_id = invoices.vendor_id
WHERE invoice_total - payment_total - credit_total > 0
ORDER BY vendor_name | true |
c43b1a4063bef4925ad497e160f44334d6528af8 | SQL | radtek/abs3 | /sql/mmfo/bars/Trigger/tiu_zp_upd.sql | UTF-8 | 2,182 | 3.09375 | 3 | [] | no_license | create or replace trigger tiu_zp_upd
after insert or update
on bars.zp_deals
for each row
declare
l_idupd zp_deals_update.idupd%type;
l_doneby zp_deals_update.upd_user_fio%type;
l_doneby_id zp_deals_update.upd_user_id%type;
begin
l_idupd := bars_sqnc.get_nextval ('s_zp_deals_update');
l_doneby_id := user_id;
begin
select fio
into l_doneby
from staff$base
where id = user_id;
exception
when no_data_found
then
l_doneby := user_name;
end;
insert into zp_deals_update (idupd,
id,
deal_id,
start_date,
close_date,
deal_name,
rnk,
sos,
deal_premium,
central,
kod_tarif,
acc_2909,
acc_3570,
branch,
kf,
user_id,
comm_reject,
crt_date,
upd_date,
fs,
upd_user_id,
upd_user_fio)
values (l_idupd,
:new.id,
:new.deal_id,
:new.start_date,
:new.close_date,
:new.deal_name,
:new.rnk,
:new.sos,
:new.deal_premium,
:new.central,
:new.kod_tarif,
:new.acc_2909,
:new.acc_3570,
:new.branch,
:new.kf,
:new.user_id,
:new.comm_reject,
:new.crt_date,
:new.upd_date,
:new.fs,
l_doneby_id,
l_doneby);
end tiu_zp_upd;
/ | true |
e8e03c0d395c50094056ad0217d43d560840d87f | SQL | VenelinBakalov/javaAdvanced | /Databases Basics/Exam-Preparation-I/18_update_trigger_WORKING.sql | UTF-8 | 638 | 3.90625 | 4 | [] | no_license | DELIMITER $$
CREATE TRIGGER tr_update_flight_status
BEFORE UPDATE
ON `flights`
FOR EACH ROW
BEGIN
IF
old.`status` NOT IN ('Cancelled', 'Arrived')
AND new.`status` = 'Arrived'
THEN
INSERT INTO `arrived_flights` (`flight_id`, `arrival_time`, `origin`, `destination`, `passengers`)
VALUES (old.flight_id, new.arrival_time,
(SELECT a.airport_name FROM airports AS a WHERE a.airport_id = new.origin_airport_id),
(SELECT a.airport_name FROM `airports` AS a WHERE a.airport_id = new.destination_airport_id),
(SELECT COUNT(*) FROM tickets AS t
WHERE t.flight_id = old.flight_id));
END IF;
END $$
DELIMITER ; | true |
deaf71030a481d1cc282c7a834f5dc6c43544eab | SQL | musicq/Koala | /_sql/secret.sql | UTF-8 | 1,249 | 3.265625 | 3 | [] | no_license | DROP DATABASE IF EXISTS secret;
CREATE DATABASE IF NOT EXISTS secret;
use secret;
create table register (
user_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
email CHAR(100) NOT NULL,
password CHAR(40) NOT NULL,
join_date DATETIME NOT NULL,
PRIMARY KEY (user_id, email)
) DEFAULT CHARSET=utf8;
create table user_info (
user_id INT UNSIGNED NOT NULL PRIMARY KEY,
user_name CHAR(60),
user_nickname CHAR(60) NOT NULL,
avatar CHAR(150),
gender CHAR(1),
birth DATETIME,
mydesc CHAR(70)
) DEFAULT CHARSET=utf8;
create table post_header (
user_id INT UNSIGNED NOT NULL,
post_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
post_date DATETIME
) DEFAULT CHARSET=utf8;
create table post_body (
post_id INT UNSIGNED NOT NULL PRIMARY KEY,
post CHAR(140)
) DEFAULT CHARSET=utf8;
create table post_img (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
post_id INT UNSIGNED NOT NULL,
img_src CHAR(150)
) DEFAULT CHARSET=utf8;
create table st_comment (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
post_id INT UNSIGNED NOT NULL,
comment CHAR(140),
parent INT UNSIGNED DEFAULT NULL
) DEFAULT CHARSET=utf8;
GRANT SELECT, UPDATE, INSERT, DELETE
ON secret.*
TO secret@localhost IDENTIFIED BY 'secret'; | true |
90f22cd62544fbf588c36768861650c0aa2bc77f | SQL | Doomy7/phpprj | /prj/school.sql | UTF-8 | 10,859 | 2.734375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 23, 2020 at 07:35 PM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.4.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
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 */;
--
-- Database: `school`
--
-- --------------------------------------------------------
--
-- Table structure for table `activity_log`
--
CREATE TABLE `activity_log` (
`aid` int(10) NOT NULL,
`log` varchar(500) DEFAULT NULL,
`time` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `activity_log`
--
INSERT INTO `activity_log` (`aid`, `log`, `time`) VALUES
(3, 'Teacher teacher logged in!', '2020/02/23 05:33:53pm'),
(4, 'Student Student1 logged in!', '2020/02/23 05:34:00pm'),
(5, 'Admin admin logged in!', '2020/02/23 05:34:13pm'),
(6, 'Admin admin logged in!', '2020/02/23 05:41:48pm'),
(7, 'Teacher teacher logged in!', '2020/02/23 05:43:12pm'),
(8, 'Teacher made following changes 55 3 4', '2020/02/23 05:43:25pm'),
(9, 'Teacher teacher logged in!', '2020/02/23 05:45:57pm'),
(10, 'Teacher made following changes 99 2 3', '2020/02/23 05:46:05pm'),
(11, 'Teacher teacher made following changes. Student: Student1 Student1 New mark: 59 On Lesson: Java I : 1', '2020/02/23 05:49:57pm'),
(12, 'Teacher teacher made following changes. Student: Student1 Student1 New mark: 45 On Lesson: Java I : 59', '2020/02/23 05:50:59pm'),
(16, 'Admin admin rejected George Psaraklas testteacher@test.com testteacher registration as teachers!', '2020/02/23 07:03:28pm'),
(17, 'Admin admin rejected George Psaraklas teststudent@test.com teststudent registration as students!', '2020/02/23 07:03:39pm'),
(18, 'Admin admin accepted timestud timestud timestud@time.cim timestud registration as students!', '2020/02/23 07:27:58pm'),
(19, 'timestud timestud timestud@time.cim timestud added as students!', '2020/02/23 07:27:58pm'),
(20, 'Admin admin rejected Exipnos Exipnakias exipnos@idiofiia.com mathiths registration as teachers!', '2020/02/23 07:28:18pm'),
(21, 'Admin admin accepted timeteach timetre timeteach@time.com timeteach registration as teachers!', '2020/02/23 07:28:32pm'),
(22, 'timeteach timetre timeteach@time.com timeteach added as teachers!', '2020/02/23 07:28:32pm');
-- --------------------------------------------------------
--
-- Table structure for table `admins`
--
CREATE TABLE `admins` (
`aid` int(10) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`surname` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `admins`
--
INSERT INTO `admins` (`aid`, `name`, `surname`, `email`, `password`, `username`) VALUES
(1, 'fdgfdgh', 'dfghdgf', 'admin@email.com', '$2y$10$dfs.yVCD0Y7gqE.XL4qVB.ZVyIvoWl3Tpj2UmAr7Bea4ZbWbMQMnS', 'admin');
-- --------------------------------------------------------
--
-- Table structure for table `admin_hashes`
--
CREATE TABLE `admin_hashes` (
`hash_id` int(10) NOT NULL,
`hash` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `admin_hashes`
--
INSERT INTO `admin_hashes` (`hash_id`, `hash`) VALUES
(1, '1'),
(2, '2'),
(3, '3');
-- --------------------------------------------------------
--
-- Table structure for table `lessons`
--
CREATE TABLE `lessons` (
`lid` int(5) NOT NULL,
`name` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `lessons`
--
INSERT INTO `lessons` (`lid`, `name`) VALUES
(1, 'Java I'),
(2, 'Java II'),
(3, 'Introduction to Computer Science'),
(4, 'Discrete Mathematics'),
(5, 'Algorithms');
-- --------------------------------------------------------
--
-- Table structure for table `marks`
--
CREATE TABLE `marks` (
`sid` int(5) NOT NULL,
`lid` int(5) NOT NULL,
`mark` int(3) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `marks`
--
INSERT INTO `marks` (`sid`, `lid`, `mark`) VALUES
(2, 1, 45),
(2, 2, 65),
(2, 3, 99),
(3, 2, 75),
(3, 4, 55),
(3, 5, 25);
-- --------------------------------------------------------
--
-- Table structure for table `students`
--
CREATE TABLE `students` (
`sid` int(5) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`surname` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `students`
--
INSERT INTO `students` (`sid`, `name`, `surname`, `email`, `password`, `username`) VALUES
(2, 'Student1', 'Student1', 'Student1@school.com', '$2y$10$wMj8hDwzgSUvBX8yZwGUguYpOUEbd5c90otzi0ZrooFWJ80pRIRv.', 'Student1'),
(3, 'Student2', 'Student2', 'Student2@school.com', '$2y$10$v8yTvwCeterF9aY2H/EuGuknO9KockevTAqWNSsIE2T5AzEO8JnpC', 'Student2'),
(4, 'Student3', 'Student3', 'Student3@school.com', '$2y$10$ecaxR/kKIKYee/Sv6ll88ejjM9hFR.T2ykTqrnoprcd/OUFNYzPLS', 'Student3'),
(5, 'Psaraki', 'Psaraklas', 'fish@sea.com', '$2y$10$d3VcGpD3SigJQKtZKtNRdO65IHuK0LGVU43tKQyIKM8uV7yz8YP2u', 'Fish'),
(9, 'timestud', 'timestud', 'timestud@time.cim', '$2y$10$1rHFqrMwHyPGvWplM9CFLuwoc5rwrhS47Sn7Sj6D5yY6hJRIZOVKW', 'timestud');
-- --------------------------------------------------------
--
-- Table structure for table `students_verify`
--
CREATE TABLE `students_verify` (
`vid` int(5) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`surname` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL,
`time` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `students_verify`
--
INSERT INTO `students_verify` (`vid`, `name`, `surname`, `email`, `password`, `username`, `time`) VALUES
(7, 'student', 'student', 'asfafa@email.com', '$2y$10$Su0F.iTrbO.Uju.wDuCBsOK4XdgC/52Vrp5ZQNbkc3N/.KgaCUjWq', 'iamastudent', '2020/02/23 07:30:29pm');
-- --------------------------------------------------------
--
-- Table structure for table `teachers`
--
CREATE TABLE `teachers` (
`tid` int(3) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`surname` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `teachers`
--
INSERT INTO `teachers` (`tid`, `name`, `surname`, `email`, `password`, `username`) VALUES
(1, 'sdfas', 'asdfas', 'dm@email.com', '$2y$10$J6qIjV/IxtJipWHuMsakAeec5ynxIGy2tY9Tx/of3wF6xIc0Ww252', 'legit'),
(2, 'Teacher1', 'Teacher1', 'Teacher1@school.com', '$2y$10$8l8mB4rwGsXVulbVlYLGUeQQxegauuqBY6DKTomiiv.CSBrauZ1xG', 'Teacher1'),
(3, 'Teacher2', 'Teacher2', 'Teacher2@school.com', '$2y$10$yzxC9zmtla3hg.WTGNFTfO3NyDa/RhtpWfWHTV/lpIvdv0XFIjFYO', 'Teacher2'),
(4, 'timeteach', 'timetre', 'timeteach@time.com', '$2y$10$n8oWFaCrb/OQP43eT1MRpuaVm5WBT/ogvxRGYY0gS6jvWH10m93mO', 'timeteach');
-- --------------------------------------------------------
--
-- Table structure for table `teachers_verify`
--
CREATE TABLE `teachers_verify` (
`vid` int(3) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`surname` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL,
`time` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `teachers_verify`
--
INSERT INTO `teachers_verify` (`vid`, `name`, `surname`, `email`, `password`, `username`, `time`) VALUES
(11, 'teasasd', 'dsfsdfsd', 'teacher2131@email.com', '$2y$10$c5Lo7Bwy0hNnafraKgubT.q0zeGNyYgoY2fpvrS4nUT.i47HsjZAm', 'teacher2131', '2020/02/23 07:30:51pm');
-- --------------------------------------------------------
--
-- Table structure for table `teaches`
--
CREATE TABLE `teaches` (
`tid` int(3) NOT NULL,
`lid` int(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `activity_log`
--
ALTER TABLE `activity_log`
ADD PRIMARY KEY (`aid`);
--
-- Indexes for table `admins`
--
ALTER TABLE `admins`
ADD PRIMARY KEY (`aid`);
--
-- Indexes for table `admin_hashes`
--
ALTER TABLE `admin_hashes`
ADD PRIMARY KEY (`hash_id`);
--
-- Indexes for table `lessons`
--
ALTER TABLE `lessons`
ADD PRIMARY KEY (`lid`);
--
-- Indexes for table `marks`
--
ALTER TABLE `marks`
ADD PRIMARY KEY (`sid`,`lid`),
ADD KEY `lid` (`lid`);
--
-- Indexes for table `students`
--
ALTER TABLE `students`
ADD PRIMARY KEY (`sid`);
--
-- Indexes for table `students_verify`
--
ALTER TABLE `students_verify`
ADD PRIMARY KEY (`vid`);
--
-- Indexes for table `teachers`
--
ALTER TABLE `teachers`
ADD PRIMARY KEY (`tid`);
--
-- Indexes for table `teachers_verify`
--
ALTER TABLE `teachers_verify`
ADD PRIMARY KEY (`vid`);
--
-- Indexes for table `teaches`
--
ALTER TABLE `teaches`
ADD PRIMARY KEY (`tid`,`lid`),
ADD KEY `lid` (`lid`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `activity_log`
--
ALTER TABLE `activity_log`
MODIFY `aid` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT for table `admins`
--
ALTER TABLE `admins`
MODIFY `aid` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `admin_hashes`
--
ALTER TABLE `admin_hashes`
MODIFY `hash_id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `lessons`
--
ALTER TABLE `lessons`
MODIFY `lid` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `students`
--
ALTER TABLE `students`
MODIFY `sid` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `students_verify`
--
ALTER TABLE `students_verify`
MODIFY `vid` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `teachers`
--
ALTER TABLE `teachers`
MODIFY `tid` int(3) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `teachers_verify`
--
ALTER TABLE `teachers_verify`
MODIFY `vid` int(3) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `admins`
--
ALTER TABLE `admins`
ADD CONSTRAINT `admins_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `admin_hashes` (`hash_id`);
--
-- Constraints for table `marks`
--
ALTER TABLE `marks`
ADD CONSTRAINT `marks_ibfk_1` FOREIGN KEY (`sid`) REFERENCES `students` (`sid`),
ADD CONSTRAINT `marks_ibfk_2` FOREIGN KEY (`lid`) REFERENCES `lessons` (`lid`);
--
-- Constraints for table `teaches`
--
ALTER TABLE `teaches`
ADD CONSTRAINT `teaches_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `teachers` (`tid`),
ADD CONSTRAINT `teaches_ibfk_2` FOREIGN KEY (`lid`) REFERENCES `lessons` (`lid`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
9db76678d0abff463c8be4cae960c630898e4b9b | SQL | BenjaminS01/test1 | /WineProject/src/database/implementation_skript.sql | UTF-8 | 7,106 | 3.546875 | 4 | [] | no_license |
DROP DATABASE IF EXISTS SKWD;
CREATE DATABASE IF NOT EXISTS SKWD;
USE SKWD;
--
DROP TABLE IF EXISTS Address;
CREATE TABLE IF NOT EXISTS Address(
id int NOT NULL AUTO_INCREMENT,
country varchar(50) NOT NULL,
city varchar(50) NOT NULL,
zip varchar(15) NOT NULL,
street varchar(50) NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Address_PK PRIMARY KEY (id)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS Customer;
CREATE TABLE IF NOT EXISTS Customer(
id int NOT NULL AUTO_INCREMENT,
firstName varchar(50) NOT NULL,
lastName varchar(50) NOT NULL,
gender enum('m', 'f', 'd') not null,
dateOfBirth date NOT NULL,
phoneNumber varchar(20) NULL,
addressID int NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Customer_PK PRIMARY KEY (id),
CONSTRAINT Customer_FK FOREIGN KEY (addressID) REFERENCES Address (id)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS Account;
CREATE TABLE IF NOT EXISTS Account(
id int NOT NULL AUTO_INCREMENT,
email varchar(50) NOT NULL,
password varchar(255)NOT NULL,
customerID int NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Account_PK PRIMARY KEY (id),
CONSTRAINT Account_FK FOREIGN KEY (customerID) REFERENCES Customer (id),
CONSTRAINT Customer_UQ unique (email)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS Vendor;
CREATE TABLE IF NOT EXISTS Vendor(
vendorID int NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
description varchar(100) NULL,
phoneNumber varchar(20) NOT NULL,
email varchar(50) NOT NULL,
addressID int NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Vendor_PK PRIMARY KEY (vendorID),
CONSTRAINT Vendor_FK FOREIGN KEY (addressID) REFERENCES Address (id),
CONSTRAINT Vendor_UQ unique (email)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS Product;
CREATE TABLE IF NOT EXISTS Product(
id int NOT NULL AUTO_INCREMENT,
prodName varchar(100)NOT NULL,
description text NULL,
standardPrice decimal(7,2)NOT NULL,
productType enum('Drink','Accessory') NOT NULL,
vendorID int NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Product_PK PRIMARY KEY (id),
CONSTRAINT Product_FK FOREIGN KEY (vendorID) REFERENCES Vendor (vendorID)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS Picture;
CREATE TABLE IF NOT EXISTS Picture(
id int NOT NULL AUTO_INCREMENT,
path varchar(200)NOT NULL,
productID int NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Pictur_PK PRIMARY KEY (id),
CONSTRAINT Picture_FK FOREIGN KEY (productID) REFERENCES Product (id)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS Property;
CREATE TABLE IF NOT EXISTS Property(
id int NOT NULL AUTO_INCREMENT,
name varchar(50) not null,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Property_PK PRIMARY KEY (id)
);
-- ---------------------------------------------------------
DROP TABLE IF EXISTS PropertyProProduct;
CREATE TABLE IF NOT EXISTS PropertyProProduct(
id int NOT NULL AUTO_INCREMENT,
productID int not null,
propertyID int not null,
value varchar(60) not null,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT ppp_PK PRIMARY KEY (id),
CONSTRAINT product_FKK FOREIGN KEY(productID) references Product(id),
CONSTRAINT property_FKK FOREIGN KEY(propertyID) references Property(id)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS Orders;
CREATE TABLE IF NOT EXISTS Orders(
id int NOT NULL AUTO_INCREMENT,
orderDate date NOT NULL,
shipDate date NULL,
shipPrice decimal(9,2)not null,
payStatus enum('unpaid','paid') NOT NULL,
payMethod enum('transfer','cash on delivery','paypal') NOT NULL,
payDate date NULL,
customerID int NOT NULL,
addressID int NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Order_PK PRIMARY KEY (id),
CONSTRAINT Basket_FK_Customer FOREIGN KEY (customerID) REFERENCES Customer (id),
CONSTRAINT Basket_FK_Address FOREIGN KEY (addressID) REFERENCES Address (id)
);
-- ---------------------------------------------------------
--
DROP TABLE IF EXISTS OrderItem;
CREATE TABLE IF NOT EXISTS OrderItem(
id int NOT NULL AUTO_INCREMENT,
actualPrice decimal(9,2)NOT NULL,
qty int(5) NOT NULL,
productID int NOT NULL,
orderID int NOT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT Basket_PK PRIMARY KEY (id),
CONSTRAINT Basket_FK_Product FOREIGN KEY (productID) REFERENCES Product (id),
CONSTRAINT Basket_FK_Order FOREIGN KEY (orderID) REFERENCES Orders (id)
);
-- ----
DROP TABLE IF EXISTS ShoppingCart;
CREATE TABLE IF NOT EXISTS ShoppingCart(
id int not null AUTO_INCREMENT,
accountId int not null,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
constraint ShoppingCart_pk primary key(id),
constraint ShoppingCart_fk_Account foreign key(accountId) references Account(id)
);
-- ---------
CREATE OR REPLACE TABLE ShoppingCartItem(
id int not null AUTO_INCREMENT,
qty int not null,
actualPrice decimal(9,2)not null,
productID int not null,
shoppingCartId int not null,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
constraint ShoppingCartItem_pk primary key(id),
constraint ShoppingCartItem_fk_Product foreign key(productId) references Product(id),
constraint ShoppingCartItem_fk_ShoppingCart foreign key(shoppingCartId) references ShoppingCart(id));
CREATE OR REPLACE VIEW AllProducts as
select ppt.productID, prop.name, ppt.value
from property prop
join PropertyProProduct ppt on prop.id =ppt.propertyID
| true |
03d47cf5fdd05729dd16e297bdb8e7f3780e1836 | SQL | AlanoudBinSalamah/lab-w05d03-express-dictionary | /db/seed.sql | UTF-8 | 2,269 | 3.609375 | 4 | [] | no_license | DROP DATABASE IF EXISTS express_terms;
CREATE DATABASE express_terms;
\c express_terms
CREATE TABLE terms(
id serial primary key,
name varchar,
definition text
);
INSERT INTO terms(name, definition) VALUES
('server','a server is a computer that serves websites or data to a "client"'),
('module','a module is a javascript file in node. Modules allow us to make a single javascript app that has many javascript files!'),
('module.exports','module.exports is the part of a node module used for exporting data. Any data in the module.exports will then be accessible from other javascript files!'),
('require','`require` is a command that lets us import data from other javascript files. Any data that is exported with `module.exports` can be imported in another file using the `require` command.'),
('node','Node is a javascript runtime environment. It lets us run javascript without a browser.'),
('npm','npm stands for "Node Package Manager". NPM is a place where "packages" are hosted. You can install code from here to be used in your own application!'),
('package','A package is like a library. A piece of code written by other people that can be used inside our app.'),
('package.json','Package.json is a file that contains data about our application. It includes a lot of things like the name of our app, a description, the version number, etc. It also includes information about what packages we are using in our app. We create the package.json file automatically when we run "npm init"'),
('route','Routes are urls. A user can make a request to a route (like /cats or /greetings or /greetings/ali) to get data. When the request is sent to a server, the server looks at the route to decide what information should be returned to the user.'),
('request','requests are objects sent by users to "request" information. The request object contains a lot of information, including routes, parameters and other things that tell us what data the user wants.'),
('response','responses are the objects built by the server to be sent back to the user.'),
('parameter','parameters are part of the route. Users can send parameters to request a specific part of the data provided by a server. For example "/greetings/trevor"'); | true |
f6eb3c348d781501d4eb04e21ce5a2a36329f55d | SQL | silverdiva/cs313-new-node | /SQL/db-v2.sql | UTF-8 | 3,450 | 4.125 | 4 | [
"MIT"
] | permissive | /*
heroku postgress db name = postgresql-metric-65706
heroku cloud app name = shielded-reef-62106
use this command to login to heroku db in shielded-reef-62106 cloud app:
heroku pg:psql postgresql-metric-65706
after logging in you can run sql at cmd prompt to create , selecte, update db tables
shielded-reef-62106::DATABASE=>
*/
/*localhost db (MyPHPAdmin)*/
CREATE DATABASE familyhistory;
\c familyhistory;
/*localhost db (MyPHPAdmin)*/
CREATE USER admin_user WITH PASSWORD 'admin_pass';
GRANT SELECT, INSERT, UPDATE ON person TO admin_user;
GRANT USAGE, SELECT ON SEQUENCE person_id_seq TO admin_user;
/*localhost db (MyPHPAdmin) + heroku cloud app*/
CREATE TABLE person_table (
person_id serial PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
date_of_birth DATE
);
/*localhost db (MyPHPAdmin) + heroku cloud app*/
CREATE TABLE relationship_table (
parent_id int REFERENCES person_table(person_id),
child_id int REFERENCES person_table(person_id)
);
/*localhost db (MyPHPAdmin) + heroku cloud app*/
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Steve', 'Rodgers', '1918-07-04');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Peter', 'Parker', '1968-07-07');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Reed', 'Richards', '1966-01-16');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('James', 'Tanton', '1967-02-27');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES
('Kimberly', 'Llanos', '1967-04-01');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Joshua', 'Van Ness', '1989-09-08');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Karley', 'Quick', '1996-06-25');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Katelyn', 'Tanton', '2004-11-06');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Emily', 'Tanton', '2006-04-10');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Juan', 'Llanos', '1947-01-13');
INSERT INTO person_table(first_name, last_name, date_of_birth) VALUES ('Edith', 'Llanos', '1950-04-26');
INSERT INTO relationship_table VALUES (4, 8); -- James to Katelyn
INSERT INTO relationship_table VALUES (4, 9); -- James to Emily
INSERT INTO relationship_table VALUES (5, 6); -- Kimberly to Joshua
INSERT INTO relationship_table VALUES (5, 7); -- Kimberly to Karley
INSERT INTO relationship_table VALUES (5, 8); -- Kimberly to Katelyn
INSERT INTO relationship_table VALUES (5, 9); -- Kimberly to Emily
INSERT INTO relationship_table VALUES (10, 5); -- Juan to Kimberly
INSERT INTO relationship_table VALUES (11, 5); -- Edith to Kimberly
/*add whatever id you want to query here*/
SELECT FROM person_table first_name, last_name, date_of_birth WHERE (SELECT relationship_table.parent_id WHERE relationship_table.child_id = childID) = id;
SELECT person_id FROM person_table WHERE (SELECT parent_id WHERE child_id = childID) = id;
/*localhost db (MyPHPAdmin) + heroku cloud app*/
/*getPerson ->*/
SELECT * from person_table WHERE person_id = id;
/*localhost db (MyPHPAdmin) + heroku cloud app*/
/*getParents ->*/
SELECT parent_id FROM relationship_table WHERE child_id = id;
/*localhost db (MyPHPAdmin) + heroku cloud app*/
/*etChildren ->*/
SELECT child_id FROM relationship_table WHERE parent_id = id;
| true |
81e749c4b11826e357c678b1a863df893246016d | SQL | rgiordano66/InfoButtons | /DeploymentPackage/dbScripts/valueset_and_log.sql | UTF-8 | 1,748 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | CREATE DATABASE IF NOT EXISTS `valueset_and_log` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `valueset_and_log`;
/*!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 utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES table on this server
--
DROP TABLE IF EXISTS `subset_json`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `subset_json`
(
`id` INT(11) PRIMARY KEY NOT NULL,
`last_updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`name` VARCHAR(255) NOT NULL,
`value_set` LONGBLOB
)ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logs` (
`logsId` bigint(20) NOT NULL auto_increment,
`request` mediumtext,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`clientIP` varchar(45) NOT NULL,
`orgID` varchar(45) NOT NULL,
`response` mediumtext NULL
PRIMARY KEY (`logsId`)
) ENGINE=MyISAM AUTO_INCREMENT=106 DEFAULT CHARSET=latin1; | true |
b2e10f7b2d38849c7921722d22d9ffa53a25782d | SQL | malianggithub/works | /works/ruihua/file/全量脚本/全量sql脚本/个人客户信息表1.sql | UTF-8 | 3,282 | 3.046875 | 3 | [] | no_license |
select DISTINCT '${data_date}' DIS_DATA_DATE,
insuredno AS KHBH,
-- 客户编号
name AS XM,
-- 姓名
(case when sex='1' then '女性' when sex='0' then '男性' else '未说明的性别' end ) AS XB,
-- 性别
birthday AS CSRQ,
-- 出生日期
(select code from ldcode where codetype='idtype' and code=a.idtype) AS ZJLX,
-- 证件类型
idno AS ZJHM,
-- 证件号码
'' AS ZJYXQQ,
-- 证件有效起期
(case when a.IsLongValid is not null then '9999-12-31' else a.IDExpDate end) AS ZJYXZQ,
-- 证件有效止期
ifnull((select occupationcode from ldoccupation where occupationcode=a.occupationcode),'未记录') AS ZY, -- 20201224职业增加未记录判断
-- 职业
ifnull((select code from ldcode where codetype='nativeplace' and code=a.nativeplace),'未记录') AS GJ, -- 20201224国籍增加未记录判断
-- 国籍
#团险被保人客户系统不录
'未说明的婚姻状况' AS HYZK,
-- 婚姻状况
(select b.Mobile1 from LCCustomerContactInfo b where b.policyno=a.grpcontno and b.CustomerNo=a.insuredno limit 1) AS YDDH,
-- 移动电话
(select b.Phone from LCCustomerContactInfo b where b.policyno=a.grpcontno and b.CustomerNo=a.insuredno limit 1) AS GDDH,
-- 固定电话
(select b.EMail1 from LCCustomerContactInfo b where b.policyno=a.grpcontno and b.CustomerNo=a.insuredno limit 1) AS DZYX,
-- 电子邮箱
#团险客户系统不录学历
'' AS XL,
-- 学历
ifnull(Salary*12,'') AS GRNSR,
-- 个人年收入
ifnull((select b.province from LCCustomerContactInfo b where b.policyno=a.grpcontno and b.CustomerNo=a.insuredno limit 1),'000000') AS DZSZS, -- 20201224地址所在省增加未记录判断
-- 地址所在省
ifnull((select b.city from LCCustomerContactInfo b where b.policyno=a.grpcontno and b.CustomerNo=a.insuredno limit 1),'000000')AS DZSZDS, -- 20201224地址所在地市增加未记录判断
-- 地址所在地市
ifnull((select b.county from LCCustomerContactInfo b where b.policyno=a.grpcontno and b.CustomerNo=a.insuredno limit 1),'000000') AS DZSZQX, -- 20201224地址所在区县增加未记录判断
-- 地址所在区县
ifnull((select PostalAddress from LCCustomerContactInfo where policyno=a.grpcontno and CustomerNo=a.insuredno limit 1),'000000') AS JD
-- 街道 -- 20201224街道增加未记录判断
from lcinsured a where a.grpcontno != '00000000000000000000'
-- and a.makedate<'2021-01-01'
and a.contno=(select max(b.contno) from lcinsured b where b.insuredno=a.insuredno and grpcontno!='00000000000000000000' and makedate<'2021-01-01')
/* 20210101 增加排除不在集中采集范围内的数据 */
-- and not EXISTS(select 1 from lcinsured where insuredno=a.insuredno and grpcontno='00000000000000000000')
-- and a.contno=(select max(b.contno) from lcinsured b where b.insuredno=a.insuredno and grpcontno!='00000000000000000000')
-- 20201224增加
-- and not EXISTS(select 1 from lcinsured where insuredno=a.insuredno and grpcontno='00000000000000000000')
/* 20210108 增加判断 */
and not EXISTS(select 1 from lcinsured lc where lc.insuredno=a.insuredno and lc.grpcontno='00000000000000000000'
and lc.contno in (select cont.contno from lccont cont where cont.contno=lc.contno and cont.signdate<'2021-01-01')
)
| true |
bec98c23047f818d933952d226d85ff60e8a7245 | SQL | AndreiBV86/temp_converter | /SQLite3/sql_basics.sql | UTF-8 | 1,475 | 3.609375 | 4 | [] | no_license | --CREATE TABLE students (
--
-- first_name TEXT,
-- last_name TEXT,
-- age INTEGER
--
--);
--
--CREATE TABLE employees (
--
-- first_name TEXT,
-- last_name TEXT,
-- age INTEGER
--
--);
--
--SELECT * FROM students;
INSERT INTO employees (first_name, last_name, age) VALUES ("Ivan", "Ivanov", 25);
INSERT INTO employees (first_name, last_name, age) VALUES ("Petr", "Petrov", 27);
INSERT INTO employees (first_name, last_name, age) VALUES ("Olga", "Sidorova", 22);
INSERT INTO employees (first_name, last_name, age) VALUES ("Inna", "Zaharova", 29);
INSERT INTO employees (first_name, last_name, age) VALUES ("Ivan", "Ivanov", 25);
INSERT INTO employees (first_name, last_name, age) VALUES ("Petr", "Petrov", 27);
INSERT INTO employees (first_name, last_name, age) VALUES ("Olga", "Sidorova", 22);
INSERT INTO employees (first_name, last_name, age) VALUES ("Inna", "Zaharova", 29);
SELECT first_name, age FROM employees WHERE first_name IS "Ivan";
SELECT last_name, age FROM employees WHERE last_name IS NOT "Ivanov";
SELECT last_name, age FROM employees WHERE last_name IS NOT "Ivanov" AND age IS NOT 22;
SELECT last_name, age FROM employees WHERE age <= 25;
SELECT first_name, age FROM employees WHERE first_name LIKE "I%";
SELECT * FROM employees WHERE first_name LIKE "%a" OR age IS 25;
SELECT * FROM employees WHERE last_name LIKE "%ro%";
UPDATE employees SET first_name="Oleg" WHERE first_name=" Ivan";
DELETE FROM employees WHERE age IS 27;
| true |
f6bddad6798608b410cb07750602fc5ca4877bc4 | SQL | randy-chen/uocis322 | /sql/create_tables.sql | UTF-8 | 2,169 | 4.21875 | 4 | [] | no_license |
/* Since there aren't that many roles, they can be easilty kept track of as part of the users table.
also makes role selection when creating a new user easier to implement.
*/
/* Added a numeric primary key as usernames can have a mix of letters and numbers,
so having them as primary keys would make keeping track of the users more difficult.
The numeric pk helps us organize the users better. Both the username and password
fields have a maximum length of 16 characters, which is in accordance with the specs.
*/
CREATE TABLE users (
user_pk serial primary key,
username varchar(16),
password varchar(16),
role text,
active boolean
);
CREATE TABLE assets (
asset_pk serial primary key,
asset_tag varchar(16),
description text,
status text
);
CREATE TABLE facilities (
facility_pk serial primary key,
fcode varchar(6),
common_name varchar(32),
location text
);
/* Really, this table is more like 'asset history'. It keeps track of where an asset has been as well
when it arrived and was disposed. This table allows us to map assets to facilities with foreign keys.
*/
CREATE TABLE asset_at (
asset_fk integer references assets(asset_pk),
facility_fk integer references facilities(facility_pk),
arrival timestamp,
disposal timestamp
);
/* I decided to use one big table to handle all the information of a transfer request and
times in transit and the load times and unload times. It seemed unnecessary to have
separate tables keep track of an asset in motion and the requests behind putting that
asset in motion. This way all information is easily visible in one table, letting
the user track transfer requests as well as transit.
*/
CREATE TABLE transfers (
req_id serial primary key,
requester varchar(16),
tf_asset varchar(16),
req_dt timestamp,
src_fac varchar(6),
load_dt timestamp,
tf_status text,
des_fac varchar(6),
unload_dt timestamp,
approver varchar(16),
aprv_dt timestamp
);
| true |
5039d3bf12b5485b9d81f9ad7c5219078a0bece1 | SQL | Orathai18/project_1 | /guestbook.sql | UTF-8 | 799 | 3.078125 | 3 | [
"MIT"
] | permissive | --
-- โครงสร้างตาราง `guestbook`
--
CREATE TABLE `guestbook` (
`g_id` int(6) NOT NULL auto_increment,
`g_name` varchar(50) NOT NULL,
`g_email` varchar(50) NOT NULL,
`g_message` text NOT NULL,
`g_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`g_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- dump ตาราง `guestbook`
--
INSERT INTO `guestbook` VALUES (1, 'เอกชัย แน่นอุดร', 'nkcombat@hotmail.com', 'แวะมาทักทายครับ', '2014-10-26 11:24:39');
INSERT INTO `guestbook` VALUES (2, 'รักไทย ใจตะวัน', 'rukthai@msu.ac.th', 'สมุดเยี่ยมใช้งานได้ดีมาก', '2014-10-26 11:26:02');
| true |
2cfee3733c4689bd2962e1f14f7075955b782425 | SQL | lissette2019/inventarioRepo | /bd_crud.sql | UTF-8 | 1,691 | 2.890625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tiempo de generación: 22-02-2021 a las 02:11:40
-- Versión del servidor: 5.5.24-log
-- Versión de PHP: 5.4.3
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 utf8 */;
--
-- Base de datos: `bd_crud`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `empleados`
--
CREATE TABLE IF NOT EXISTS `empleados` (
`empleadoId` bigint(20) NOT NULL AUTO_INCREMENT,
`empleado` varchar(100) NOT NULL,
PRIMARY KEY (`empleadoId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
--
-- Volcado de datos para la tabla `empleados`
--
INSERT INTO `empleados` (`empleadoId`, `empleado`) VALUES
(4, 'Guerra Martinez'),
(7, 'Ezequiel Arevalo'),
(8, 'Claudia Carcamo');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `roles`
--
CREATE TABLE IF NOT EXISTS `roles` (
`rolId` bigint(20) NOT NULL AUTO_INCREMENT,
`nombre` varchar(100) NOT NULL,
PRIMARY KEY (`rolId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
--
-- Volcado de datos para la tabla `roles`
--
INSERT INTO `roles` (`rolId`, `nombre`) VALUES
(4, 'Super mega administrador '),
(6, 'Super admin');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
71cd554e60d8d2914c9b481288fc2329e9e04498 | SQL | KongouFer/6_semestre | /basesDatos/laboratorio/practicas/7/previo/s-00-asignaturas-elimina-usuario.sql | UTF-8 | 480 | 3.21875 | 3 | [
"MIT"
] | permissive | --@Autor: Alfonso Murrieta Villegas
--@Fecha creación: 19/04/2020
--@Descripción: Elimina al usuario sga_p07_previo en caso de existir.
set serveroutput on
declare
v_count number(1,0);
begin
select count(*) into v_count
from dba_users
where username ='AMV_P07_PREVIO';
if v_count > 0 then
execute immediate 'drop user AMV_P07_PREVIO cascade';
dbms_output.put_line('Usuario eliminado');
else
dbms_output.put_line('El usuario no existe, no se requiere eliminar');
end if;
end;
/ | true |
10f7f31d95607c00d6f1a46f6be769e71b7d6132 | SQL | xy63237777/ttms-master | /movies-manage-system/TTMSSQL/movies_Seat.sql | UTF-8 | 623 | 2.796875 | 3 | [] | no_license | create table movies_Seat(
ID int not null comment '分片算法规则',
movieSeat_Id bigint not null primary key auto_increment comment '座位的自增主键',
movieSeat_HallId bigint not null comment '座位关联的影厅',
movieSeat_IsBuy int not null comment '座位是否购买使用位运算 每一位代表一场演出计划的购买状态',
movieSeat_IsOk int not null comment '电影是否为好的',
movieSeat_State int not null comment '座位的状态',
movieSeat_X int not null comment '座位的横坐标',
movieSeat_Y int not null comment '座位的纵坐标'
)charset=utf8;
| true |
023cb66a614444df5275e633f22ebf73bd29a620 | SQL | santhoshmathavan/Payoda_Learning | /Day-1/Assignment2.sql | UTF-8 | 659 | 4.25 | 4 | [] | no_license | SELECT customer_id,order_status
FROM orders
WHERE order_id=1;
CREATE INDEX idx ON orders(order_id,store_id);
drop index idx on orders;
Explain SELECT * FROM orders
where order_id=1
and store_id=1;
select P.product_name,B.brand_name
from brands B
inner join products P
on P.brand_id = B.brand_id
and B.brand_name='Nike';
create index od_Idx ON orders(order_id,customer_id);
create index cus_idx on customers(customer_id);
-- create index full_name on customers(first_name,last_name);
SELECT orders.order_id, customers.first_name,customers.last_name
FROM orders
INNER JOIN customers ON orders.customer_id = customers.customer_id;
show index from orders; | true |
979b596ad432f13050862542af7c9655b4f003e1 | SQL | appnewtechs/indicadores_10_03_2017 | /sql/Script teste de chamadas e evento.sql | UTF-8 | 954 | 2.75 | 3 | [] | no_license |
/*
call somarTop5Dia();
call somarTop5Mes();
call somarTop5Ano();
call somarIndicadores();
*/
select * from top5GruposMes;
select * from top5ProdutosMes;
select * from top5VendedorMes;
select * from top5GruposAno;
select * from top5ProdutosAno;
select * from top5VendedorAno;
select * from top5GruposDia;
select * from top5ProdutosDia;
select * from top5VendedorDia;
/*
delete from indicadores_loja_ano;
delete from indicadores_loja_dia;
delete from indicadores_loja_mes;
delete from top5GruposDia;
delete from top5ProdutosDia;
delete from top5VendedorDia;
delete from top5GruposAno;
delete from top5ProdutosAno;
delete from top5VendedorAno;
delete from top5GruposMes;
delete from top5ProdutosMes;
delete from top5VendedorMes;
*/
/*
select * FROM indicadores_loja_ano;
select * FROM indicadores_loja_mes;
select * FROM indicadores_loja_dia
select SYSDATE()
SHOW EVENTS FROM indicadores;
SHOW PROCESSLIST
SET GLOBAL event_scheduler = ON;
*/
| true |
700496f79bc81d108e4bc8d82fa2e511a2c693e2 | SQL | Kenna-D/Personal-Project | /db/orders/delete_order.sql | UTF-8 | 213 | 2.90625 | 3 | [] | no_license | DELETE FROM love_your_shelf_ordered_products
WHERE ordered_products_id = $1;
SELECT * FROM love_your_shelf_ordered_products op
JOIN love_your_shelf_products p on p.product_id = op.product_id
WHERE op.user_id = $2; | true |
33b27afcd9688611910bf19b8f88bcc60476da78 | SQL | cevian/timescaledb | /test/sql/c_unit_tests.sql | UTF-8 | 596 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"PostgreSQL",
"LicenseRef-scancode-free-unknown"
] | permissive | -- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE OR REPLACE FUNCTION ts_test_time_to_internal_conversion() RETURNS VOID
AS :MODULE_PATHNAME LANGUAGE C VOLATILE;
CREATE OR REPLACE FUNCTION ts_test_interval_to_internal_conversion() RETURNS VOID
AS :MODULE_PATHNAME LANGUAGE C VOLATILE;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
SELECT ts_test_time_to_internal_conversion();
SELECT ts_test_interval_to_internal_conversion();
| true |
11b04bb162dd8763ef0f071a7fdde4f4625e4a8e | SQL | jongvin/werp | /werp/erpw/general/t_web/개발자공유풀/khs_query_test.sql | UHC | 111,881 | 3.15625 | 3 | [] | no_license | select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and rownum < 2
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where Not exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and rownum < 2
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where Not exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) Not in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) Not in
(
select
t3.owner,t3.table_name
from t3
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) Not in
(
select
distinct
t3.owner,t3.table_name
from t3
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and rownum < 2
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
and rownum < 2
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and rownum < 2
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
/
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
and rownum < 2
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t3.column_name = 'TABLE_NAME'
)
/
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
where t3.column_name = 'TABLE_NAME'
)
/
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
/
select /*+RULE*/
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
/
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 09:29:52 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 09:29:52 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_2632.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and rownum < 2
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 2.31 7.21 26150 529131 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 2.31 7.21 26150 529131 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
30376 FILTER
259392 TABLE ACCESS FULL T1
29912 COUNT STOPKEY
29912 INDEX RANGE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.65 5.60 26353 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.65 5.60 26353 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.75 5.74 26598 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.75 5.74 26598 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.59 5.50 26353 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.59 5.51 26353 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.71 5.89 26353 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.71 5.89 26353 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 6 0.00 0.00 0 0 0 0
Execute 7 0.00 0.00 0 0 0 0
Fetch 10 5.03 29.96 131807 635207 0 5
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 23 5.03 29.97 131807 635207 0 5
Misses in library cache during parse: 5
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
7 user SQL statements in session.
0 internal SQL statements in session.
7 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_2632.trc
Trace file compatibility: 9.00.01
Sort options: default
2 sessions in tracefile.
7 user SQL statements in trace file.
0 internal SQL statements in trace file.
7 SQL statements in trace file.
7 unique SQL statements in trace file.
162 lines in trace file.
PL/SQL ó ϷǾϴ.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 09:38:48 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 09:38:48 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_2632.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and rownum < 2
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 2.31 7.21 26150 529131 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 2.31 7.21 26150 529131 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
30376 FILTER
259392 TABLE ACCESS FULL T1
29912 COUNT STOPKEY
29912 INDEX RANGE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.65 5.60 26353 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.65 5.60 26353 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.75 5.74 26598 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.75 5.74 26598 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.59 5.50 26353 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.59 5.51 26353 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.71 5.89 26353 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.71 5.89 26353 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 3 0.00 0.00 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 6 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where Not exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and rownum < 2
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 4 4.51 14.84 52426 1058262 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 4.51 14.84 52426 1058262 0 2
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
229016 FILTER
259392 TABLE ACCESS FULL T1
29912 COUNT STOPKEY
29912 INDEX RANGE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where Not exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.01 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 4 4.40 14.42 51864 1058262 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 4.42 14.42 51864 1058262 0 2
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
229016 FILTER
259392 TABLE ACCESS FULL T1
29912 INDEX RANGE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) Not in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.01 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 4 4.23 18.11 51873 1058262 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 4.25 18.12 51873 1058262 0 2
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
229016 FILTER
259392 TABLE ACCESS FULL T1
29912 INDEX RANGE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) Not in
(
select
t3.owner,t3.table_name
from t3
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 4 1.51 17.59 55736 53038 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 1.51 17.59 55736 53038 0 2
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
229016 HASH JOIN ANTI
259392 TABLE ACCESS FULL T1
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) Not in
(
select
distinct
t3.owner,t3.table_name
from t3
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 4 1.65 17.24 55767 53038 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 1.65 17.24 55767 53038 0 2
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
229016 HASH JOIN ANTI
259392 TABLE ACCESS FULL T1
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 18 0.03 0.01 0 0 0 0
Execute 21 0.00 0.00 0 0 0 0
Fetch 30 21.35 112.19 399473 3916069 0 15
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 69 21.39 112.20 399473 3916069 0 15
Misses in library cache during parse: 10
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
21 user SQL statements in session.
0 internal SQL statements in session.
21 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_2632.trc
Trace file compatibility: 9.00.01
Sort options: default
3 sessions in tracefile.
35 user SQL statements in trace file.
0 internal SQL statements in trace file.
21 SQL statements in trace file.
12 unique SQL statements in trace file.
424 lines in trace file.
PL/SQL ó ϷǾϴ.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 09:47:40 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 09:47:40 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_2504.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 74
********************************************************************************
select null
from
dual
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 3 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.00 0.00 0 3 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 74
Rows Row Source Operation
------- ---------------------------------------------------
1 TABLE ACCESS FULL DUAL
********************************************************************************
begin sys.dbms_application_info.set_module('PL/SQL Developer', :action); end;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 1
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 74
********************************************************************************
begin
if :enable = 0 then
sys.dbms_output.disable;
else
sys.dbms_output.enable(:size);
end if;
end;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 1
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 74
********************************************************************************
begin :id := sys.dbms_transaction.local_transaction_id; end;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 2
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 0 0 2
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 74
********************************************************************************
select 'x'
from
dual
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 3 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.00 0.00 0 3 0 1
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 74
Rows Row Source Operation
------- ---------------------------------------------------
1 TABLE ACCESS FULL DUAL
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and rownum < 2
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 1.42 6.63 26274 232523 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 1.42 6.63 26274 232523 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
19432 FILTER
259392 TABLE ACCESS FULL T1
19432 COUNT STOPKEY
19432 FILTER
19432 INDEX RANGE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.50 6.23 26897 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.51 6.23 26897 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
205000 HASH JOIN
107808 TABLE ACCESS FULL T1
25641 INDEX FAST FULL SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.56 7.28 27387 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.56 7.28 27387 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
205000 HASH JOIN
107808 TABLE ACCESS FULL T1
25641 INDEX FAST FULL SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.70 6.30 26897 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.70 6.30 26897 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
205000 HASH JOIN
107808 TABLE ACCESS FULL T1
25641 INDEX FAST FULL SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.48 6.08 26897 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.50 6.08 26897 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
205000 HASH JOIN
107808 TABLE ACCESS FULL T1
25641 INDEX FAST FULL SCAN PK_T3 (object id 37136)
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 12 0.03 0.00 0 0 0 0
Execute 14 0.00 0.00 0 0 0 4
Fetch 12 3.67 32.54 134352 338605 0 7
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 38 3.70 32.55 134352 338605 0 11
Misses in library cache during parse: 7
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
14 user SQL statements in session.
0 internal SQL statements in session.
14 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_2504.trc
Trace file compatibility: 9.00.01
Sort options: default
3 sessions in tracefile.
21 user SQL statements in trace file.
0 internal SQL statements in trace file.
14 SQL statements in trace file.
12 unique SQL statements in trace file.
240 lines in trace file.
PL/SQL ó ϷǾϴ.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:04:59 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:04:59 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_1988.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
and rownum < 2
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.53 6.01 26266 26307 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.53 6.01 26266 26307 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 FILTER
259392 TABLE ACCESS FULL T1
8 COUNT STOPKEY
8 FILTER
8 INDEX RANGE SCAN PK_T3 (object id 37136)
SQL> @utlxpls
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 37 | 46 |
| 1 | SORT AGGREGATE | | 1 | 37 | |
|* 2 | FILTER | | | | |
| 3 | TABLE ACCESS FULL | T1 | 1621 | 59977 | 44 |
|* 4 | COUNT STOPKEY | | | | |
|* 5 | FILTER | | | | |
|* 6 | INDEX RANGE SCAN| PK_T3 | 1 | 19 | 2 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
--------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter( EXISTS (SELECT /*+ */ 0 FROM "T3" "T3" WHERE :B1='
ACCESS$' AND :B2='SYS' AND ROWNUM<2 AND "T3"."TABLE
_NAME"=:B3 AND "T3"."OWNER"=:B4))
4 - filter(ROWNUM<2)
5 - filter(:B1='ACCESS$' AND :B2='SYS')
6 - access("T3"."OWNER"=:B1 AND "T3"."TABLE_NAME"=:B2)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Note: cpu costing is off
24 õǾϴ.
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 56 | 3 |
| 1 | SORT AGGREGATE | | 1 | 56 | |
| 2 | MERGE JOIN CARTESIAN | | 10 | 560 | 3 |
| 3 | TABLE ACCESS BY INDEX ROWID | T1 | 1 | 37 | 2 |
|* 4 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
| 5 | BUFFER SORT | | 12 | 228 | 1 |
| 6 | FIRST ROW | | 12 | 228 | 1 |
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
|* 7 | INDEX RANGE SCAN (MIN/MAX)| PK_T3 | 12 | | 1 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("T1"."OWNER"='SYS' AND "T1"."OBJECT_NAME"='ACCESS$')
7 - access("T3"."OWNER"='SYS' AND "T3"."TABLE_NAME"='ACCESS$')
Note: cpu costing is off
21 õǾϴ.
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 21 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 21 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 NESTED LOOPS
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 FIRST ROW
8 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 56 | 3 |
| 1 | SORT AGGREGATE | | 1 | 56 | |
| 2 | NESTED LOOPS | | 1 | 56 | 3 |
| 3 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 37 | 2 |
|* 4 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
| 5 | FIRST ROW | | 1 | 19 | 1 |
|* 6 | INDEX RANGE SCAN (MIN/MAX)| PK_T3 | 1 | | 1 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("T1"."OWNER"='SYS' AND "T1"."OBJECT_NAME"='ACCESS$')
6 - access("T3"."OWNER"='SYS' AND "T3"."TABLE_NAME"='ACCESS$')
filter("T1"."OWNER"="T3"."OWNER" AND "T1"."OBJECT_NAME"="T3"."TABLE
_NAME")
Note: cpu costing is off
22 õǾϴ.
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 56 | 3 |
| 1 | SORT AGGREGATE | | 1 | 56 | |
| 2 | MERGE JOIN CARTESIAN | | 10 | 560 | 3 |
| 3 | TABLE ACCESS BY INDEX ROWID | T1 | 1 | 37 | 2 |
|* 4 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
| 5 | BUFFER SORT | | 12 | 228 | 1 |
| 6 | FIRST ROW | | 12 | 228 | 1 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
|* 7 | INDEX RANGE SCAN (MIN/MAX)| PK_T3 | 12 | | 1 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("T1"."OWNER"='SYS' AND "T1"."OBJECT_NAME"='ACCESS$')
7 - access("T3"."OWNER"='SYS' AND "T3"."TABLE_NAME"='ACCESS$')
Note: cpu costing is off
21 õǾϴ.
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
where t3.owner = 'SYS'
and t3.table_name = 'ACCESS$'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 56 | 3 |
| 1 | SORT AGGREGATE | | 1 | 56 | |
| 2 | MERGE JOIN CARTESIAN | | 10 | 560 | 3 |
| 3 | TABLE ACCESS BY INDEX ROWID | T1 | 1 | 37 | 2 |
|* 4 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
| 5 | BUFFER SORT | | 12 | 228 | 1 |
| 6 | FIRST ROW | | 12 | 228 | 1 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
|* 7 | INDEX RANGE SCAN (MIN/MAX)| PK_T3 | 12 | | 1 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("T1"."OWNER"='SYS' AND "T1"."OBJECT_NAME"='ACCESS$')
7 - access("T3"."OWNER"='SYS' AND "T3"."TABLE_NAME"='ACCESS$')
Note: cpu costing is off
21 õǾϴ.
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and rownum < 2
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
1 COUNT STOPKEY
1 INDEX RANGE SCAN PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 37 | 2 |
| 1 | SORT AGGREGATE | | 1 | 37 | |
| 2 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 37 | 2 |
|* 3 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
|* 4 | COUNT STOPKEY | | | | |
|* 5 | INDEX RANGE SCAN | PK_T3 | 1 | 19 | 2 |
----------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("SYS_ALIAS_2"."OWNER"='SYS' AND "SYS_ALIAS_2"."OBJECT_NAME"
='ACCESS$')
filter( EXISTS (SELECT /*+ */ 0 FROM "T3" "T3" WHERE ROWNUM<2 AND
"T3"."TABLE_NAME"=:B1 AND "T3"."OWNER"=:B2))
4 - filter(ROWNUM<2)
5 - access("T3"."OWNER"=:B1 AND "T3"."TABLE_NAME"=:B2)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Note: cpu costing is off
23 õǾϴ.
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 56 | 3 |
| 1 | SORT AGGREGATE | | 1 | 56 | |
| 2 | MERGE JOIN CARTESIAN | | 10 | 560 | 3 |
| 3 | TABLE ACCESS BY INDEX ROWID | T1 | 1 | 37 | 2 |
|* 4 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
| 5 | BUFFER SORT | | 12 | 228 | 1 |
| 6 | FIRST ROW | | 12 | 228 | 1 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
|* 7 | INDEX RANGE SCAN (MIN/MAX)| PK_T3 | 12 | | 1 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("T1"."OWNER"='SYS' AND "T1"."OBJECT_NAME"='ACCESS$')
7 - access("T3"."OWNER"='SYS' AND "T3"."TABLE_NAME"='ACCESS$')
Note: cpu costing is off
21 õǾϴ.
SQL>
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 21 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 21 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 NESTED LOOPS
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 FIRST ROW
8 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 56 | 3 |
| 1 | SORT AGGREGATE | | 1 | 56 | |
| 2 | NESTED LOOPS | | 1 | 56 | 3 |
| 3 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 37 | 2 |
|* 4 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
| 5 | FIRST ROW | | 1 | 19 | 1 |
|* 6 | INDEX RANGE SCAN (MIN/MAX)| PK_T3 | 1 | | 1 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("T1"."OWNER"='SYS' AND "T1"."OBJECT_NAME"='ACCESS$')
6 - access("T1"."OWNER"="T3"."OWNER" AND "T1"."OBJECT_NAME"="T3"."TABLE
_NAME")
filter("T3"."OWNER"='SYS' AND "T3"."TABLE_NAME"='ACCESS$')
Note: cpu costing is off
22 õǾϴ.
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
)
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 11 0.00 0.01 0 0 0 0
Execute 12 0.00 0.00 0 0 0 0
Fetch 20 0.53 6.01 26266 26440 0 10
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 43 0.53 6.02 26266 26440 0 10
Misses in library cache during parse: 10
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
12 user SQL statements in session.
0 internal SQL statements in session.
12 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_1988.trc
Trace file compatibility: 9.00.01
Sort options: default
1 session in tracefile.
12 user SQL statements in trace file.
0 internal SQL statements in trace file.
12 SQL statements in trace file.
12 unique SQL statements in trace file.
293 lines in trace file.
PL/SQL ó ϷǾϴ.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:31:08 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:31:08 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_296.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.57 6.36 26474 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.57 6.36 26474 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 2 0.57 6.36 26474 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 7 0.57 6.36 26474 26519 0 1
Misses in library cache during parse: 1
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
3 user SQL statements in session.
0 internal SQL statements in session.
3 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_296.trc
Trace file compatibility: 9.00.01
Sort options: default
1 session in tracefile.
3 user SQL statements in trace file.
0 internal SQL statements in trace file.
3 SQL statements in trace file.
3 unique SQL statements in trace file.
50 lines in trace file.
PL/SQL ó ϷǾϴ.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:36:34 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:36:34 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_296.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.57 6.36 26474 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.57 6.36 26474 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 56 | 3 |
| 1 | SORT AGGREGATE | | 1 | 56 | |
| 2 | MERGE JOIN CARTESIAN | | 10 | 560 | 3 |
| 3 | TABLE ACCESS BY INDEX ROWID | T1 | 1 | 37 | 2 |
|* 4 | INDEX RANGE SCAN | IX_T1 | 1 | | 1 |
| 5 | BUFFER SORT | | 12 | 228 | 1 |
| 6 | FIRST ROW | | 12 | 228 | 1 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
|* 7 | INDEX RANGE SCAN (MIN/MAX)| PK_T3 | 12 | | 1 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("T1"."OWNER"='SYS' AND "T1"."OBJECT_NAME"='ACCESS$')
7 - access("T3"."OWNER"='SYS' AND "T3"."TABLE_NAME"='ACCESS$')
Note: cpu costing is off
21 õǾϴ.
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 4 0.00 0.00 0 0 0 0
Execute 6 0.00 0.00 0 0 0 0
Fetch 4 0.57 6.36 26474 26532 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 14 0.57 6.36 26474 26532 0 2
Misses in library cache during parse: 2
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
6 user SQL statements in session.
0 internal SQL statements in session.
6 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_296.trc
Trace file compatibility: 9.00.01
Sort options: default
2 sessions in tracefile.
9 user SQL statements in trace file.
0 internal SQL statements in trace file.
6 SQL statements in trace file.
4 unique SQL statements in trace file.
102 lines in trace file.
PL/SQL ó ϷǾϴ.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:43:55 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 10:43:55 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_296.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.57 6.36 26474 26519 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.57 6.36 26474 26519 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
312264 HASH JOIN
38629 INDEX FAST FULL SCAN PK_T3 (object id 37136)
259392 TABLE ACCESS FULL T1
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 3 0.00 0.00 0 0 0 0
Execute 3 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 6 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t1.owner = 'SYS'
and t1.object_name = 'ACCESS$'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 13 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 13 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
8 MERGE JOIN CARTESIAN
8 TABLE ACCESS BY INDEX ROWID T1
8 INDEX RANGE SCAN IX_T1 (object id 37132)
8 BUFFER SORT
1 FIRST ROW
1 INDEX RANGE SCAN (MIN/MAX) PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
and rownum < 2
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 1.85 8.33 26271 529091 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 1.85 8.33 26271 529091 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 FILTER
259392 TABLE ACCESS FULL T1
2288 COUNT STOPKEY
2288 INDEX UNIQUE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.90 7.70 26271 285685 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.90 7.71 26271 285685 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 NESTED LOOPS
259392 TABLE ACCESS FULL T1
2288 INDEX UNIQUE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.95 0.42 26271 285685 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.95 0.42 26271 285685 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 NESTED LOOPS
259392 TABLE ACCESS FULL T1
2288 INDEX UNIQUE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 1.04 7.16 26271 285685 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 1.04 7.16 26271 285685 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 NESTED LOOPS
259392 TABLE ACCESS FULL T1
2288 INDEX UNIQUE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
where t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.96 7.61 26271 285685 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.96 7.61 26271 285685 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 NESTED LOOPS
259392 TABLE ACCESS FULL T1
2288 INDEX UNIQUE SCAN PK_T3 (object id 37136)
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 10 0.00 0.00 0 0 0 0
Execute 13 0.00 0.00 0 0 0 0
Fetch 14 6.31 37.61 157829 1698363 0 7
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 37 6.31 37.62 157829 1698363 0 7
Misses in library cache during parse: 7
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
13 user SQL statements in session.
0 internal SQL statements in session.
13 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_296.trc
Trace file compatibility: 9.00.01
Sort options: default
3 sessions in tracefile.
22 user SQL statements in trace file.
0 internal SQL statements in trace file.
13 SQL statements in trace file.
9 unique SQL statements in trace file.
247 lines in trace file.
PL/SQL ó ϷǾϴ.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 13:22:51 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
TKPROF: Release 9.2.0.1.0 - Production on Mar 4 13:22:51 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_1588.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 4 0.07 4.00 711 6366 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 0.07 4.00 711 6366 0 2
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 TABLE ACCESS BY INDEX ROWID T1
2575 NESTED LOOPS
286 INDEX FAST FULL SCAN PK_T3 (object id 37136)
2288 INDEX RANGE SCAN IX_T1 (object id 37132)
********************************************************************************
select /*+RULE*/
max(t1.LAST_DDL_TIME)
From t1 ,t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.01 0.00 0 0 0 0
Fetch 4 0.04 0.14 121 6152 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 0.06 0.14 121 6152 0 2
Misses in library cache during parse: 1
Optimizer goal: RULE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 TABLE ACCESS BY INDEX ROWID T1
2575 NESTED LOOPS
286 TABLE ACCESS BY INDEX ROWID T3
286 INDEX RANGE SCAN IX_T3C (object id 37137)
2288 INDEX RANGE SCAN IX_T1 (object id 37132)
********************************************************************************
alter session set sql_trace = false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 85
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
and rownum < 2
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 1.89 6.57 26005 529091 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 1.89 6.57 26005 529091 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 FILTER
259392 TABLE ACCESS FULL T1
2288 COUNT STOPKEY
2288 INDEX UNIQUE SCAN PK_T3 (object id 37136)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where exists
(
select
Null
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.01 0.01 0 3183 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.03 0.01 0 3183 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 TABLE ACCESS BY INDEX ROWID T1
2575 NESTED LOOPS
286 INDEX FAST FULL SCAN PK_T3 (object id 37136)
2288 INDEX RANGE SCAN IX_T1 (object id 37132)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t1.owner = t3.owner
and t1.object_name = t3.table_name
and t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.01 0.01 0 3183 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.01 0.01 0 3183 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 TABLE ACCESS BY INDEX ROWID T1
2575 NESTED LOOPS
286 INDEX FAST FULL SCAN PK_T3 (object id 37136)
2288 INDEX RANGE SCAN IX_T1 (object id 37132)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
t3.owner,t3.table_name
from t3
where t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.03 0.01 0 3183 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.03 0.01 0 3183 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 TABLE ACCESS BY INDEX ROWID T1
2575 NESTED LOOPS
286 INDEX FAST FULL SCAN PK_T3 (object id 37136)
2288 INDEX RANGE SCAN IX_T1 (object id 37132)
********************************************************************************
select
max(t1.LAST_DDL_TIME)
From t1
where (t1.owner,t1.object_name ) in
(
select
distinct
t3.owner,t3.table_name
from t3
where t3.column_name = 'TABLE_NAME'
)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.01 0.01 0 3183 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.01 0.01 0 3183 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE
2288 TABLE ACCESS BY INDEX ROWID T1
2575 NESTED LOOPS
286 INDEX FAST FULL SCAN PK_T3 (object id 37136)
2288 INDEX RANGE SCAN IX_T1 (object id 37132)
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 11 0.01 0.00 0 0 0 0
Execute 13 0.01 0.00 0 0 0 0
Fetch 18 2.09 10.78 26837 554341 0 9
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 42 2.12 10.78 26837 554341 0 9
Misses in library cache during parse: 7
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
13 user SQL statements in session.
0 internal SQL statements in session.
13 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\admin\dongildb\udump\dongildb_ora_1588.trc
Trace file compatibility: 9.00.01
Sort options: default
2 sessions in tracefile.
17 user SQL statements in trace file.
0 internal SQL statements in trace file.
13 SQL statements in trace file.
9 unique SQL statements in trace file.
255 lines in trace file.
PL/SQL ó ϷǾϴ.
| true |
8774afff703b2189eab3b6569ffab6b650e6db42 | SQL | FritzAxel/java-bootcamp-2018 | /Topic4/Exercise-2.sql | UTF-8 | 1,213 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | INSERT INTO `teacher` (first_name, last_name, date_of_birth)
values
('Gonzalo', 'Rocha', 20/08/1985),
('Axel' , 'Fritz', 26/08/1995),
('Matias' , 'Massaccesi', 20/04/1996);
INSERT INTO course (name, teacher_id, hours_by_week)
values
('Maths', 4, 4),
('Chemistry', 5, 4),
('Physics', 6, 8);
INSERT INTO student (first_name, last_name, date_of_birth)
values
('Matias','Lopez', 20/09/1991),
('Domingo','Peron', 10/04/1984),
('Brian','Gancitano', 02/01/1991),
('Ricardo','Darin', 01/07/1986),
('Jose','Neuer', 04/09/1979),
('Faustino','Sarmiento', 02/06/1994),
('Fabian' , 'Moreyra', 03/03/1993),
('Izquierdo','Gonzalez', 08/11/1990),
('Manuela','Dominguez', 22/02/1992),
('Sebastian','Riquelme', 18/05/1995),
('Rigoberto','Sandes', 22/09/1993),
('Silvina','Gonzalez', 30/08/1994),
('Oscar','Scioli', 07/07/1987),
('Manuel', 'Sanchez', 01/01/1991),
('Esteban', 'Rosco', 05/05/1995),
('Carla', 'Lopez', 24/06/1986);
INSERT INTO `student_x_course` (registration_number , course_id)
values
(4,4),
(1,4),
(2,4),
(13,4),
(11,4),
(3,4),
(16,4),
(5,4),
(8,4),
(12,4),
(1,5),
(2,5),
(3,5),
(4,5),
(5,5),
(6,5),
(7,5),
(8,5),
(9,5),
(10,5),
(11,6),
(12,6),
(13,6),
(14,6),
(15,6),
(16,6),
(3,6),
(5,6),
(6,6),
(7,6);
| true |
e1e15c0263e650c28385d5f65932fce551fc79fc | SQL | tomOsuch/kodilla-sql | /Index.sql | UTF-8 | 215 | 3.15625 | 3 | [] | no_license | EXPLAIN SELECT * FROM READERS
WHERE FIRSTNAME = 'John';
CREATE INDEX READERSNAME ON READERS (FIRSTNAME, LASTNAME);
CREATE INDEX BOOKSTITLE ON BOOKS (TITLE);
EXPLAIN SELECT * FROM READERS
WHERE FIRSTNAME = 'John'; | true |
0e59ea8bf5fa37c74d4bbbf2df74a9bdafe76817 | SQL | fandashtic/arc_chennai | /Sivabalan-SQL/SQL_STORED_PROCEDURE/sp_list_ForeCast_DocLU.sql | UTF-8 | 475 | 3.203125 | 3 | [] | no_license | CREATE Procedure sp_list_ForeCast_DocLU(@FromDoc int,
@ToDoc int)
As
Select Forecast_Abstract.DocSerial,
Forecast_Abstract.DocPrefix + Cast(Forecast_Abstract.DocumentID as nvarchar),
Vendors.Vendor_Name, Forecast_Abstract.VendorID, Forecast_Abstract.DocumentDate
From Forecast_Abstract, Vendors
Where Forecast_Abstract.VendorID = Vendors.VendorID And
Forecast_Abstract.DocumentID Between @FromDoc And @ToDoc
Order By Vendors.Vendor_Name, Forecast_Abstract.DocumentDate
| true |
61d702d5747814771e9d0d114cfce44815618124 | SQL | mohamedTidda/PFEdocs | /source code folder/pfe_db.sql | UTF-8 | 11,724 | 3.15625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1
-- Généré le : mar. 26 mars 2019 à 12:07
-- Version du serveur : 10.1.37-MariaDB
-- Version de PHP : 7.1.24
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
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 */;
--
-- Base de données : `pfe_db`
--
-- --------------------------------------------------------
--
-- Structure de la table `doctors`
--
CREATE TABLE `doctors` (
`D_id` int(11) NOT NULL,
`D_name` varchar(255) NOT NULL,
`D_password` varchar(255) NOT NULL,
`age` int(11) NOT NULL,
`adress` varchar(255) NOT NULL,
`office` varchar(255) NOT NULL,
`phone` varchar(255) NOT NULL,
`groupID` int(11) NOT NULL DEFAULT '0',
`description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `doctors`
--
INSERT INTO `doctors` (`D_id`, `D_name`, `D_password`, `age`, `adress`, `office`, `phone`, `groupID`, `description`) VALUES
(1, 'tidda', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', 23, 'chlef-dz', 'chlef 151', '0123456', 1, 'medical specialist in orthopedic surgery'),
(2, 'mohamed', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', 20, 'chlef', 'dz', 'chlef', 0, 'medical specialist in orthopedic surgery'),
(3, 'islam', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', 25, 'chlef-dz', 'chlef', '0123456', 0, 'medical specialist in orthopedic surgery');
-- --------------------------------------------------------
--
-- Structure de la table `mdicines_described`
--
CREATE TABLE `mdicines_described` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`dose` varchar(255) NOT NULL,
`repeated` varchar(255) NOT NULL,
`boxs` varchar(255) NOT NULL,
`form` varchar(255) NOT NULL,
`time_use` varchar(255) NOT NULL,
`p_id` int(11) NOT NULL,
`d_id` int(11) NOT NULL,
`prescribe_date` date NOT NULL,
`prescription_id` int(11) DEFAULT NULL,
`already_added` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `mdicines_described`
--
INSERT INTO `mdicines_described` (`id`, `name`, `dose`, `repeated`, `boxs`, `form`, `time_use`, `p_id`, `d_id`, `prescribe_date`, `prescription_id`, `already_added`) VALUES
(1, 'Abacavir Sulfate', '0.5', '2', '2', 'Troches', 'after meal', 5, 1, '2019-03-02', 2, 1),
(2, 'Bacitracin', '1.5', '1', '3', 'Liquid', 'before meal', 5, 1, '2019-03-02', 2, 1),
(3, 'Abacavir Sulfate', '0.5', '1', '1', 'Troches', 'after meal', 5, 1, '2019-03-04', 13, 1),
(4, 'Banzel', '1', '3', '2', 'Liquid', 'before meal', 5, 1, '2019-03-04', 13, 1),
(5, 'Abarelix', '0.5', '1', '1', 'Troches', 'before meal', 5, 1, '2019-03-04', 14, 1),
(6, 'Bacitracin', '0.5', '1', '1', 'Troches', 'after meal', 5, 1, '2019-03-04', 15, 1),
(8, 'Abarelix', '3', '3', '2', 'Injection', 'before meal', 5, 1, '2019-03-05', 16, 1),
(9, 'Abarelix', '0.5', '2', '1', 'Injection', 'after meal', 8, 1, '2019-03-25', 18, 1),
(10, 'Abarelix', '1', '2', '2', 'Troches', 'morning', 8, 1, '2019-03-25', 20, 1);
-- --------------------------------------------------------
--
-- Structure de la table `medicines`
--
CREATE TABLE `medicines` (
`med_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`uri` mediumtext NOT NULL,
`description` mediumtext NOT NULL,
`absorption` mediumtext NOT NULL,
`affectedOrganism` mediumtext NOT NULL,
`biotransformation` mediumtext NOT NULL,
`halfLife` mediumtext NOT NULL,
`indication` mediumtext NOT NULL,
`mechanismOfAction` mediumtext NOT NULL,
`pharmacology` mediumtext NOT NULL,
`toxicity` mediumtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `medicines`
--
INSERT INTO `medicines` (`med_id`, `name`, `uri`, `description`, `absorption`, `affectedOrganism`, `biotransformation`, `halfLife`, `indication`, `mechanismOfAction`, `pharmacology`, `toxicity`) VALUES
(1, 'Abacavir Sulfate', '', '', '', '', '', '', '', '', '', ''),
(2, 'Abarelix\r\n', '', '', '', '', '', '', '', '', '', ''),
(3, 'Bacitracin', '', '', '', '', '', '', '', '', '', ''),
(4, 'Bactrim', '', '', '', '', '', '', '', '', '', ''),
(5, 'Banzel', '', '', '', '', '', '', '', '', '', ''),
(6, 'Cabergoline', '', '', '', '', '', '', '', '', '', ''),
(7, 'Cafcit', '', '', '', '', '', '', '', '', '', '');
-- --------------------------------------------------------
--
-- Structure de la table `patienthistory`
--
CREATE TABLE `patienthistory` (
`H_id` int(11) NOT NULL,
`p_id` int(11) NOT NULL,
`d_id` int(11) NOT NULL,
`chronicDiseases` text NOT NULL,
`importantMedications` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `patienthistory`
--
INSERT INTO `patienthistory` (`H_id`, `p_id`, `d_id`, `chronicDiseases`, `importantMedications`) VALUES
(1, 5, 1, 'diabetes-hypertension', 'panadol'),
(2, 5, 1, 'diabetes-hypertension', 'panadol');
-- --------------------------------------------------------
--
-- Structure de la table `patientofdoctor`
--
CREATE TABLE `patientofdoctor` (
`pOd_id` int(11) NOT NULL,
`D_id` int(11) NOT NULL,
`p_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `patientofdoctor`
--
INSERT INTO `patientofdoctor` (`pOd_id`, `D_id`, `p_id`) VALUES
(3, 1, 5),
(10, 1, 1),
(11, 1, 4);
-- --------------------------------------------------------
--
-- Structure de la table `patients`
--
CREATE TABLE `patients` (
`p_id` int(11) NOT NULL,
`p_name` varchar(255) NOT NULL,
`p_password` varchar(255) NOT NULL,
`birth_date` date NOT NULL,
`phone` varchar(255) NOT NULL,
`adress` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `patients`
--
INSERT INTO `patients` (`p_id`, `p_name`, `p_password`, `birth_date`, `phone`, `adress`) VALUES
(1, 'khaled', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', '1998-08-15', '1234', 'chlef'),
(2, 'ahmed', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', '1996-08-15', '987654321', 'chlef-dz'),
(3, 'youcef', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', '1988-01-10', '987654321', 'chlef-dz'),
(4, 'zaki', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', '1995-03-02', '123456', 'chlef'),
(5, 'sohayeb', '1ba36e6200640edd06654522fa1137c8c72b4fb0', '1994-03-08', '123456', 'chlef'),
(7, 'karim', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', '2010-01-08', 'chlef', '123456'),
(8, 'khawla', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', '2019-03-14', 'chlef', '123456');
-- --------------------------------------------------------
--
-- Structure de la table `pharmacy`
--
CREATE TABLE `pharmacy` (
`ph_id` int(11) NOT NULL,
`ph_name` varchar(255) NOT NULL,
`ph_password` varchar(255) NOT NULL,
`adress` varchar(255) NOT NULL,
`phone` varchar(255) NOT NULL,
`owner_name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `pharmacy`
--
INSERT INTO `pharmacy` (`ph_id`, `ph_name`, `ph_password`, `adress`, `phone`, `owner_name`) VALUES
(1, 'youcef', '40bd001563085fc35165329ea1ff5c5ecbdbbeef', 'alger-dz', 'a', 'a');
-- --------------------------------------------------------
--
-- Structure de la table `prescription`
--
CREATE TABLE `prescription` (
`id` int(11) NOT NULL,
`p_id` int(11) NOT NULL,
`d_id` int(11) NOT NULL,
`add_time` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `prescription`
--
INSERT INTO `prescription` (`id`, `p_id`, `d_id`, `add_time`) VALUES
(0, 5, 1, '2019-03-03'),
(1, 4, 1, '2019-03-01'),
(2, 4, 1, '2019-03-02'),
(3, 5, 1, '2019-03-03'),
(4, 5, 1, '2019-03-03'),
(5, 4, 1, '2019-03-03'),
(6, 4, 1, '2019-03-03'),
(7, 4, 1, '2019-03-03'),
(8, 4, 1, '2019-03-03'),
(9, 1, 1, '2019-03-03'),
(13, 5, 1, '2019-03-04'),
(14, 5, 1, '2019-03-04'),
(15, 5, 1, '2019-03-04'),
(16, 5, 1, '2019-03-05'),
(17, 8, 1, '2019-03-25'),
(18, 8, 1, '2019-03-25'),
(19, 8, 1, '2019-03-25'),
(20, 8, 1, '2019-03-25');
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `doctors`
--
ALTER TABLE `doctors`
ADD PRIMARY KEY (`D_id`);
--
-- Index pour la table `mdicines_described`
--
ALTER TABLE `mdicines_described`
ADD PRIMARY KEY (`id`),
ADD KEY `mdicines_described_ibfk_1` (`d_id`),
ADD KEY `mdicines_described_ibfk_3` (`prescription_id`),
ADD KEY `p_id` (`p_id`);
--
-- Index pour la table `medicines`
--
ALTER TABLE `medicines`
ADD PRIMARY KEY (`med_id`);
--
-- Index pour la table `patienthistory`
--
ALTER TABLE `patienthistory`
ADD PRIMARY KEY (`H_id`);
--
-- Index pour la table `patientofdoctor`
--
ALTER TABLE `patientofdoctor`
ADD PRIMARY KEY (`pOd_id`),
ADD KEY `orders1` (`D_id`),
ADD KEY `order2` (`p_id`);
--
-- Index pour la table `patients`
--
ALTER TABLE `patients`
ADD PRIMARY KEY (`p_id`);
--
-- Index pour la table `pharmacy`
--
ALTER TABLE `pharmacy`
ADD PRIMARY KEY (`ph_id`);
--
-- Index pour la table `prescription`
--
ALTER TABLE `prescription`
ADD PRIMARY KEY (`id`),
ADD KEY `d_id` (`d_id`),
ADD KEY `p_id` (`p_id`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT pour la table `doctors`
--
ALTER TABLE `doctors`
MODIFY `D_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT pour la table `mdicines_described`
--
ALTER TABLE `mdicines_described`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT pour la table `medicines`
--
ALTER TABLE `medicines`
MODIFY `med_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT pour la table `patienthistory`
--
ALTER TABLE `patienthistory`
MODIFY `H_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT pour la table `patientofdoctor`
--
ALTER TABLE `patientofdoctor`
MODIFY `pOd_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT pour la table `patients`
--
ALTER TABLE `patients`
MODIFY `p_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT pour la table `pharmacy`
--
ALTER TABLE `pharmacy`
MODIFY `ph_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT pour la table `prescription`
--
ALTER TABLE `prescription`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `mdicines_described`
--
ALTER TABLE `mdicines_described`
ADD CONSTRAINT `mdicines_described_ibfk_1` FOREIGN KEY (`d_id`) REFERENCES `doctors` (`D_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `mdicines_described_ibfk_3` FOREIGN KEY (`prescription_id`) REFERENCES `prescription` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `mdicines_described_ibfk_4` FOREIGN KEY (`p_id`) REFERENCES `patients` (`p_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Contraintes pour la table `patientofdoctor`
--
ALTER TABLE `patientofdoctor`
ADD CONSTRAINT `order2` FOREIGN KEY (`p_id`) REFERENCES `patients` (`p_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `orders1` FOREIGN KEY (`D_id`) REFERENCES `doctors` (`D_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Contraintes pour la table `prescription`
--
ALTER TABLE `prescription`
ADD CONSTRAINT `prescription_ibfk_1` FOREIGN KEY (`d_id`) REFERENCES `doctors` (`D_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `prescription_ibfk_2` FOREIGN KEY (`p_id`) REFERENCES `patients` (`p_id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
ea7baf7eb0d78bc603be563cf06561c77e2a8add | SQL | nadineRoldao/amigo-secreto-app | /scripts_banco/script_amigoSecreto_DDL.sql | UTF-8 | 1,831 | 3.765625 | 4 | [] | no_license | -- drop database amigo_secreto_app;
-- create database amigo_secreto_app;
use amigo_secreto_app;
drop table if exists grupo_amigo;
drop table if exists grupo_postagem;
drop table if exists grupo;
drop table if exists amigo;
create table amigo (
id int not null auto_increment primary key,
nome varchar(255) not null,
email varchar(255) not null,
senha varchar(255) not null,
imagem varchar(255) null
);
create table grupo (
id int not null auto_increment primary key,
nome varchar(255) not null,
id_amigo int null,
data_sorteio timestamp null,
valor_min float null,
valor_max float null,
data_evento timestamp null,
local_evento varchar(255) null
);
create table grupo_amigo (
id_amigo int not null,
id_grupo int not null,
ativo ENUM('y', 'n') not null default 'n',
id_amigo_sorteado int null,
primary key (id_grupo, id_amigo)
);
create table grupo_postagem (
id int not null auto_increment primary key,
id_amigo int not null,
id_grupo int not null,
texto varchar(1000),
link varchar(255),
data_postagem timestamp default current_timestamp
);
alter table grupo
add foreign key (id_amigo) references amigo(id);
alter table grupo_amigo
add foreign key (id_amigo) references amigo(id);
alter table grupo_amigo
add foreign key (id_grupo) references grupo(id);
alter table grupo_postagem
add foreign key (id_amigo) references amigo(id);
alter table grupo_postagem
add foreign key (id_grupo) references grupo(id);
alter table amigo add unique(email);
alter table grupo add unique(nome); | true |
96b6506e56ac62137ef624de12153bace8ae7db4 | SQL | everthis/leetcode-js | /619-biggest-single-number.sql | UTF-8 | 155 | 2.953125 | 3 | [
"MIT"
] | permissive | # Write your MySQL query statement below
select(
select num
from my_numbers
group by num
having count(*) = 1
order by num desc limit 1
) as num;
| true |
afdaffb45093631141da77995c4d72b849b4c25e | SQL | IlyassBoussataha/PYKA_V2 | /src/main/resources/PYKA.sql | UTF-8 | 3,902 | 3.390625 | 3 | [] | no_license | CREATE TABLE profil(
id INTEGER NOT NULL AUTO_INCREMENT,
civilite VARCHAR(5) COLLATE utf8_unicode_ci NOT NULL,
nom VARCHAR(30) COLLATE utf8_unicode_ci NOT NULL,
prenom VARCHAR(30) COLLATE utf8_unicode_ci NOT NULL,
datedenaissance DATE NULL,
adresse VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
codepostale INTEGER(11) NOT NULL,
ville VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
email VARCHAR(50) COLLATE utf8_unicode_ci UNIQUE NOT NULL,
telephone VARCHAR(30) COLLATE utf8_unicode_ci UNIQUE NOT NULL,
siren VARCHAR(20) COLLATE utf8_unicode_ci UNIQUE,
rib VARCHAR(50) COLLATE utf8_unicode_ci,
nom_entreprise VARCHAR(50) COLLATE utf8_unicode_ci,
parcours VARCHAR(300) COLLATE utf8_unicode_ci DEFAULT NULL,
dateentree DATE NULL,
datesortie DATE DEFAULT NULL,
date_exclusion DATE NULL,
pieceid VARCHAR(300) DEFAULT NULL,
pieceidverso VARCHAR(300) DEFAULT NULL,
kbis VARCHAR(300) DEFAULT NULL,
permis VARCHAR(300) DEFAULT NULL,
photo VARCHAR(300) DEFAULT NULL,
casier_judiciaire VARCHAR(300) DEFAULT NULL,
vtc VARCHAR(300) DEFAULT NULL,
nb_commandes int(11),
last_commandes int(11) DEFAULT '0',
active tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE login (
id int(11) NOT NULL AUTO_INCREMENT,
profil_id int(11) NOT NULL,
email varchar(50) COLLATE utf8_unicode_ci UNIQUE NOT NULL,
password varchar(255) COLLATE utf8_unicode_ci NOT NULL,
admin tinyint(1) NOT NULL DEFAULT '0',
limited tinyint(1) NOT NULL DEFAULT '0',
confirme tinyint(1) NOT NULL DEFAULT '0',
valide tinyint(1) NOT NULL DEFAULT '0',
exclu tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
FOREIGN KEY (profil_id) REFERENCES profil(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE login_roles (
id int(11) NOT NULL AUTO_INCREMENT,
login_id int(11) NOT NULL,
roles varchar(40) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY login_groups_uk (login_id,roles),
FOREIGN KEY (login_id) REFERENCES login (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE verificationtoken (
id int(11) NOT NULL AUTO_INCREMENT,
token VARCHAR(255) COLLATE utf8_unicode_ci,
expiryDate DATE,
login_id int(11) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (login_id) REFERENCES login(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE creneaux (
id int(11) NOT NULL AUTO_INCREMENT,
heure_debut TIME NOT NULL,
heure_fin TIME NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE disponibilite (
id int(11) NOT NULL AUTO_INCREMENT,
laveur_id int(11),
date DATE,
creneau int(11) NOT NULL,
attribue tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
FOREIGN KEY (laveur_id) REFERENCES profil(id),
FOREIGN KEY (creneau) REFERENCES creneaux(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE commande (
id int(11) NOT NULL AUTO_INCREMENT,
client_id int(11) NOT NULL,
laveur_id int(11),
date DATE,
creneau int(11) NOT NULL,
vehicule VARCHAR(50) COLLATE utf8_unicode_ci NOT NULL,
type_lavage VARCHAR(50) COLLATE utf8_unicode_ci NOT NULL,
adresse VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL,
mode_paiement VARCHAR(50) COLLATE utf8_unicode_ci NOT NULL,
montant FLOAT,
nouvelle tinyint(1) NOT NULL DEFAULT '0',
assigner tinyint(1) NOT NULL DEFAULT '0',
effectuer tinyint(1) NOT NULL DEFAULT '0',
annuler tinyint(1) NOT NULL DEFAULT '0',
motif_annuler VARCHAR(100) COLLATE utf8_unicode_ci,
PRIMARY KEY (id),
FOREIGN KEY (client_id) REFERENCES profil(id),
FOREIGN KEY (laveur_id) REFERENCES profil(id),
FOREIGN KEY (creneau) REFERENCES creneaux(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
| true |
3557f5fd886cbc422936aeaf4efa8bedd2f29b3f | SQL | JazzHandsCMDB/jazzhands | /database/pkg/oracle/port_support_body.sql | UTF-8 | 5,109 | 2.859375 | 3 | [] | no_license | -- Copyright (c) 2005-2010, Vonage Holdings Corp.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED BY VONAGE HOLDINGS CORP. ''AS IS'' AND ANY
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL VONAGE HOLDINGS CORP. BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*
* $Id$
*
* backend support for dealing with ports. This is not part of the public
* interface so generally should not be granted.
*/
create or replace package body port_support
IS
-------------------------------------------------------------------
-- returns the Id tag for CM
-------------------------------------------------------------------
FUNCTION id_tag
RETURN VARCHAR2
IS
BEGIN
RETURN('<-- $Id$ -->');
END;
--end of procedure id_tag
-------------------------------------------------------------------
-------------------------------------------------------------------
-- returns if a device has any power ports or not
-------------------------------------------------------------------
FUNCTION has_power_ports (
in_Device_id device.device_id%type
) RETURN BOOLEAN
IS
tally integer;
BEGIN
select count(*)
into tally
from device_power_interface
where device_id = in_device_id;
if tally = 0 then
return FALSE;
end if;
return TRUE;
END;
--end of procedure has_power_ports
-------------------------------------------------------------------
-------------------------------------------------------------------
-- returns if a device has any serial ports or not
-------------------------------------------------------------------
FUNCTION has_serial_ports (
in_Device_id device.device_id%type
) RETURN BOOLEAN
IS
tally integer;
BEGIN
return has_physical_ports(in_Device_id, 'serial');
END;
--end of procedure has_serial_ports
-------------------------------------------------------------------
-------------------------------------------------------------------
-- returns if a device has any physical ports or not
-- if in_port_type is set, will limit the check to that type,
-- otherwise will limit the search to that type
-------------------------------------------------------------------
FUNCTION has_physical_ports (
in_Device_id device.device_id%type,
in_port_type val_port_type.port_type%type DEFAULT NULL
) RETURN BOOLEAN
IS
tally integer;
BEGIN
if in_port_type is NULL then
select count(*)
into tally
from physical_port
where device_id = in_device_id;
else
select count(*)
into tally
from physical_port
where device_id = in_device_id
and port_type = in_port_type;
end if;
if tally = 0 then
return FALSE;
end if;
return TRUE;
END;
--end of procedure has_physical_ports
-------------------------------------------------------------------
-------------------------------------------------------------------
-- update a table dynamically
-------------------------------------------------------------------
procedure do_l1_connection_update(
p_cnames in layer1_conn_array,
p_values in layer1_conn_array,
p_l1_id in layer1_connection.layer1_connection_id%type
) is
l_stmt long;
l_rc number;
i number;
g_cursor number;
begin
g_cursor := dbms_sql.open_cursor;
l_stmt := 'update layer1_connection set ' || p_cnames(1) || '= :bv1';
dbms_output.put_line('P_names is ' || p_cnames.count);
for i in 2 .. p_cnames.count loop
l_stmt := l_stmt || ',' || p_cnames(i) || ' = :bv' || i;
end loop;
l_stmt := l_stmt || ' where layer1_connection_id = :lcid';
--
-- make the query happen and stuff.
--
dbms_output.put_line( l_stmt );
dbms_sql.parse( g_cursor, l_stmt, dbms_sql.native );
for i in 1 .. p_values.count
loop
dbms_sql.bind_variable( g_cursor, ':bv' || i, p_values(i) );
end loop;
dbms_sql.bind_variable( g_cursor, ':lcid', p_l1_id );
l_rc := dbms_sql.execute( g_cursor );
end;
--end of procedure do_l1_connection_update
-------------------------------------------------------------------
end;
/
show errors;
| true |
47ed9029c48202b9f3caa7f65d8bf19fec02da9b | SQL | Antonio1491/salta | /sql/tipo_credenciales.sql | UTF-8 | 1,295 | 2.9375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.0.4
-- http://www.phpmyadmin.net
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 18-04-2019 a las 20:41:41
-- Versión del servidor: 5.5.32
-- Versión de PHP: 7.0.32
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 utf8 */;
--
-- Base de datos: `salta`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `tipo_credenciales`
--
CREATE TABLE IF NOT EXISTS `tipo_credenciales` (
`id_tipo` int(2) NOT NULL AUTO_INCREMENT,
`tipo` varchar(300) COLLATE utf8_spanish_ci NOT NULL,
PRIMARY KEY (`id_tipo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci AUTO_INCREMENT=4 ;
--
-- Volcado de datos para la tabla `tipo_credenciales`
--
INSERT INTO `tipo_credenciales` (`id_tipo`, `tipo`) VALUES
(1, 'Administrador'),
(2, 'Conferencista'),
(3, 'Comité');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
018799bf6c28abec7e8126fd8d3c9e55ea0adf7d | SQL | ludoaubert/linkedboxdraw | /SelectMetaData_SQLServer.sql | UTF-8 | 3,922 | 4.34375 | 4 | [
"Apache-2.0"
] | permissive |
WITH cte_fk AS (
-- stay away from INFORMATION_SCHEMA on SQL Server (Aaron Bertrand)
SELECT obj.name AS FK_NAME,
sch.name AS [schema_name],
tab1.name AS [table],
col1.name AS [column],
tab2.name AS [referenced_table],
col2.name AS [referenced_column]
FROM sys.foreign_key_columns fkc
INNER JOIN sys.objects obj
ON obj.object_id = fkc.constraint_object_id
INNER JOIN sys.tables tab1
ON tab1.object_id = fkc.parent_object_id
INNER JOIN sys.schemas sch
ON tab1.schema_id = sch.schema_id
INNER JOIN sys.columns col1
ON col1.column_id = parent_column_id AND col1.object_id = tab1.object_id
INNER JOIN sys.tables tab2
ON tab2.object_id = fkc.referenced_object_id
INNER JOIN sys.columns col2
ON col2.column_id = referenced_column_id AND col2.object_id = tab2.object_id
), cte_pk AS (
SELECT Tab.CONSTRAINT_SCHEMA AS [schema_name],
Tab.CONSTRAINT_NAME AS [pk_name],
Col.Column_Name AS [columns],
Col.Table_Name AS [table_name]
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS Tab
JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE Col ON Col.Constraint_Name = Tab.Constraint_Name
AND Col.Table_Name = Tab.Table_Name
WHERE Tab.Constraint_Type = 'PRIMARY KEY'
) , cte_table_list AS (
SELECT table_name, ROW_NUMBER() OVER (ORDER BY table_name) AS rn
FROM INFORMATION_SCHEMA.TABLES
--WHERE EXISTS (SELECT * FROM cte_fk WHERE TABLE_NAME IN ([table], [referenced_table]))
) , cte_table_column_list AS (
SELECT c.table_name, c.column_name, tl.rn AS rn_table,
ROW_NUMBER() OVER (PARTITION BY c.table_name ORDER BY MAX(pk.pk_name) DESC, MAX(fk_dest.FK_NAME) DESC, MAX(fk_orig.FK_NAME) DESC, c.column_name) AS rn_column
FROM INFORMATION_SCHEMA.COLUMNS c
JOIN cte_table_list tl ON c.TABLE_NAME=tl.TABLE_NAME
LEFT JOIN cte_pk pk ON c.TABLE_NAME=pk.table_name AND c.COLUMN_NAME = pk.[columns]
LEFT JOIN cte_fk fk_orig ON c.TABLE_NAME=fk_orig.[table] AND c.COLUMN_NAME = fk_orig.[column]
LEFT JOIN cte_fk fk_dest ON c.TABLE_NAME=fk_dest.[referenced_table] AND c.COLUMN_NAME = fk_dest.[referenced_column]
GROUP BY c.table_name, c.column_name, tl.rn
) , cte_fields AS (
SELECT tl.table_name AS title, tl.rn-1 AS id, (
SELECT tc.COLUMN_NAME AS [name],
CAST(CASE WHEN pk.pk_name IS NULL THEN 0 ELSE 1 END AS BIT) AS isPrimaryKey,
CAST(CASE WHEN fk.FK_NAME IS NULL THEN 0 ELSE 1 END AS BIT) AS isForeignKey
FROM cte_table_column_list tc
LEFT JOIN cte_pk pk ON tc.TABLE_NAME=pk.table_name AND tc.COLUMN_NAME = pk.[columns]
LEFT JOIN cte_fk fk ON tc.TABLE_NAME=fk.[table] AND tc.COLUMN_NAME = fk.[column]
WHERE tc.TABLE_NAME = tl.table_name
ORDER BY tc.rn_column
FOR JSON PATH
) AS fields
FROM cte_table_list tl
), cte_links AS (
SELECT tcl_from.rn_table - 1 AS [from], -- zero based
tcl_from.rn_column - 1 AS fromField, -- zero based
'' AS fromCardinality,
tcl_to.rn_table - 1 AS [to], -- zero based
tcl_to.rn_column - 1 AS toField,-- zero based
'' AS toCardinality
FROM cte_fk fk
JOIN cte_table_column_list tcl_from ON fk.[table]=tcl_from.TABLE_NAME AND fk.[column]=tcl_from.COLUMN_NAME
JOIN cte_table_column_list tcl_to ON fk.referenced_table=tcl_to.TABLE_NAME AND fk.referenced_column=tcl_to.COLUMN_NAME
), cte_tr2 AS (
SELECT l1.[from], l2.[to]
FROM cte_links l1
JOIN cte_links l2 ON l1.[to] = l2.[from]
), cte_diagdata AS (
SELECT DB_NAME() AS documentTitle,
(
SELECT *
FROM cte_fields
ORDER BY title
FOR JSON PATH
) AS boxes,
(
SELECT l.*,
CASE
WHEN EXISTS(SELECT * FROM cte_tr2 WHERE cte_tr2.[from]=l.[from] AND cte_tr2.[to]=l.[to])
THEN 'TR2'
ELSE ''
END AS category
FROM cte_links l
FOR JSON PATH
) AS links,
json_query('[]') AS [values],
json_query('[]') AS boxComments,
json_query('[]') AS fieldComments,
json_query('[]') AS fieldColors
)
SELECT *
FROM cte_diagdata
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER;
| true |
4cc7613f9cb18d34faf7e947648087f01e59ceff | SQL | Joaquim09Castro/modulo2_queries-resilia | /Scripts/Montadoras/Vitorias-Construtoras.sql | UTF-8 | 265 | 3.75 | 4 | [] | no_license | SELECT
c.name 'Constructor',
SUM(cs.wins) 'Win Count'
FROM
`constructors` c
INNER JOIN
`constructorStandings` cs
ON
c.constructorId = cs.constructorId
GROUP BY
1
HAVING
`Win Count` > 0
UNION
SELECT
'Others',
0
ORDER BY
2 DESC; | true |
f03155ded8d6c2b6beb63df1e5b18706685934e2 | SQL | kunoffeduard/Food-Bank | /datasets/sample.sql | UTF-8 | 1,315 | 2.5625 | 3 | [] | no_license | BEGIN TRANSACTION;
CREATE TABLE "Account" (
id INTEGER NOT NULL,
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"BillingStreet" VARCHAR(255),
"BillingCity" VARCHAR(255),
"BillingState" VARCHAR(255),
"BillingPostalCode" VARCHAR(255),
"BillingCountry" VARCHAR(255),
"ShippingStreet" VARCHAR(255),
"ShippingCity" VARCHAR(255),
"ShippingState" VARCHAR(255),
"ShippingPostalCode" VARCHAR(255),
"ShippingCountry" VARCHAR(255),
"Phone" VARCHAR(255),
"Fax" VARCHAR(255),
"Website" VARCHAR(255),
"NumberOfEmployees" VARCHAR(255),
"AccountNumber" VARCHAR(255),
"Site" VARCHAR(255),
"Type" VARCHAR(255),
PRIMARY KEY (id)
);
INSERT INTO "Account" VALUES(1,'Beispielaccount für Ansprüche','','','','','','','','','','','','','','','','','','');
CREATE TABLE "Contact" (
id INTEGER NOT NULL,
"Salutation" VARCHAR(255),
"FirstName" VARCHAR(255),
"LastName" VARCHAR(255),
"Email" VARCHAR(255),
"Phone" VARCHAR(255),
"MobilePhone" VARCHAR(255),
"OtherPhone" VARCHAR(255),
"HomePhone" VARCHAR(255),
"Title" VARCHAR(255),
"Birthdate" VARCHAR(255),
"MailingStreet" VARCHAR(255),
"MailingCity" VARCHAR(255),
"MailingState" VARCHAR(255),
"MailingPostalCode" VARCHAR(255),
"MailingCountry" VARCHAR(255),
"AccountId" VARCHAR(255),
PRIMARY KEY (id)
);
COMMIT;
| true |
98e0d31f5f009bfb170203d54324d7c33dc5dd20 | SQL | jericopingul/SQL | /Stanford-SQL/Movie_Rating_Modification/3.sql | UTF-8 | 244 | 3.390625 | 3 | [] | no_license | /* For all movies that have an average rating of 4 stars or higher, add 25 to the
release year. (Update the existing tuples; don't insert new tuples.)
*/
update Movie
set year = year + 25
where mID in
(select mID from Rating where stars > 4) | true |
cb324c44c872fe742495f91a2fb4da169187a468 | SQL | coa205/postZip_finder | /Scripts/Script.sql | UTF-8 | 7,737 | 3.0625 | 3 | [] | no_license | create table if not exists post (
zipcode char(5) null,
sido varchar(20) null,
sigungu varchar(20) null,
doro varchar(80) null,
building1 int(5) null,
building2 int(5) null
);
delete from post;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/강원도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/경기도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/경상남도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/경상북도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/광주광역시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/대구광역시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/대전광역시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/부산광역시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/서울특별시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/세종특별자치시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/울산광역시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/인천광역시.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/전라남도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/전라북도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/제주특별자치도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/충청남도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
LOAD data LOCAL INFILE 'D:/workspace_mybatis/PostZip_finder/DataFiles/충청북도.txt'
INTO table post
character set 'euckr'
fields TERMINATED by '|'
IGNORE 1 lines
(@zipcode, @sido, @d, @sigungu , @d, @d, @d, @d, @doro, @d, @d, @building1, @building2, @d, @d, @d, @d, @d, @d ,@d, @d, @d, @d, @d, @d, @d)
set zipcode=@zipcode, sido=@sido, sigungu=@sigungu, doro=@doro, building1=@building1, building2=@building2;
select * from post;
select count(*) from post;
select * from post where zipcode = 42287 and sido = '대구광역시' and doro = '고산로'; | true |
62644975d175c8d2fa9ee7aa95df6031f59381c3 | SQL | ddfs/odoo | /scripts/unbalanced-journal-entriy.sql | UTF-8 | 430 | 3.6875 | 4 | [] | no_license | /* filters unbalanced journal entries in account_move and account_move_line */
SELECT t.*, abs(t.total_debit - t.total_credit) as total_diff FROM (
SELECT am.id,
(SELECT sum(aml.debit) as total_debit FROM account_move_line AS aml WHERE aml.move_id = am.id),
(SELECT sum(aml.credit) as total_credit FROM account_move_line AS aml WHERE aml.move_id = am.id)
FROM account_move AS am
) as t
WHERE t.total_debit - t.total_credit > 0
| true |
ea57242d3c60ec780a0a84279f54216f84fbde8a | SQL | HomarDavila/Enrollment2 | /EnrollmentDB/ExportAses/Tables/ProcessHeader.sql | UTF-8 | 669 | 2.671875 | 3 | [] | no_license | CREATE TABLE [ExportAses].[ProcessHeader] (
[ID] INT IDENTITY (1, 1) NOT NULL,
[FileName] NVARCHAR (256) NULL,
[ProcessType] NVARCHAR (100) NOT NULL,
[StartTime] DATETIME NULL,
[EndTime] DATETIME NULL,
[CreatedBy] VARCHAR (50) NOT NULL,
[CreatedOn] DATETIME CONSTRAINT [DF_File_CreatedOn] DEFAULT (getdate()) NOT NULL,
[UpdatedBy] VARCHAR (50) NULL,
[UpdatedOn] DATETIME NULL,
[Enabled] BIT CONSTRAINT [DF_File_Void] DEFAULT ((0)) NOT NULL,
[Exception] VARCHAR (2048) NULL,
CONSTRAINT [PK_File] PRIMARY KEY CLUSTERED ([ID] ASC)
);
| true |
77c3704bbd5d58744100db77ac37c0287c8cd3e4 | SQL | TBoris/gorynych | /sql/transport.sql | UTF-8 | 1,783 | 4.46875 | 4 | [] | no_license | -- Aggregate Transport -----------------------------------------
CREATE TABLE TRANSPORT_TYPE(
ID SERIAL PRIMARY KEY ,
TRANSPORT_TYPE TEXT UNIQUE NOT NULL
);
INSERT INTO TRANSPORT_TYPE(TRANSPORT_TYPE) VALUES ('bus'), ('car'),
('motorcycle'), ('helicopter');
CREATE TABLE TRANSPORT(
ID BIGSERIAL PRIMARY KEY ,
TRANSPORT_ID TEXT UNIQUE NOT NULL ,
TITLE TEXT NOT NULL ,
TYPE INT REFERENCES TRANSPORT_TYPE(ID) NOT NULL ,
DESCRIPTION TEXT,
PHONE CHARACTER VARYING(50)
);
-- Select transport
SELECT
ID, TRANSPORT_ID, TITLE,
(SELECT TRANSPORT_TYPE FROM TRANSPORT_TYPE WHERE ID=TYPE),
DESCRIPTION, PHONE
FROM TRANSPORT
WHERE
TRANSPORT_ID = %s;
-- Select all_transport
SELECT
TRANSPORT_ID, ID, TRANSPORT_ID, TITLE,
(SELECT TRANSPORT_TYPE FROM TRANSPORT_TYPE WHERE ID=TYPE),
DESCRIPTION, PHONE
FROM TRANSPORT;
-- Insert transport
INSERT INTO TRANSPORT(TITLE, TYPE, DESCRIPTION, PHONE, TRANSPORT_ID)
VALUES (%s,
(SELECT ID FROM TRANSPORT_TYPE WHERE TRANSPORT_TYPE=%s),
%s, %s, %s)
RETURNING ID;
-- Update transport
UPDATE TRANSPORT SET
TITLE=%s,
TYPE=(SELECT ID FROM TRANSPORT_TYPE WHERE TRANSPORT_TYPE=%s),
DESCRIPTION=%s,
PHONE=%s
WHERE TRANSPORT_ID=%s;
-- Select transport_for_contest
SELECT
transport_type.transport_type,
transport.title,
transport.description,
tracker.tracker_id,
transport.transport_id
FROM
contest,
participant,
tracker,
tracker_assignees,
transport,
transport_type
WHERE
participant.participant_id = transport.transport_id AND
participant.id = contest.id AND
tracker.id = tracker_assignees.id AND
tracker_assignees.assignee_id = participant.participant_id AND
transport.type = transport_type.id AND
participant.type = 'transport' AND
contest.contest_id = %s;
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.