text stringlengths 6 9.38M |
|---|
CREATE DATABASE IF NOT EXISTS `portfoliodb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `portfoliodb`;
-- MySQL dump 10.13 Distrib 8.0.22, for Win64 (x86_64)
--
-- Host: localhost Database: portfoliodb
-- ------------------------------------------------------
-- Server version 8.0.22
/*!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 `transakcije`
--
DROP TABLE IF EXISTS `transakcije`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `transakcije` (
`id` int NOT NULL AUTO_INCREMENT,
`adressFrom` varchar(45) NOT NULL,
`adressTo` varchar(45) NOT NULL,
`ammount` float NOT NULL,
`time` datetime DEFAULT CURRENT_TIMESTAMP,
`valutaId` int NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
KEY `fk_valute_id_idx` (`valutaId`),
CONSTRAINT `fk_valute_id` FOREIGN KEY (`valutaId`) REFERENCES `valute` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `transakcije`
--
LOCK TABLES `transakcije` WRITE;
/*!40000 ALTER TABLE `transakcije` DISABLE KEYS */;
INSERT INTO `transakcije` VALUES (1,'hfhdhdfhdhd','sdgsdgsgsg',10,'2019-10-20 10:15:08',1),(2,'gdgddggd','qqqqqq',43.2,'2019-10-20 10:15:08',1);
/*!40000 ALTER TABLE `transakcije` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `valute`
--
DROP TABLE IF EXISTS `valute`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `valute` (
`id` int NOT NULL AUTO_INCREMENT,
`naziv` varchar(45) NOT NULL,
`tracer` varchar(10) NOT NULL,
`opis` varchar(1024) DEFAULT NULL,
`time` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `valute`
--
LOCK TABLES `valute` WRITE;
/*!40000 ALTER TABLE `valute` DISABLE KEYS */;
INSERT INTO `valute` VALUES (1,'Bitcoin','BTC','Bitkoin je digitalna i globalna valuta. Stvorena je 2009. godine od strane lica ili grupe ljudi pod pseudonimom Satoši Nakamoto.','2019-10-20 10:15:08'),(2,'Etherium','ETC','Ethereum is a decentralized, open-source blockchain featuring smart contract functionality.','2019-10-20 10:15:08'),(3,'Dogecoin','DOGE','Dogecoin (/ˈdoʊdʒkɔɪn/ DOHJ-koyn,[1] code: DOGE, symbol: Ð) is a cryptocurrency invented by software engineers Billy Markus and Jackson Palmer, who decided to create a payment system that is instant, fun, and free from traditional banking fees.','2019-10-20 10:15:08');
/*!40000 ALTER TABLE `valute` 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-02-16 10:31:38
|
SELECT S.pro_id
FROM "user" as U JOIN "special_user" as S ON U.username = S.username
WHERE U.username = ?; |
--
-- Copyright 2017-2017 Spotify AB
--
-- 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.
--
-- Upgrade to handle the metrics request mechanism
DROP TABLE IF EXISTS node_metrics;
CREATE TABLE IF NOT EXISTS node_metrics_v1 (
time_partition bigint,
run_id uuid,
node text,
cluster text,
datacenter text,
requested boolean,
pending_compactions int,
has_repair_running boolean,
active_anticompactions int,
PRIMARY KEY((run_id, time_partition), node)
)
WITH compaction = {'class':'SizeTieredCompactionStrategy', 'unchecked_tombstone_compaction':'true'}
AND caching = {'keys':'ALL', 'rows_per_partition':'ALL'}
AND gc_grace_seconds = 120
AND default_time_to_live = 180;
|
select product_in_branch.product_barcode,
product.name,
concat(b.TOWN,', ', b.ADDRESS) as branch,
M.name as manufaurer_name,
C.country_name,
product_in_branch.amount_in_stock
from product
join product_in_branch on product.barcode = product_in_branch.product_barcode
join Manufacturer M on product.manufacturld = M.id
join country C on M.countryid = C.id
join branchs b on b.ID = product_in_branch.branch_id
where product_in_branch.amount_in_stock <= :min_amount; |
create table carts_products (
cart_id bigserial not null,
product_id bigint not null,
quantity int not null,
created_at timestamptz DEFAULT now(),
updated_at timestamptz DEFAULT now()
) with (OIDS = FALSE); |
SELECT name, id, email, cohort_id
FROM students
WHERE email NOT LIKE '%gmail.com'
AND phone IS NULL; |
/* MySQL 8.0.23 adds support for writing host part of account names in
* CIDR notation.
* See https://dev.mysql.com/doc/refman/8.0/en/account-names.html
*/
/* To create a user that could connect from a specific network */
CREATE USER 'test1'@'192.168.100.0/255.255.255.0';
/* Hey, this should also work properly in MySQL 8.0.23 and later */
CREATE user 'test2'@'192.168.100.0/24';
/* TODO: Test with different network masks */
|
Create Procedure sp_Delete_RecCustomers(@ID int)
As
Update ReceivedCustomers Set Status=(Status |192)
Where ID=@ID
|
select
distinct repo_group
from
gha_repos
where
repo_group is not null
order by
repo_group asc
;
|
INSERT INTO post(id,title,content) values (1,'Sometimes...','This is a story about...');
INSERT INTO post(id,title,content) values (2,'Beginning','What I am about to release...'); |
SET MODE POSTGRESQL;
CREATE TABLE IF NOT EXISTS Person (
id INT PRIMARY KEY AUTO_INCREMENT, --todo 18.11.2017: UUID from Java
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255),
-- professional BOOLEAN DEFAULT FALSE,
dob DATE,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
address VARCHAR(255),
telephone VARCHAR(15)
);
CREATE TABLE IF NOT EXISTS Role (
id INT PRIMARY KEY, --todo 18.11.2017: UUID from Java
description VARCHAR(255),
name VARCHAR(80)
);
CREATE TABLE IF NOT EXISTS User (
id INT PRIMARY KEY, --todo 18.11.2017: UUID from Java
role_id INT,
FOREIGN KEY (id) REFERENCES Person (id),
FOREIGN KEY (role_id) REFERENCES Role (id)
);
INSERT INTO Role (id, description, name) VALUES (1, '', 'ADMIN'); --1
INSERT INTO Role (id, description, name) VALUES (2, '', 'MODERATOR'); --2
INSERT INTO Role (id, description, name) VALUES (3, '', 'GARDENER'); --3
INSERT INTO Role (id, description, name) VALUES (4, '', 'CONSULT'); --4
INSERT INTO Role (id, description, name) VALUES (5, '', 'MANAGER'); --5
INSERT INTO Role (id, description, name) VALUES (6, '', 'SALE'); --6
INSERT INTO Person (first_name, last_name, dob, email, password, address, telephone)
VALUES ('Jose', 'Eglesias', '1980-06-15', 'Jose_Eglesias@mail.es', 'qwerty', 'Franco square, 5/1, 10',
'+38007654321');
INSERT INTO User (id, role_id) VALUES (1, 1);
INSERT INTO Person (first_name, last_name, dob, email, password, address, telephone)
VALUES ('John', 'Eglesias', '1980-06-15', 'John_Eglesias@mail.es', 'qwerty', 'Franco square, 5/1, 10',
'+38007654321');
INSERT INTO User (id, role_id) VALUES (2, 2);
INSERT INTO Person (first_name, last_name, dob, email, password, address, telephone)
VALUES ('Pit', 'Eglesias', '1980-06-15', 'Pit_Eglesias@mail.es', 'qwerty', 'Franco square, 5/1, 10',
'+38007654321');
INSERT INTO User (id, role_id) VALUES (3, 3);
INSERT INTO Person (first_name, last_name, dob, email, password, address, telephone)
VALUES ('Aisha', 'Eglesias', '1980-06-15', 'Aisha_Eglesias@mail.es', 'qwerty', 'Franco square, 5/1, 10',
'+38007654321');
INSERT INTO User (id, role_id) VALUES (4, 4);
INSERT INTO Person (first_name, last_name, dob, email, password, address, telephone)
VALUES ('Paul', 'Eglesias', '1980-06-15', 'Aisha_Eglesias@mail.es', 'qwerty', 'Franco square, 5/1, 10',
'+38007654321');
INSERT INTO User (id, role_id) VALUES (5, 5);
INSERT INTO Person (first_name, last_name, dob, email, password, address, telephone)
VALUES ('Anton', 'Eglesias', '1980-06-15', 'Aisha_Eglesias@mail.es', 'qwerty', 'Franco square, 5/1, 10',
'+38007654321');
INSERT INTO User (id, role_id) VALUES (6, 6); |
-- phpMyAdmin SQL Dump
-- version 4.9.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Sep 29, 2020 at 04:58 PM
-- Server version: 5.7.26
-- PHP Version: 7.4.2
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 */;
--
-- Database: `DestinoCerto`
--
-- --------------------------------------------------------
--
-- Table structure for table `Contato`
--
CREATE TABLE `Contato` (
`NomeCompleto` varchar(255) DEFAULT NULL,
`Email` varchar(255) DEFAULT NULL,
`Assunto` varchar(255) DEFAULT NULL,
`Mensagem` varchar(1000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `Contato`
--
INSERT INTO `Contato` (`NomeCompleto`, `Email`, `Assunto`, `Mensagem`) VALUES
('Lucca Bringhenti', 'email@email.com', 'Suporte', 'aSDASDASDASDASDcu\r\n'),
('Lucca Bringhenti', 'teste@teste.com', 'Suporte', 'aSDASDASDASDASDcu\r\n'),
('Nome Completo', 'email@teste.com', 'Outro Assunto', 'Teste da aplicação');
-- --------------------------------------------------------
--
-- Table structure for table `Pacotes`
--
CREATE TABLE `Pacotes` (
`idPacote` int(11) NOT NULL AUTO_INCREMENT,
`nomePacote` varchar(255) DEFAULT NULL,
`origemPacote` varchar(255) DEFAULT NULL,
`destinoPacote` varchar(255) DEFAULT NULL,
`atrativosPacote` varchar(255) DEFAULT NULL,
`saidaPacote` date DEFAULT NULL,
`retornoPacote` date DEFAULT NULL,
`idCriador` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `Pacotes`
--
INSERT INTO `Pacotes` (`idPacote`, `nomePacote`, `origemPacote`, `destinoPacote`, `atrativosPacote`, `saidaPacote`, `retornoPacote`, `idCriador`) VALUES
(1, 'Serra Gaúcha', 'Bento Gonçalves', 'Garibaldi', 'Tour completo da Serra Gaúcha', '2020-12-25', '2020-01-06', 1),
(2, 'Rota Romântica', 'Caxias do Sul', 'Morro Reuter', 'Rota Romântica Gaúcha', '2020-05-04', '2020-05-14', 1);
-- --------------------------------------------------------
--
-- Table structure for table `Usuarios`
--
CREATE TABLE `Usuarios` (
`idUsuario` int(11) NOT NULL,
`nomeUsuario` varchar(255) DEFAULT NULL,
`dataNascimento` datetime DEFAULT NULL,
`loginUsuario` varchar(255) DEFAULT NULL,
`senhaUsuario` varchar(255) DEFAULT NULL,
`tipoUsuario` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `Usuarios`
--
INSERT INTO `Usuarios` (`idUsuario`, `nomeUsuario`, `dataNascimento`, `loginUsuario`, `senhaUsuario`, `tipoUsuario`) VALUES
(1, 'Administrador', '2020-09-24 19:20:41', 'admin', 'admin', 0),
(2, 'Colaborador', '2020-09-24 19:20:41', 'colab', 'colab', 1),
(3, 'Lucca', '2003-05-04 00:00:00', 'luccab', 'luccab', 0),
(4, 'Lucca', '2004-04-05 00:00:00', 'luccabcolab', 'luccabcolab', 1);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `Pacotes`
--
ALTER TABLE `Pacotes`
ADD PRIMARY KEY (`idPacote`),
ADD KEY `idCriador` (`idCriador`);
--
-- Indexes for table `Usuarios`
--
ALTER TABLE `Usuarios`
ADD PRIMARY KEY (`idUsuario`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `Pacotes`
--
ALTER TABLE `Pacotes`
MODIFY `idPacote` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `Usuarios`
--
ALTER TABLE `Usuarios`
MODIFY `idUsuario` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `Pacotes`
--
ALTER TABLE `Pacotes`
ADD CONSTRAINT `pacotes_ibfk_1` FOREIGN KEY (`idCriador`) REFERENCES `Usuarios` (`idUsuario`);
/*!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 */;
|
Create Procedure MERP_SP_getDistinctFSUID
AS
Begin
-- Since Old version FSU should not requested to portal, we are making the below change
select distinct T.FSUID from tblinstallationdetail T,Setup S, tbl_merp_fileinfo F,Tbl_merp_configabstract Config where IsNull(T.Status, 0) & 4 = 4
and S.Version=F.BuildVersion
And Config.ScreenCode='FSUCutoff'
And T.FSUID >= Cast(Description as int)
and T.FSUID = F.FSUID
order by T.FSUID
End
|
-- Mar 6, 2008 6:40:40 PM CST
-- Change P_String
UPDATE AD_Column SET FieldLength=255,Updated=TO_DATE('2008-03-06 18:40:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=2791
;
-- Mar 6, 2008 6:40:40 PM CST
-- Change P_String
UPDATE AD_Field SET Name='Process String', Description='Process Parameter', Help=NULL WHERE AD_Column_ID=2791 AND IsCentrallyMaintained='Y'
;
-- Mar 6, 2008 6:40:45 PM CST
-- Change P_String
ALTER TABLE AD_PInstance_Para MODIFY P_String NVARCHAR2(255) DEFAULT NULL
;
-- Mar 6, 2008 6:41:54 PM CST
-- Change P_String
UPDATE AD_Column SET FieldLength=255,Updated=TO_DATE('2008-03-06 18:41:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=2792
;
-- Mar 6, 2008 6:41:54 PM CST
-- Change P_String
UPDATE AD_Field SET Name='Process String To', Description='Process Parameter', Help=NULL WHERE AD_Column_ID=2792 AND IsCentrallyMaintained='Y'
;
-- Mar 6, 2008 6:41:58 PM CST
-- Change P_String
ALTER TABLE AD_PInstance_Para MODIFY P_String_To NVARCHAR2(255) DEFAULT NULL
;
|
SELECT name, kyoka, tokuten
FROM students
RIGHT OUTER JOIN seiseki ON students.student_no = seiseki.student_no
WHERE kyoka is not null; |
/*
执行用时:380 ms, 在所有 MySQL 提交中击败了26.57% 的用户
内存消耗:0 B, 在所有 MySQL 提交中击败了100.00% 的用户
通过测试用例:14 / 14
*/
# Write your MySQL query statement below
select distinct a.* from stadium a, stadium b, stadium c
where a.people >= 100 and b.people >= 100 and c.people >= 100 and
(
(a.id = b.id - 1 and b.id = c.id - 1) or
(b.id = a.id - 1 and a.id = c.id - 1) or
(b.id = c.id - 1 and c.id = a.id - 1)
)
order by id
/*
执行用时:413 ms, 在所有 MySQL 提交中击败了11.85% 的用户
内存消耗:0 B, 在所有 MySQL 提交中击败了100.00% 的用户
通过测试用例:14 / 14
*/
# Write your MySQL query statement below
select id, visit_date, people from
(
select *,
lead(people, 1) over(order by visit_date) as next1,
lead(people, 2) over(order by visit_date) as next2,
lag(people, 1) over(order by visit_date) as pre1,
lag(people, 2) over(order by visit_date) as pre2
from stadium
) t
where people >= 100 and (
pre1 >= 100 and pre2 >= 100 or
pre1 >= 100 and next1 >= 100 or
next1 >= 100 and next2 >= 100
)
|
CREATE TABLE spots (
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
name varchar(50),
tags varchar(50),
address varchar(50),
city varchar(50),
state varchar(50),
lat decimal,
lon decimal
);
CREATE TABLE lists (
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
name varchar(50),
tags varchar(50),
city varchar(50),
state varchar(50),
is_public BOOLEAN
);
CREATE TABLE lists_spots (
list_id INTEGER,
spot_id INTEGER,
FOREIGN KEY (list_id) REFERENCES lists(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (spot_id) REFERENCES spots(id) ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE users_lists (
users_id INTEGER,
list_id INTEGER,
FOREIGN KEY (users_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (list_id) REFERENCES lists(id) ON UPDATE CASCADE ON DELETE CASCADE
);
|
/*
How to query the database to find the size of all page drafts per space
Confluence administrators may want to audit draft page usage on their instance.
link: https://confluence.atlassian.com/confkb/how-to-query-the-database-to-find-the-size-of-all-page-drafts-per-space-998664642.html
*/
select
count(content.contentid) as number_of_drafts,
pg_size_pretty(sum(pg_column_size(bodycontent.body))) as total_size_of_drafts,
spaces.spacename as space_name
from bodycontent
inner join content on (content.contentid = bodycontent.contentid)
inner join spaces on (content.spaceid = spaces.spaceid)
where bodycontent.contentid in
(select contentid from CONTENT where CONTENT_STATUS = 'draft' and CONTENTTYPE = 'PAGE')
GROUP BY space_name
ORDER BY number_of_drafts DESC, space_name; |
-- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Server version: 10.1.31-MariaDB
-- PHP Version: 7.2.3
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: `dallas`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`id` int(11) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updationDate` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `username`, `password`, `creationDate`, `updationDate`) VALUES
(1, 'admin', 'f925916e2754e5e03f75dd58a5733251', '2020-10-24 16:21:18', '21-11-2020 08:27:55 PM');
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE `category` (
`id` int(11) NOT NULL,
`categoryName` varchar(255) DEFAULT NULL,
`categoryDescription` longtext,
`creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updationDate` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `category`
--
INSERT INTO `category` (`id`, `categoryName`, `categoryDescription`, `creationDate`, `updationDate`)
VALUES ('1', 'Plant', NULL, '2020-12-01 13:29:33', NULL),
('2', 'Pots', NULL, '2020-12-01 13:29:33', NULL),
('3', 'Gifts', NULL, '2020-12-01 13:31:28', NULL),
('4', 'Accessories', NULL, '2020-12-01 13:31:28', NULL;
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`id` int(11) NOT NULL,
`userId` int(11) DEFAULT NULL,
`productId` varchar(255) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL,
`orderDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`paymentMethod` varchar(50) DEFAULT NULL,
`orderStatus` varchar(55) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `orders`
--
INSERT INTO `orders` (`id`, `userId`, `productId`, `quantity`, `orderDate`, `paymentMethod`, `orderStatus`) VALUES
(1, 1, '3', 1, '2017-03-07 19:32:57', 'COD', NULL),
(3, 1, '4', 1, '2017-03-10 19:43:04', 'Debit / Credit card', 'Delivered'),
(4, 1, '17', 1, '2017-03-08 16:14:17', 'COD', 'in Process'),
(5, 1, '3', 1, '2017-03-08 19:21:38', 'COD', NULL),
(6, 1, '4', 1, '2017-03-08 19:21:38', 'COD', NULL);
-- --------------------------------------------------------
--
-- Table structure for table `ordertrackhistory`
--
CREATE TABLE `ordertrackhistory` (
`id` int(11) NOT NULL,
`orderId` int(11) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`remark` mediumtext,
`postingDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `ordertrackhistory`
--
INSERT INTO `ordertrackhistory` (`id`, `orderId`, `status`, `remark`, `postingDate`) VALUES
(1, 3, 'in Process', 'Order has been Shipped.', '2017-03-10 19:36:45'),
(2, 1, 'Delivered', 'Order Has been delivered', '2017-03-10 19:37:31'),
(3, 3, 'Delivered', 'Product delivered successfully', '2017-03-10 19:43:04'),
(4, 4, 'in Process', 'Product ready for Shipping', '2017-03-10 19:50:36');
-- --------------------------------------------------------
--
-- Table structure for table `productreviews` -> comment
--
CREATE TABLE `productreviews` (
`id` int(11) NOT NULL,
`productId` int(11) DEFAULT NULL,
`quality` int(11) DEFAULT NULL,
`price` int(11) DEFAULT NULL,
`value` int(11) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`summary` varchar(255) DEFAULT NULL,
`review` longtext,
`reviewDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `productreviews`
--
INSERT INTO `productreviews` (`id`, `productId`, `quality`, `price`, `value`, `name`, `summary`, `review`, `reviewDate`) VALUES
(2, 3, 4, 5, 5, 'Nan', 'BEST PRODUCT FOR ME :)', 'BEST PRODUCT FOR ME :)', '2017-02-26 20:43:57'),
(3, 3, 3, 4, 3, 'Nannn', 'Nice Product', 'Value for money', '2017-02-26 20:52:46'),
(4, 3, 3, 4, 3, 'Nannnn', 'Nice Product', 'Value for money', '2017-02-26 20:59:19');
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`id` int(11) NOT NULL,
`category` int(11) NOT NULL,
`subCategory` int(11) DEFAULT NULL,
`productName` varchar(255) DEFAULT NULL,
`productPrice` int(11) DEFAULT NULL,
`productSize` varchar(25) DEFAULT NULL,
`productPriceBeforeDiscount` int(11) DEFAULT NULL,
`productDescription` longtext,
`productImage1` varchar(255) DEFAULT NULL,
`productImage2` varchar(255) DEFAULT NULL,
`productImage3` varchar(255) DEFAULT NULL,
`shippingCharge` int(11) DEFAULT NULL,
`productAvailability` varchar(255) DEFAULT NULL,
`postingDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updationDate` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `category`, `subCategory`, `productName`, `productPrice`, `productSize`, `productPriceBeforeDiscount`, `productDescription`, `productImage1`, `productImage2`, `productImage3`, `shippingCharge`, `productAvailability`, `postingDate`, `updationDate`) VALUES
('1', '1', '1', 'Marimo Moss Ball', '6.50', '1.5', '7.00', '<p> name: aegagropila linnaei (Marimo Moss Ball)</p>\r\n\r\n<p>light: low</p>\r\n\r\n<p>water: change water every 1-2 weeks, cold water only</p>\r\n\r\n<p>other: 3-4 cm diameter // turn and squeeze the moss balls when changing water to keep their shape</p>', NULL, NULL, NULL, NULL, NULL, '2020-11-09 20:04:39', NULL);
-- --------------------------------------------------------
ALTER TABLE `products`
DROP `productPriceBeforeDiscount`,
DROP `shippingCharge`;
--
-- Table structure for table `subcategory`
--
CREATE TABLE `subcategory` (
`id` int(11) NOT NULL,
`categoryid` int(11) DEFAULT NULL,
`subcategory` varchar(255) DEFAULT NULL,
`creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updationDate` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `subcategory`
--
INSERT INTO `subcategory` (`id`, `categoryid`, `subcategory`, `creationDate`, `updationDate`)
VALUES ('1', '1', 'Tropical Indoor Plants\r\n', '2020-12-01 13:39:08', NULL),
('2', '1', 'Air Plants\r\n', '2020-12-01 13:39:08', NULL),
('3', '1', 'Aquatic Plants\r\n', '2020-12-01 13:41:16', NULL),
('4', '1', 'Outdoor Plants\r\n', '2020-12-01 13:41:16', NULL);
-- --------------------------------------------------------
--
-- Table structure for table `userlog`
--
CREATE TABLE `userlog` (
`id` int(11) NOT NULL,
`userEmail` varchar(255) DEFAULT NULL,
`userip` binary(16) DEFAULT NULL,
`loginTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`logout` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `userlog`
--
INSERT INTO `userlog` (`id`, `userEmail`, `userip`, `loginTime`, `logout`, `status`) VALUES
(1, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 11:18:50', '', 1),
(2, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 11:29:33', '', 1),
(3, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 11:30:11', '', 1),
(4, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 15:00:23', '26-02-2017 11:12:06 PM', 1),
(5, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 18:08:58', '', 0),
(6, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 18:09:41', '', 0),
(7, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 18:10:04', '', 0),
(8, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 18:10:31', '', 0),
(9, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-26 18:13:43', '', 1),
(10, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-27 18:52:58', '', 0),
(11, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-02-27 18:53:07', '', 1),
(12, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-03 18:00:09', '', 0),
(13, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-03 18:00:15', '', 1),
(14, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-06 18:10:26', '', 1),
(15, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-07 12:28:16', '', 1),
(16, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-07 18:43:27', '', 1),
(17, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-07 18:55:33', '', 1),
(18, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-07 19:44:29', '', 1),
(19, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-08 19:21:15', '', 1),
(20, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-15 17:19:38', '', 1),
(21, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-15 17:20:36', '15-03-2017 10:50:39 PM', 1),
(22, 'anuj.lpu1@gmail.com', 0x3a3a3100000000000000000000000000, '2017-03-16 01:13:57', '', 1),
(23, 'hgfhgf@gmass.com', 0x3a3a3100000000000000000000000000, '2018-04-29 09:30:40', '', 1);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`contactno` bigint(11) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`shippingAddress` longtext,
`shippingState` varchar(255) DEFAULT NULL,
`shippingCity` varchar(255) DEFAULT NULL,
`shippingPincode` int(11) DEFAULT NULL,
`billingAddress` longtext,
`billingState` varchar(255) DEFAULT NULL,
`billingCity` varchar(255) DEFAULT NULL,
`billingPincode` int(11) DEFAULT NULL,
`regDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updationDate` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `name`, `email`, `contactno`, `password`, `shippingAddress`, `shippingState`, `shippingCity`, `shippingPincode`, `billingAddress`, `billingState`, `billingCity`, `billingPincode`, `regDate`, `updationDate`) VALUES
(1, 'Nan', 'nan312@gmail.com', 0123456789, 'f925916e2754e5e03f75dd58a5733251', 'Hanoi University', 'Thanh Xuan', 'Ha Noi', 110001, 'km9 Nguyen Trai Thanh Xuan Ha Noi', 'Thanh Xuan', 'Ha Noi', 110092, '2020-02-11 19:30:50', ''),
(2, 'Maria', 'mariaxuyenpham@gmail.com', 8285703355, '5c428d8875d2948607f3e3fe134d71b4', '', '', '', 0, '', '', '', 0, '2017-03-15 17:21:22', '');
-- --------------------------------------------------------
--
-- Table structure for table `wishlist`
--
CREATE TABLE `wishlist` (
`id` int(11) NOT NULL,
`userId` int(11) DEFAULT NULL,
`productId` int(11) DEFAULT NULL,
`postingDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `wishlist`
--
INSERT INTO `wishlist` (`id`, `userId`, `productId`, `postingDate`) VALUES
(1, 1, 0, '2017-02-27 18:53:17');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `ordertrackhistory`
--
ALTER TABLE `ordertrackhistory`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `productreviews`
--
ALTER TABLE `productreviews`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `subcategory`
--
ALTER TABLE `subcategory`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `userlog`
--
ALTER TABLE `userlog`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `wishlist`
--
ALTER TABLE `wishlist`
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=2;
--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `ordertrackhistory`
--
ALTER TABLE `ordertrackhistory`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `productreviews`
--
ALTER TABLE `productreviews`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- AUTO_INCREMENT for table `subcategory`
--
ALTER TABLE `subcategory`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT for table `userlog`
--
ALTER TABLE `userlog`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `wishlist`
--
ALTER TABLE `wishlist`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
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 */;
|
TRUNCATE cash_sessions RESTART IDENTITY cascade;
INSERT INTO cash_sessions (cash_session_id, buyin, cashout,
hours_played, date, user_id)
VALUES
(1, 300, 400, 5, now(), 1),
(2, 500, 0, 6.25, now(), 3),
(3, 100, 400, 2.5, now(), 5),
(4, 300, 1400, 2.25, now(), 2),
(5, 600, 800, 4.6, now(), 1),
(6, 700, 400, 3.1, now(), 2),
(7, 100, 400, 7.7, now(), 6),
(8, 200, 400, 6.5, now(), 1),
(9, 300, 400, 3.33, now(), 4),
(10, 500, 400, 0.5, now(), 1),
(11, 400, 400, 1, now(), 2),
(12, 300, 400, 5, now(), 4),
(13, 100, 400, 10.5, now(), 5),
(14, 60, 4000, 12, now(), 6);
SELECT setval('cash_sessions_cash_session_id_seq', 14, true); |
-- create user 'kalikalatest'@'localhost' identified by 'kalikalatest';
grant all privileges on kalikalatest.* to 'kalikalatest'@'localhost' identified by 'kalikalatest';
flush privileges;
|
DROP DATABASE IF EXISTS bamazon;
CREATE DATABASE bamazon;
USE bamazon;
CREATE TABLE products (
id INT NOT NULL AUTO_INCREMENT,
product_name VARCHAR(45) NULL,
department_name VARCHAR(20) NULL,
price DECIMAL (10,2) NOT NULL,
quantity INT(10),
product_sales DECIMAL (10,2) NULL,
PRIMARY KEY (id)
);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("tooth brushes", "hygiene", 2.15, 5);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("Xbox", "electronics", 329.99, 13);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("Samsung TV", "electronics", 1099.99, 41);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("deoderant", "hygiene", 4.27, 7);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("pants", "clothing", 10.97, 26);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("Hand Soap", "hygiene", 4.00, 54);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("Smart Phone", "electronics", 300.00, 8);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("Wallet", "accessories", 15.99, 3);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("Silverware Set", "kitchen", 65.77, 19);
INSERT INTO products (product_name, department_name, price, quantity)
VALUE ("Wooden Desk", "furniture", 89.99, 2);
CREATE TABLE departments (
department_id INT NOT NULL AUTO_INCREMENT,
department_name VARCHAR(45) NULL,
overhead_costs DECIMAL(10,2) NULL,
PRIMARY KEY (department_id)
);
INSERT INTO departments (department_name, overhead_cost)
VALUE ("accessories", 10.00);
INSERT INTO departments (department_name, overhead_cost)
VALUE ("electronics", 10.00);
INSERT INTO departments (department_name, overhead_cost)
VALUE ("kitchen", 10.00);
INSERT INTO departments (department_name, overhead_cost)
VALUE ("furniture", 10.00);
INSERT INTO departments (department_name, overhead_cost)
VALUE ("clothing", 10.00);
INSERT INTO departments (department_name, overhead_cost)
VALUE ("hygiene", 10.00);
SELECT * FROM bamazon.departments
|
insert into burgers (burger_name) values ('Quarter pounder');
insert into burgers (burger_name) values ('Big Mac');
insert into burgers (burger_name) values ('Mcdouble'); |
CREATE OR REPLACE FUNCTION fn_jbset(_ks text[])
RETURNS jsonb
LANGUAGE sql AS
$BODY$
SELECT jsonb_object_agg(t, TRUE)
FROM unnest(_ks) t;
$BODY$
CREATE OR REPLACE FUNCTION fn_jbset_conj(_set jsonb, _ks text[])
RETURNS jsonb
LANGUAGE sql AS
$BODY$
SELECT _set||fn_jbset(_ks);
$BODY$
CREATE OR REPLACE FUNCTION fn_jbset_disj(_set jsonb, _ks text[])
RETURNS jsonb
LANGUAGE sql AS
$BODY$
SELECT _set-_ks;
$BODY$
|
-- ----------------------------------------------------------------------------------------------------
-- TABLE: favorites
-- ----------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS favorites;
CREATE TABLE public.favorites (
tenantId integer NOT NULL,
objectGUID uuid NOT NULL,
userGUID uuid NOT NULL,
CONSTRAINT favorites1 PRIMARY KEY (tenantId, objectGUID, userGUID)
);
ALTER TABLE public.favorites
OWNER TO postgres;
GRANT ALL ON TABLE public.favorites TO postgres;
GRANT SELECT, UPDATE, INSERT, TRUNCATE, DELETE ON TABLE public.favorites TO caf;
|
-- BETWEEN--範囲検索
-- ex.販売単価100~1000の商品を検索する
SELECT
name,
unit_price
FROM
items
WHERE
-- 100 <= unit_price <= 1000
unit_price BETWEEN 100 AND 1000
; |
CREATE DATABASE IF NOT EXISTS docker_database;
CREATE TABLE IF NOT EXISTS `docker_database`.`users` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE);
|
\encoding UTF8;
SET client_min_messages TO WARNING;
ALTER TABLE app.acc_utente ADD COLUMN foto OID;
|
DROP DATABASE IF EXISTS scoreboard_data;
CREATE DATABASE scoreboard_data;
USE scoreboard_data;
DROP DATABASE IF EXISTS scoreboard;
CREATE TABLE scoreboard
(
id INT AUTO_INCREMENT UNIQUE,
player VARCHAR(20) NOT NULL,
score INT
);
INSERT INTO scoreboard(player, score) VALUES ("red", 0), ("yellow", 0);
|
--初始化 只运行一次
INSERT INTO td_navigation_menu(
action_type,
channel_id,
icon_id,
is_enable,
link_url,
name,
parent_id,
sort_id,
title,
type
) VALUES(
'view',
'0',
NULL,
TRUE,
'/cash/return/note/list',
'channel_cash_return_note_list',
87,
10,
'退款申请列表',
'system'
);
INSERT INTO td_navigation_menu(
action_type,
channel_id,
icon_id,
is_enable,
link_url,
name,
parent_id,
sort_id,
title,
type
) VALUES(
'view',
'0',
NULL,
TRUE,
'/balance/list',
'balance_log_list',
43,
4,
'预存款变更记录',
'system'
);
INSERT INTO td_navigation_menu(
action_type,
channel_id,
icon_id,
is_enable,
link_url,
name,
parent_id,
sort_id,
title,
type
) VALUES(
'view',
'0',
NULL,
TRUE,
'/goods/inventory/log',
'channel_inventory_log',
26,
6,
'库存日志',
'system'
);
|
# 1.查询同时存在1课程和2课程的情况
#题意不明
# 2.查询同时存在1课程和2课程的情况
#题意不明
# 3.查询平均成绩大于等于60分的同学的学生编号和学生姓名和平均成绩
# 查询每位学生的学生编号和平均成绩
-- select studentId, avg(score) avgScore from student_course
-- group by studentId
select s.id, s.name, sc.avgScore from student s, (select studentId, avg(score) avgScore from student_course
group by studentId) sc
where s.id = sc.studentId and sc.avgScore > 60;
# 4.查询在student_course表中不存在成绩的学生信息的SQL语句
# 查询成绩表中学生的学生编号
-- select studentId from student_course;
select * from student
where id not in (select studentId from student_course);
# 5.查询所有有成绩的SQL
# 查询成绩表中学生的学生编号
-- select studentId from student_course;
select * from student
where id in (select studentId from student_course);
# 6.查询学过编号为1并且也学过编号为2的课程的同学的信息
select distinct s.* from student s, student_course sc01, student_course sc02
where s.id = sc01.studentId and s.id = sc02.studentId
and sc01.courseId = 1 and sc02.courseId = 2;
# 7.检索1课程分数小于60,按分数降序排列的学生信息
select s.* from student s, student_course sc
where s.id = sc.studentId and sc.courseId = 1 and sc.score < 60
order by sc.score desc;
# 8.查询每门课程的平均成绩,结果按平均成绩降序排列,平均成绩相同时,按课程编号升序排列
select courseId, avg(score) from student_course
group by courseId
order by avg(score) desc, courseId;
# 9.查询课程名称为"数学",且分数低于60的学生姓名和分数
select s.name, sc.score from student s, course c, student_course sc
where s.id = sc.studentId and sc.courseId = c.id and c.name = '数学'
and sc.score < 60;
|
SELECT date(time) AS 'Dzień', min(time) AS 'Wschód', max(time) AS 'Zachód'
FROM temp
WHERE measurement IS NOT NULL
GROUP BY day(time)
|
alter TABLE transparencia.acordo_aditamento_itens alter column quantidade type numeric; |
insert into customer (id, name) values (1, 'João da Silva');
insert into customer (id, name) values (2, 'Raimundo José');
insert into product (id, name, value) values (1, 'Celular', 1600.0);
insert into product (id, name, value) values (2, 'Notebook', 2700.0);
insert into product (id, name, value) values (3, 'Carregador', 500.0);
insert into sale (id, registration_date, customer_id, freight, total) values (1, sysdate(), 1, 15.0, 1615.0);
insert into item (id, sale_id, product_id, amount) values (2, 1, 1, 1); |
CREATE PROCEDURE sp_insert_Bank( @ACCOUNT_NO NVARCHAR(50),
@ACCOUNT_NAME NVARCHAR(50),
@BANK_CODE nvarchar(50),
@BRANCH_CODE nvarchar(50))
AS
INSERT INTO Bank(Account_Number,
Account_Name,
BankCode,
BranchCode,
Active)
Values (@ACCOUNT_NO,
@ACCOUNT_NAME,
@BANK_CODE,
@BRANCH_CODE,
1)
SELECT @@IDENTITY
|
ALTER TABLE `properties`
ADD COLUMN `state` ENUM('Active','Inactive') NOT NULL DEFAULT 'Active' AFTER `name`;
UPDATE `properties`
SET `state`='Active' WHERE `status_id`='1';
UPDATE `properties`
SET `state`='Inactive' WHERE `status_id`='2';
ALTER TABLE `properties`
DROP COLUMN `status_id`;
ALTER TABLE `properties`
ADD UNIQUE INDEX `name`(`name`);
|
CREATE DATABASE IF NOT EXISTS testcase
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
use testcase;
Create table if not exists user(
id varchar(32) primary key comment "email",
password varchar(32) ,
name varchar(64) ,
nick varchar(64),
ts timestamp default current_timestamp
);
create table if not exists feed(
no INT unsigned auto_increment primary key comment "sequence",
id varchar(32) comment "same as that of table 'user'",
content varchar(4096),
ts timestamp default current_timestamp
);
|
/*
* Datenbank neu aufbauen (Alle Daten gehen verloren)
*
*/
-- Bestehende Tabellen löschen
drop table if exists TEST;
drop table if exists SPIELER;
create table SPIELER (
SPIELER_ID int primary key not null auto_increment,
NAME varchar(50) not null,
VNAME varchar(50) not null,
GEBDAT date not null,
STATUS int not null
);
create table TEST (
TEST_ID int primary key not null auto_increment,
DATUM date not null,
SPIELER_ID int not null,
TEAM int not null,
DATA blob
);
alter table TEST add constraint FK_TEST_SPIELER foreign key (SPIELER_ID) references SPIELER(SPIELER_ID); |
CREATE TABLE pessoa (
codigo BIGINT(20) PRIMARY KEY AUTO_INCREMENT,
nome VARCHAR(50) NOT NULL,
ativo VARCHAR(10) NOT NULL,
logradouro VARCHAR(50),
numero VARCHAR(50),
complemento VARCHAR(50),
bairro VARCHAR(50),
cep VARCHAR(50),
cidade VARCHAR(50),
estado VARCHAR(50)
) ENGINE=innoDB DEFAULT CHARSET = utf8;
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("AFRAIN","true","AV","","QD 01","ITAPUÃN","74.948-731","","GO");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("GABRIELA","false","RUA","1","QD 01","","74.948-731","GOIÂNIA","GO");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("ANTONIA","true","AV","174","QD 01","SÃO MIGUEL","74.948-731","GOIÂNIA","GO");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("SOPHIA","false","RUA","1","QD 01","GARAVELO B","74.948-731","GOIÂNIA","");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("EDIVAN","true","AV BAND","","QD 01","AEROPORTO SUL","74.948-731","","GO");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("SAMUEL","false","RUA","1","QD 01","","74.948-731","AP. DE GOIÂNIA","GO");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("TAIS","true","AV","47","QD 01","ITAIPU","74.948-731","GOIÂNIA","GO");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("MIRLEN","false","RUA INORIO","1","QD 01","RES. ITAIPU","74.948-731","GOIÂNIA","");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("LUCAS","true","AV CASTELO","","QD 01","GARAVELO","74.948-731","","GO");
INSERT INTO pessoa (nome, ativo, logradouro, numero, complemento, bairro, cep, cidade, estado) value ("LARISSA","false","RUA JARCI","1","QD 01","","74.948-731","GOIÂNIA","GO"); |
/*
SQLyog Community v12.2.4 (64 bit)
MySQL - 5.6.5-m8 : Database - xnode
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!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 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`xnode` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `xnode`;
/*Table structure for table `source_quote` */
DROP TABLE IF EXISTS `source_quote`;
CREATE TABLE `source_quote` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`quote` varchar(400) DEFAULT NULL,
`source` varchar(100) DEFAULT NULL,
`type` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=latin1;
/*Data for the table `source_quote` */
insert into `source_quote`(`id`,`quote`,`source`,`type`) values
(8,'You can do anything, but not everything.','David','My neighbour'),
(9,'The richest man is not he who has the most, but he who needs the least.','Unknown Author',''),
(12,'Work like you don’t need money, love like you’ve never been hurt, and dance like no one’s watching.','Unknown',''),
(14,'You’ve heard of the golden rule, haven’t you? Whoever has the gold makes the rules.','Crazy hunch-backed old guy in Aladdin','Cartoon'),
(15,'Never be afraid to laugh at yourself, after all, you could be missing out on the joke of the century.','Dame Edna Everage','Someone'),
(17,'Advice is what we ask for when we already know the answer but wish we didn’t.','Erica Jong','American novelist'),
(20,'The human heart has hidden treasures, In secret kept, in silence sealed; The thoughts, the hopes, the dreams, the pleasures, Whose charms were broken if revealed.','Jane Eyre','Novel'),
(21,'For you a thousand times over.','The kite runner','Novel');
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
drop table if exists houses;
create table if not exists houses (
id serial,
name varchar(250),
address varchar(250),
city varchar(100),
state varchar(50),
zipcode int
);
insert into houses (
name,
address,
city,
state,
zipcode
) values (
'first name',
'first house',
'first city',
'first state',
12345
);
insert into houses (
name,
address,
city,
state,
zipcode
) values (
'second name',
'second house',
'second city',
'second state',
23456
);
insert into houses (
name,
address,
city,
state,
zipcode
) values (
'third name',
'third house',
'third city',
'third state',
34567
);
select * from houses; |
-- //1 Find the country that start with Y
SELECT name FROM world
WHERE name LIKE 'Y%'
-- //2 Find the countries that end with y
SELECT name FROM world
WHERE name LIKE '%Y'
-- //3 Find the countries that contain the letter x
SELECT name FROM world
WHERE name LIKE '%x%'
-- //4 Find the countries that end with land
SELECT name FROM world
WHERE name LIKE '%land'
-- //5 Find the countries that start with C and end with ia
SELECT name FROM world
WHERE name LIKE 'C%ia'
-- //6 Find the country that has oo in the name
SELECT name FROM world
WHERE name LIKE '%oo%'
-- //7 Find the countries that have three or more a in the name
SELECT name FROM world
WHERE LENGTH(name) - LENGTH(REPLACE(lower(name), 'a', '')) > 2;
-- //8 Find the countries that have "t" as the second character.
SELECT name FROM world
WHERE name LIKE '_t%'
ORDER BY name
-- //9 Find the countries that have two "o" characters separated by two others.
SELECT name FROM world
WHERE name LIKE '%o__o%'
-- //10 FInd the countries that have exactly four characters.
SELECT name FROM world
WHERE name LIKE '____'
-- //11. Findthe country where the name is the capital city.
SELECT name
FROM world
WHERE name = capital
-- //12. Find the country where the capital is the country plus "City"
SELECT name
FROM world
WHERE capital LIKE '%City'
-- //13. Find the capital and the name where the capital includes the name of the county.
SELECT capital, name
FROM world
WHERE capital LIKE concat('%', name, '%');
-- //14 Find the capital and the name where the capital is an extentions of name of the country.
SELECT name, capital
FROM world
WHERE capital LIKE concat('%', name, '%') AND LENGTH(capital) > LENGTH(name);
-- //15 Show the name and the extension where the capital is an extention of nmae of the country
SELECT name, REPLACE(capital, name, '')
FROM world
WHERE capital LIKE concat('%', name, '%') AND capital > name;
|
/*
Navicat MySQL Data Transfer
Source Server : sy
Source Server Type : MySQL
Source Server Version : 50722
Source Host : localhost:3306
Source Schema : article_spider
Target Server Type : MySQL
Target Server Version : 50722
File Encoding : 65001
Date: 09/07/2018 22:31:18
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for jobbole_article
-- ----------------------------
DROP TABLE IF EXISTS `jobbole_article`;
CREATE TABLE `jobbole_article` (
`title` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章标题',
`create_time` date NULL DEFAULT NULL COMMENT '文章创建时间',
`url` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章url',
`url_obejct_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '文章url的md5值',
`front_image_url` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '每篇文章首页的图片路径',
`front_image_path` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片下载的本地路径',
`comment_nums` int(11) NOT NULL DEFAULT 0 COMMENT '评论数',
`fav_nums` int(11) NOT NULL DEFAULT 0 COMMENT '收藏数',
`parise_nums` int(11) NOT NULL DEFAULT 0 COMMENT '点赞数',
`tags` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文章标签',
`content` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章具体内容',
PRIMARY KEY (`url_obejct_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1; |
-- check_events.sql
-- reports on any events that are set
-- demo by setting some events:
-- alter session set events '10015 trace name context forever, level 3';
-- alter session set sql_trace=true;
set serveroutput on size 1000000
declare
event_level number;
begin
for i in 1..10999 loop
sys.dbms_system.read_ev(i,event_level);
if (event_level > 0) then
dbms_output.put_line('Event '||to_char(i)||' set at level '||
to_char(event_level));
end if;
end loop;
end;
/
|
-- Nginx
insert into depends_on (id , valueName, services_id)
values ( 1, 'apache', 5 );
-- Kibana
insert into depends_on (id , valueName, services_id)
values ( 2, 'elasticsearch', 9 );
-- Kafka
insert into depends_on (id , valueName, services_id)
values ( 3, 'zookeeper', 12 );
|
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 19, 2019 at 08:09 AM
-- Server version: 10.1.36-MariaDB
-- PHP Version: 7.2.11
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: `ecom`
--
-- --------------------------------------------------------
--
-- Table structure for table `brand`
--
CREATE TABLE `brand` (
`brand_id` int(11) NOT NULL,
`brand_name` varchar(50) NOT NULL,
`brand_description` text NOT NULL,
`brand_image` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `brand`
--
INSERT INTO `brand` (`brand_id`, `brand_name`, `brand_description`, `brand_image`) VALUES
(1, 'Levis', 'Bhot Mehnga', 'saafsgdhyghd');
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE `category` (
`cat_id` int(11) NOT NULL,
`cat_name` varchar(50) NOT NULL,
`cat_description` text NOT NULL,
`cat_image` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `category`
--
INSERT INTO `category` (`cat_id`, `cat_name`, `cat_description`, `cat_image`) VALUES
(1, 'Clothes', 'safgjfd dswqdfg', '');
-- --------------------------------------------------------
--
-- Table structure for table `customer`
--
CREATE TABLE `customer` (
`cust_id` int(11) NOT NULL,
`cust_name` varchar(200) NOT NULL,
`cust_email` varchar(500) NOT NULL,
`cust_password` varchar(32) NOT NULL,
`cust_address` text NOT NULL,
`cust_contact` varchar(24) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `employee`
--
CREATE TABLE `employee` (
`emp_id` int(11) NOT NULL,
`emp_name` varchar(200) NOT NULL,
`emp_contact` varchar(22) NOT NULL,
`emp_email` varchar(500) NOT NULL,
`emp_address` text NOT NULL,
`emp_password` varchar(32) NOT NULL,
`emp_designation` varchar(100) NOT NULL,
`emp_nic` varchar(17) NOT NULL,
`emp_salary` int(11) NOT NULL,
`emp_doj` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee`
--
INSERT INTO `employee` (`emp_id`, `emp_name`, `emp_contact`, `emp_email`, `emp_address`, `emp_password`, `emp_designation`, `emp_nic`, `emp_salary`, `emp_doj`) VALUES
(1, 'Dexent Hamza', '3435676543', '', 'Baldia Town', 'dc647eb65e6711e155375218212b3964', 'Manager', '32565587990431', 120000, '13/04/2019'),
(2, 'Mansoor Ali', '09872164344', '', 'Hadiri', '827ccb0eea8a706c4c34a16891f84e7b', 'Accountant', '21334554657', 10000, '3/4/2019'),
(3, 'Nabeel', '03125363723', '', 'Baldia Town', '3b16e4b382f5a0e0d386f6b149891a1a', 'Manager', '3256558799043', 214345, '15/04/2019');
-- --------------------------------------------------------
--
-- Table structure for table `nav`
--
CREATE TABLE `nav` (
`nav_id` int(11) NOT NULL,
`nav_name` varchar(50) NOT NULL,
`nav_title` varchar(150) NOT NULL,
`nav_description` varchar(500) NOT NULL,
`nav_status` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`ord_id` int(11) NOT NULL,
`ord_cust_id` int(11) DEFAULT NULL,
`ord_date` varchar(20) DEFAULT NULL,
`ord_status` varchar(25) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `ord_details`
--
CREATE TABLE `ord_details` (
`ord_id` int(11) DEFAULT NULL,
`ord_prd_id` int(11) DEFAULT NULL,
`ord_quantity` int(11) DEFAULT NULL,
`ord_price` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `prd_details`
--
CREATE TABLE `prd_details` (
`prd_id` int(11) DEFAULT NULL,
`prd_name` varchar(100) DEFAULT NULL,
`prd_price` int(11) DEFAULT NULL,
`prd_image` text,
`prd_description` text,
`prd_quantity` int(11) DEFAULT NULL,
`prd_date` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `prd_details`
--
INSERT INTO `prd_details` (`prd_id`, `prd_name`, `prd_price`, `prd_image`, `prd_description`, `prd_quantity`, `prd_date`) VALUES
(NULL, 'Shoes', 2000, 'safdagdsh', 'adsfgds', 10, NULL),
(22, 'Shoes', 2000, 'safdagdsh', 'adsfgds', 10, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `product`
--
CREATE TABLE `product` (
`prd_id` int(11) NOT NULL,
`prd_cat_id` int(11) DEFAULT NULL,
`prd_brand_id` int(11) DEFAULT NULL,
`prd_status` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `product`
--
INSERT INTO `product` (`prd_id`, `prd_cat_id`, `prd_brand_id`, `prd_status`) VALUES
(1, 1, 1, 'enabled'),
(2, 1, 1, 'enabled'),
(3, 1, 1, 'enabled'),
(4, 1, 1, 'enabled'),
(5, 1, 1, 'enabled'),
(6, 1, 1, 'enabled'),
(7, 1, 1, 'enabled'),
(8, 1, 1, 'enabled'),
(9, 1, 1, 'enabled'),
(10, 1, 1, 'enabled'),
(17, 1, 1, 'enabled'),
(18, 1, 1, 'enabled'),
(19, 1, 1, 'enabled'),
(20, 1, 1, 'enabled'),
(21, 1, 1, 'enabled'),
(22, 1, 1, 'enabled');
-- --------------------------------------------------------
--
-- Table structure for table `purchases`
--
CREATE TABLE `purchases` (
`purchase_id` int(11) NOT NULL,
`purchase_prd_id` int(11) DEFAULT NULL,
`purchase_quantity` int(11) DEFAULT NULL,
`purchase_cost_price` int(11) DEFAULT NULL,
`purchase_sale_price` int(11) DEFAULT NULL,
`purchase_date` varchar(35) DEFAULT NULL,
`purchase_advance` int(11) DEFAULT NULL,
`purchase_total` int(11) DEFAULT NULL,
`purchase_balance` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `purchases_return`
--
CREATE TABLE `purchases_return` (
`purchase_return_id` int(11) NOT NULL,
`purchase_return_purchase_id` int(11) DEFAULT NULL,
`purchase_return_quantity` int(11) DEFAULT NULL,
`purchase_return_date` varchar(35) DEFAULT NULL,
`purchase_return_description` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `sales`
--
CREATE TABLE `sales` (
`sale_id` int(11) NOT NULL,
`sale_ord_id` int(11) DEFAULT NULL,
`sale_mod_payment` varchar(250) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `sales_return`
--
CREATE TABLE `sales_return` (
`sale_return_id` int(11) NOT NULL,
`sale_return_sale_id` int(11) DEFAULT NULL,
`sale_prd_id` int(11) DEFAULT NULL,
`sale_return_quantity` int(11) DEFAULT NULL,
`sale_return_date` varchar(25) DEFAULT NULL,
`sale_return_cause_return` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `vendor`
--
CREATE TABLE `vendor` (
`vendor_id` int(11) NOT NULL,
`vendor_name` varchar(150) NOT NULL,
`vendor_company` varchar(100) NOT NULL,
`vendor_company_address` varchar(200) NOT NULL,
`vendor_email` varchar(300) NOT NULL,
`vendor_contact` varchar(24) NOT NULL,
`vendor_address` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `brand`
--
ALTER TABLE `brand`
ADD PRIMARY KEY (`brand_id`);
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`cat_id`);
--
-- Indexes for table `customer`
--
ALTER TABLE `customer`
ADD PRIMARY KEY (`cust_id`);
--
-- Indexes for table `employee`
--
ALTER TABLE `employee`
ADD PRIMARY KEY (`emp_id`);
--
-- Indexes for table `nav`
--
ALTER TABLE `nav`
ADD PRIMARY KEY (`nav_id`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`ord_id`),
ADD KEY `ord_cust_id` (`ord_cust_id`);
--
-- Indexes for table `ord_details`
--
ALTER TABLE `ord_details`
ADD KEY `ord_id` (`ord_id`),
ADD KEY `ord_prd_id` (`ord_prd_id`);
--
-- Indexes for table `prd_details`
--
ALTER TABLE `prd_details`
ADD KEY `prd_id` (`prd_id`);
--
-- Indexes for table `product`
--
ALTER TABLE `product`
ADD PRIMARY KEY (`prd_id`),
ADD KEY `prd_cat_id` (`prd_cat_id`),
ADD KEY `prd_brand_id` (`prd_brand_id`);
--
-- Indexes for table `purchases`
--
ALTER TABLE `purchases`
ADD PRIMARY KEY (`purchase_id`),
ADD KEY `purchase_prd_id` (`purchase_prd_id`);
--
-- Indexes for table `purchases_return`
--
ALTER TABLE `purchases_return`
ADD PRIMARY KEY (`purchase_return_id`),
ADD KEY `purchase_return_purchase_id` (`purchase_return_purchase_id`);
--
-- Indexes for table `sales`
--
ALTER TABLE `sales`
ADD PRIMARY KEY (`sale_id`),
ADD KEY `sale_ord_id` (`sale_ord_id`);
--
-- Indexes for table `sales_return`
--
ALTER TABLE `sales_return`
ADD PRIMARY KEY (`sale_return_id`),
ADD KEY `sale_return_sale_id` (`sale_return_sale_id`),
ADD KEY `sale_prd_id` (`sale_prd_id`);
--
-- Indexes for table `vendor`
--
ALTER TABLE `vendor`
ADD PRIMARY KEY (`vendor_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `brand`
--
ALTER TABLE `brand`
MODIFY `brand_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `cat_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `customer`
--
ALTER TABLE `customer`
MODIFY `cust_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `employee`
--
ALTER TABLE `employee`
MODIFY `emp_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `nav`
--
ALTER TABLE `nav`
MODIFY `nav_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `ord_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `product`
--
ALTER TABLE `product`
MODIFY `prd_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT for table `purchases`
--
ALTER TABLE `purchases`
MODIFY `purchase_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `purchases_return`
--
ALTER TABLE `purchases_return`
MODIFY `purchase_return_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `sales`
--
ALTER TABLE `sales`
MODIFY `sale_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `sales_return`
--
ALTER TABLE `sales_return`
MODIFY `sale_return_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vendor`
--
ALTER TABLE `vendor`
MODIFY `vendor_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
ADD CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`ord_cust_id`) REFERENCES `customer` (`cust_Id`);
--
-- Constraints for table `ord_details`
--
ALTER TABLE `ord_details`
ADD CONSTRAINT `ord_details_ibfk_1` FOREIGN KEY (`ord_id`) REFERENCES `orders` (`ord_id`),
ADD CONSTRAINT `ord_details_ibfk_2` FOREIGN KEY (`ord_prd_id`) REFERENCES `product` (`prd_id`);
--
-- Constraints for table `prd_details`
--
ALTER TABLE `prd_details`
ADD CONSTRAINT `prd_details_ibfk_1` FOREIGN KEY (`prd_id`) REFERENCES `product` (`prd_id`);
--
-- Constraints for table `product`
--
ALTER TABLE `product`
ADD CONSTRAINT `product_ibfk_1` FOREIGN KEY (`prd_cat_id`) REFERENCES `category` (`cat_id`),
ADD CONSTRAINT `product_ibfk_2` FOREIGN KEY (`prd_brand_id`) REFERENCES `brand` (`brand_id`);
--
-- Constraints for table `purchases`
--
ALTER TABLE `purchases`
ADD CONSTRAINT `purchases_ibfk_1` FOREIGN KEY (`purchase_prd_id`) REFERENCES `product` (`prd_id`);
--
-- Constraints for table `purchases_return`
--
ALTER TABLE `purchases_return`
ADD CONSTRAINT `purchases_return_ibfk_1` FOREIGN KEY (`purchase_return_purchase_id`) REFERENCES `purchases` (`purchase_id`);
--
-- Constraints for table `sales`
--
ALTER TABLE `sales`
ADD CONSTRAINT `sales_ibfk_1` FOREIGN KEY (`sale_ord_id`) REFERENCES `orders` (`ord_id`);
--
-- Constraints for table `sales_return`
--
ALTER TABLE `sales_return`
ADD CONSTRAINT `sales_return_ibfk_1` FOREIGN KEY (`sale_return_sale_id`) REFERENCES `sales` (`sale_id`),
ADD CONSTRAINT `sales_return_ibfk_2` FOREIGN KEY (`sale_prd_id`) REFERENCES `product` (`prd_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 */;
|
-- GROUP BY group equal elements
SELECT score, name FROM second_table
WHERE name IS NOT NULL
ORDER BY score DESC;
|
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Dec 10, 2020 at 12:10 AM
-- Server version: 5.7.31
-- PHP Version: 7.3.21
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: `favouritethings`
--
-- --------------------------------------------------------
--
-- Table structure for table `fav_things`
--
DROP TABLE IF EXISTS `fav_things`;
CREATE TABLE IF NOT EXISTS `fav_things` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(20) NOT NULL,
`image` varchar(25) NOT NULL,
`description` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `fav_things`
--
INSERT INTO `fav_things` (`id`, `title`, `image`, `description`) VALUES
(1, 'Music', 'music.jpg', 'I love listening music, every day.'),
(2, 'Movies', 'movies.jpg', 'I consider the theater is one of the best places in the world.'),
(3, 'Hiking', 'hiking.jpg', 'Nothing better than take a walk in the nature.');
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 */;
|
/**
*
* @author Alexey
* @name sums_4calc
* @manual
* @writable per_sums
*/
Select distinct t1.lc_id, t1.services_id, t1.fs_active
, t4.calc_formula, t4.calc_value_formula
, t.per_sums_id, t.flat_service_id
, t.date_id, t.calc, t.benefit
, t.recalc, t.full_calc, t.rate
, t.calc_value
From Calc_object q1
Inner Join lc_flat_services t1 on q1.lc_id = t1.lc_id
and q1.lc_id = t1.lc_id
Inner Join per_sums t on t1.lc_flat_services_id = t.flat_service_id
Inner Join usl_services t3 on t3.usl_services_id = t1.services_id
Inner Join usl_calc_formula t4 on t3.calc_id = t4.usl_calc_formula_id
Where :date_id = t.date_id |
.mode column
.headers on
SELECT bookId, creatorId FROM bookCreator
WHERE bookId=4; |
-- Таблица users --
-- имена таблиц и полей в бэквотак или без них, ни каких кавычек!
CREATE TABLE `users` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`username` VARCHAR(255) NOT NULL UNIQUE,
`pass` VARCHAR(255) NOT NULL,
PRIMARY KEY(id)
)
CHARACTER SET utf8
COLLATE utf8_general_ci;
INSERT INTO `users` (username, pass)
VALUES ('admin', '$2y$10$fc0w8rBPxzu9zcIFX7zcz.cbd9to/CiZ1Dxlrqt47V4gdjVIjbSNW');
|
CREATE SCHEMA [Patient]
|
create table temp as
select
hospital_ownership,
count(provider_id) as log_count
from hospitals
group by hospital_ownership
order by log_count DESC;
|
UPDATE `article` SET `first_img` = 'http://www.lynnzh.top/src/thumbs/thumb_demo.jpeg';
UPDATE `article` SET `file_url` = 'http://www.lynnzh.top/src/issues/issues_demo.html'; |
SELECT
user_id,
current.rev_id,
CAST(current.rev_len AS INT) -
CAST(IFNULL(parent.rev_len, 0) AS INT) bytes_changed,
ve_tag.ct_rev_id IS NOT NULL AS ve_tagged
FROM staging.ve2_experimental_users
INNER JOIN enwiki.revision current ON user_id = current.rev_user
LEFT JOIN enwiki.revision parent ON parent.rev_id = current.rev_parent_id
LEFT JOIN enwiki.change_tag ve_tag ON
ct_rev_id = current.rev_id AND
ct_tag = "visualeditor"
WHERE
current.rev_timestamp BETWEEN "2015052823" and "2015061123" AND
current.rev_timestamp BETWEEN
registration AND
DATE_FORMAT(
DATE_ADD(registration, INTERVAL 7 DAY),
"%Y%m%d%H%i%S"
);
|
create or replace trigger ins_sum after insert on coach for each row set @total = @total + new.salary;
create or replace trigger dec_sum after delete on coach for each row set @total = @total - old.salary;
|
-- link: https://leetcode.com/problems/exchange-seats/description/
-- Not sure the solution below works
select t1.id as id, coalesce(t2.student, t1.student) as student from seat t1 left join seat t2 on ((t1.id+1)^1)-1 = t2.id order by t1.id asc;
|
/*
** Question:https://leetcode.com/problems/project-employees-ii/
*/
-- method 1, Oracle
SELECT
t2.project_id
FROM
(
SELECT
t1.*,
RANK() OVER (ORDER BY t1.emp_cnt DESC) AS pos
FROM
(
SELECT p.project_id, COUNT(*) AS emp_cnt
FROM Project p
GROUP BY p.project_id
) t1
) t2
WHERE t2.pos = 1;
-- method 2, Oracle
WITH t1 AS (
SELECT p.project_id, COUNT(*) AS emp_cnt
FROM Project p
GROUP BY p.project_id
)
SELECT
t1.project_id
FROM t1
WHERE t1.emp_cnt IN
(
SELECT MAX(emp_cnt) AS max_emp_cnt
FROM t1
)
-- method 3.1, MySQL/Postgres
-- Refer to this solution: https://leetcode.com/problems/project-employees-ii/discuss/353448/Easy-Understand-MySQL-Solution
-- This is similar to my method 2, but uses HAVING instead of CTE and WHERE.
select project_id
from project
group by project_id
having count(employee_id) =
(select max(cnt)
from (select project_id, count(distinct employee_id) as cnt
from project
group by project_id) as t1)
-- method 3.2, MySQL/Postgres
-- Refer to this solution: https://leetcode.com/problems/project-employees-ii/discuss/307641/Simple-SQL-solution
SELECT project_id
FROM project
GROUP BY project_id
HAVING COUNT(employee_id) =
(
SELECT count(employee_id)
FROM project
GROUP BY project_id
ORDER BY count(employee_id) desc
LIMIT 1
)
|
-- Enola-ROUDAUT Florimel-FLOTTE Salomé-REBOURS
-- Le script de peuplement doit être lancé après le script de création des contraintes
-------------------------------------------------------------------------------------------------------------- SOMMAIRE
------------------------------------------------------------------------ Contraintes
-- 1. T_VerificationDateExp
-- 2. T_VerificationDateDemande
-- 3. T_VerificationNiveauAcceptation
-- 4. T_IntégrationReactif
-- 5. T_VerificationNomRelevé
-- 6. T_VerificationDivisionEntiere
-------------------------------------------------------------------- Automatisations
-- 1. AutoPlacementGroupe
-- 2. AutoCalculCoeffSurcout Fonctionne pas
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------- CONTRAINTES ----------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------- T_VerificationDateExp
-- DébutExp <= FinExp
create or replace trigger T_VerificationDateExp before insert on EXPERIENCE for each row
begin
if :new.DEBUTEXP > :new.FINEXP then
raise_application_error(-20001, 'Les dates de début et de fin pour une expérience ne sont pas cohérentes');
end if;
end;
/
commit;
--------------------------------------------------------------------------------------------- T_VerificationDateDemande
-- DateChercheur (Date de demande de l'expérience) <= DébutExp
create or replace trigger T_VerificationDateDemande before insert on EXPERIENCE for each row
begin
if :new.DEBUTEXP < :new.DATECHERCHEUR then
raise_application_error(-20002, 'Les dates de demande et de début pour une expérience ne sont pas cohérentes');
end if;
end;
/
commit;
--------------------------------------------------------------------------------------- T_VerificationNiveauAcceptation
-- Les niveaux d'acceptation a1 et a2 sont tels que a1 <= a2
create or replace trigger T_VerificationNiveauAcceptation before insert on EXPERIENCE for each row
begin
if :new.a1 > :new.a2 then
raise_application_error(-20003, 'Attention, a1 doit être < ou = de a2');
end if;
end;
/
commit;
-------------------------------------------------------------------------------------------------- T_IntégrationReactif
-- Eviter les redondances de réactifs :
-- Si le nom du réactif est déjà dans la BDD, il n'est pas à nouveau inséré
-- (ne pas tenir compte de la casse, ni des accents)
create or replace trigger T_IntégrationReactif after insert on REACTIF
declare
nbReac integer:=0;
begin
select count(*) into nbReac from (select count (*) from REACTIF group by upper(nomReactif) having count(*) > 1) maTable;
if nbReac = 1 then
raise_application_error(-20004, 'Ce réactif existe déjà');
end if;
end;
/
commit;
----------------------------------------------------------------------------------------------- T_VérificationNomRelevé
-- Nom_Relevé doit contenir "Colorimétrique" ou "Opacimétrique" exclusivement
create or replace trigger T_VérificationNomRelevé before insert on TYPERELEVE for each row
declare
nom1 VARCHAR(20):='Colorimétrique';
nom2 VARCHAR(20):='Opacimétrique';
begin
if upper(:new.Nom_releve) <> upper(nom1) and upper(:new.Nom_releve) <> upper(nom2) then
raise_application_error(-20005, 'Le nom du releve doit contenir "Colorimétrique" ou "Opacimétrique" exclusivement');
end if;
end;
/
commit;
----------------------------------------------------------------------------------------- T_VerificationDivisionEntiere
-- Durée et fObservation sont tels que d/f donne un résultat entier
create or replace trigger T_VerificationDivisionEntiere before insert on EXPERIENCE for each row
begin
if :new.fObservation <> null then
if mod(:new.Duree,:new.fObservation) <> 0 then
raise_application_error(-20006, 'd/f ne donne pas un résultat entier');
end if;
end if;
end;
/
commit;
----------------------------------------------------------------------------------------------------------------------
--------------------------------------------------- AUTOMATISATIONS --------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------- AutoPlacementGroupe
-- Placement des n replicas d'un groupe sur des plaques
-- Un groupe doit être sur la même plaque
-- Tous les groupes d'une même plaque sont sous les mêmes conditions
-- (opacimétrique/colorimétrique, suivis dans le temps/non suivis dans le temps)
create or replace trigger PlacementGroupe before insert on GROUPE for each row
declare
nb NUMBER;
NbSlotOcc NUMBER;
begin
SELECT NBSLOTPOURGROUPE
INTO nb
FROM GROUPE
NATURAL JOIN EXPERIENCE
WHERE IDEXPERIENCE = :new.IDEXPERIENCE;
for i in (SELECT IDPLAQUE, IDTYPEPLAQUE FROM PLAQUE NATURAL JOIN LOTPLAQUE) loop
SELECT SUM(NBSLOTPOURGROUPE)
INTO NbSlotOcc
FROM EXPERIENCE
NATURAL JOIN GROUPE
WHERE IDPLAQUE = i.IDPLAQUE;
if i.IDTYPEPLAQUE = 0 then
if NbSlotOcc <= 96 - nb then
:new.IDPLAQUE := i.IDPLAQUE;
EXIT;
end if;
else
if NbSlotOcc <= 384 - nb then
:new.IDPLAQUE := i.IDPLAQUE;
EXIT;
end if;
end if;
end loop;
end;
/
------------------------------------------------------------------------------------------------- AutoCalculCoeffSurcout
-- Un niveau de priorité supérieur à 1 a un impact sur le coût de l'expérience
-- Le prix total d'une expérience e est multiplié par le coefficient (n + d)/n
-- n le nombre total d'expériences non réalisées et arrivées avant e (e comprise)
-- d le nombre d'expériences doublées par e dans la file d'attente, du fait de sa priorité
-- Fonctionne pas
-- VERSION 1 PRIORITAIRE
create or replace trigger AutoCalculCoeffSurcout before UPDATE or INSERT on EXPERIENCE for each row
declare
nbN number;
nbE number;
begin
for i in (SELECT * FROM EXPERIENCE WHERE IndicePriorite > 1) loop
SELECT COUNT(*) +1 into nbN
FROM EXPERIENCE
WHERE (
SELECT dateChercheur
FROM EXPERIENCE
JOIN RESULTAT USING (idResultat)
WHERE indicePriorite>1 and AccepteResultat=0) < i.dateChercheur;
SELECT COUNT(*) into nbE
FROM EXPERIENCE
WHERE (SELECT IndicePriorite FROM EXPERIENCE) < i.IndicePriorite;
UPDATE EXPERIENCE SET coeffSurcout = (nbN+nbE)/nbN
WHERE IdExperience=i.IdExperience;
end loop;
end;
/
-- VERSION 2 (SI 1 FONCTIONNE PAS)
drop trigger AutoCalculCoeffSurcout;
create or replace trigger AutoCalculCoeffSurcout before UPDATE or INSERT on EXPERIENCE for each row
declare
nbN NUMBER;
nbE NUMBER;
begin
if :new.IndicePriorite>1 then
SELECT COUNT(*) +1 into nbN
FROM EXPERIENCE
WHERE (
SELECT dateChercheur
FROM EXPERIENCE
JOIN RESULTAT USING (idResultat)
WHERE indicePriorite>1 and AccepteResultat=0) < :new.dateChercheur;
SELECT COUNT(*) into nbE
FROM EXPERIENCE
WHERE (SELECT IndicePriorite FROM EXPERIENCE) < :new.IndicePriorite;
UPDATE EXPERIENCE SET coeffSurcout = (nbN+nbE)/nbN
WHERE IdExperience=:new.IdExperience;
end if;
end;
/ |
CREATE TABLE IF NOT EXISTS clients (
id INT NOT NULL AUTO_INCREMENT,
phone_number VARCHAR(16) NOT NULL,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
PRIMARY KEY (id)
) |
insert into UserInfo (user_name, password) values
("quinn", "qpwd"),
("christian", "cpwd"),
("story", "spwd"),
("benjamin", "bpwd"),
("graham", "gpwd"),
("justin", "jpwd"); |
-- phpMyAdmin SQL Dump
-- version 4.0.10.18
-- https://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Apr 13, 2017 at 09:44 AM
-- Server version: 10.1.22-MariaDB
-- PHP Version: 5.6.30
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: `database_name`
--
-- --------------------------------------------------------
--
-- Table structure for table `active_users`
--
CREATE TABLE IF NOT EXISTS `active_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`sess_id` longtext NOT NULL,
`bought` tinyint(1) NOT NULL,
`expiry` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=75 ;
--
-- Dumping data for table `active_users`
--
INSERT INTO `active_users` (`id`, `user_id`, `sess_id`, `bought`, `expiry`) VALUES
(0, 0, 'ERROR', 0, NULL),
(20, 23, 'ql8kf3ect1ii3p4mhmjmh21vs5', 1, NULL),
(58, 118, '0bmn7egttq4fbrmpm4h7f3d4u7', 1, NULL),
(74, 118, 'e7lhf0uf64lkf4597ovmt00065', 1, NULL),
(71, 121, 'q7vsfh17vsom8eht6m17g1a4u7', 1, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `languages`
--
CREATE TABLE IF NOT EXISTS `languages` (
`cID` int(11) NOT NULL AUTO_INCREMENT,
`cName` varchar(30) NOT NULL,
`cPrice` decimal(10,2) NOT NULL,
`cSmallDesc` varchar(90) NOT NULL,
`cFullDesc` varchar(200) NOT NULL,
`image` varchar(30) NOT NULL,
PRIMARY KEY (`cID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `languages`
--
INSERT INTO `languages` (`cID`, `cName`, `cPrice`, `cSmallDesc`, `cFullDesc`, `image`) VALUES
(1, 'English2', '59.00', 'Beginners course to English. This includes common words, verbs and adjectives. ', ' This guide introduces anyone who is new to the English language and teaches the basics of it. ', 'english.png'),
(2, 'French ', '49.99', 'This course is for new learners to the French language. ', 'The course is composed of learning the most common French words used on a daily basis, most used verbs and adjectives to begin constructing sentences. ', 'french.png');
-- --------------------------------------------------------
--
-- Table structure for table `lessons`
--
CREATE TABLE IF NOT EXISTS `lessons` (
`lesson_id` int(3) NOT NULL,
`course_id` int(3) NOT NULL,
`lesson_desc` varchar(50) NOT NULL,
PRIMARY KEY (`lesson_id`,`course_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `lessons`
--
INSERT INTO `lessons` (`lesson_id`, `course_id`, `lesson_desc`) VALUES
(1, 1, 'English Lesson 1'),
(1, 2, 'French Lesson 1'),
(2, 2, 'French Lesson 2'),
(3, 2, 'French Lesson 3'),
(2, 1, 'English Lesson 2'),
(3, 1, 'English Lesson 3');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(10) NOT NULL AUTO_INCREMENT,
`username` varchar(15) NOT NULL,
`email` varchar(30) NOT NULL,
`password` varchar(80) NOT NULL,
`join_date` date NOT NULL,
`u_permission` int(4) NOT NULL,
`image_name` varchar(50) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`user_id`, `username`, `email`, `password`, `join_date`, `u_permission`, `image_name`) VALUES
(23, 'Luke', 'luke@gmail.com', '$2y$12$x.PigR2aBAzHXDgO3Liraelhy2UCi88lM5ct/UojqxWM03Sk5k1YW', '2016-12-09', 1337, '0'),
(24, 'CollinDev', 'cadams@premierleague.com', '$2y$12$sQtVF6sEkOyWemvQ8J6vAOFb3z/wteB11/mbuj127SZbXeZhwH326', '2016-11-09', 1337, '0'),
(25, 'DEVACC', 'guestacc@premierleague.com', '$2y$12$GztwCr5OEM69hN2xH0zdGOzJPy7hSU/DImwwNQdlr9Gk7q8JaCsF6', '2016-12-10', 1337, '0'),
(26, 'DamianCEO', 'Damian@premierleague.com', '$2y$12$XvxRa2atcXWY8XpSpp/Z4eBH7V2UqS6/WiifhKHaamFrgZ.het1qu', '2015-11-10', 1337, '0'),
(27, 'ChrisCOO', 'chris@premierleague.com', '$2y$12$TaV5nS6H2q3z.8Ds.3hD1Op9FuBfdZFD8HGiu9L357cWGqz.lSMdu', '2015-11-10', 1337, '0'),
(118, 'LukeOKane', 'lukek@gmail.com', '$2y$12$qiTw0IIwfKfuzRSqT6XFX.E.e4bj91eZQf96Wsgy8QYGh1Gb7O40S', '2017-03-09', 0, ''),
(120, 'JohnDoe', 'Jd@gmail.com', '$2y$12$2tw9PLFNTDipm5giSeRPOOEDi1.84ynP4HcTb7PFeVIpKLBxCqVqS', '2017-03-13', 0, ''),
(121, 'Derek@gmail.com', 'Derek2@gmail.com', '$2y$12$ilCd35ffR9NuZzKzJmwgIOpT1OPTNz8c86Y2jwZuybUiWBOsm9lS6', '2017-03-13', 0, '');
-- --------------------------------------------------------
--
-- Table structure for table `user_courses`
--
CREATE TABLE IF NOT EXISTS `user_courses` (
`user_id` int(11) NOT NULL,
`course_id` varchar(3) NOT NULL,
`current_lesson` varchar(3) NOT NULL,
`current_user_sess_id` varchar(100) DEFAULT NULL,
`expiry` datetime DEFAULT NULL,
PRIMARY KEY (`user_id`,`course_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user_courses`
--
INSERT INTO `user_courses` (`user_id`, `course_id`, `current_lesson`, `current_user_sess_id`, `expiry`) VALUES
(23, '1', '3', NULL, NULL),
(23, '2', '2', NULL, NULL),
(115, '1', '0', NULL, NULL),
(115, '2', '1', NULL, NULL),
(114, '1', '0', NULL, NULL),
(116, '1', '2', NULL, NULL),
(116, '2', '0', NULL, NULL),
(118, '1', '1', NULL, NULL),
(118, '2', '0', NULL, NULL),
(120, '1', '0', NULL, NULL),
(121, '2', '2', NULL, NULL);
/*!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 */;
|
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1_3306
Source Server Version : 50718
Source Host : 127.0.0.1:3306
Source Database : logistics
Target Server Type : MYSQL
Target Server Version : 50718
File Encoding : 65001
Date: 2018-11-20 09:42:00
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for waybills
-- ----------------------------
DROP TABLE IF EXISTS `waybills`;
CREATE TABLE `waybills` (
`w_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '运单状态id',
`state` varchar(255) DEFAULT NULL COMMENT '状态名称',
`byte1` varchar(255) DEFAULT NULL COMMENT '备用',
`byte2` int(255) DEFAULT NULL COMMENT '备用',
PRIMARY KEY (`w_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of waybills
-- ----------------------------
INSERT INTO `waybills` VALUES ('1', '待发运单', null, null);
INSERT INTO `waybills` VALUES ('2', '未到运单', null, null);
INSERT INTO `waybills` VALUES ('3', '未结运单', null, null);
INSERT INTO `waybills` VALUES ('4', '已结运单', null, null);
|
CREATE TABLE `article` (
`articleId` int(11) NOT NULL AUTO_INCREMENT,
`articleName` varchar(50) NOT NULL,
`articleContent` text CHARACTER SET latin1,
`articleDescription` varchar(100) DEFAULT NULL,
`articleSubCategoryId` int(11) NOT NULL,
`articleCreatedDate` date NOT NULL,
`articleLastModifiedDate` date NOT NULL,
`articleAuthorUserId` int(11) NOT NULL,
PRIMARY KEY (`articleId`),
KEY `FK_ARTICLE_articleSubCategoryId` (`articleSubCategoryId`),
KEY `FK_ARTICLE_articleAuthorUserId` (`articleAuthorUserId`),
CONSTRAINT `FK_ARTICLE_articleAuthorUserId` FOREIGN KEY (`articleAuthorUserId`) REFERENCES `user` (`userId`),
CONSTRAINT `FK_ARTICLE_articleSubCategoryId` FOREIGN KEY (`articleSubCategoryId`) REFERENCES `sub_category` (`subCategoryId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
create database xidianstudents;
ALTER DATABASE xidianstudents CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
DROP TABLE IF EXISTS xidianstudents.student;
CREATE TABLE xidianstudents.student
(
id INT(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
academy VARCHAR(100),
className VARCHAR(50),
email VARCHAR(50),
name VARCHAR(100)
);
|
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Apr 14, 2015 at 06:07 AM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `temp`
--
-- --------------------------------------------------------
--
-- Table structure for table `rso`
--
CREATE TABLE IF NOT EXISTS `rso` (
`RSOID` int(11) NOT NULL AUTO_INCREMENT,
`UniversityID` int(11) NOT NULL,
`Name` varchar(35) NOT NULL,
`Email` varchar(254) DEFAULT NULL,
`Active` char(1) NOT NULL DEFAULT 'N',
`Description` text NOT NULL,
PRIMARY KEY (`RSOID`),
UNIQUE KEY `Name` (`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
-- --------------------------------------------------------
--
-- Table structure for table `rsomembers`
--
CREATE TABLE IF NOT EXISTS `rsomembers` (
`RSOID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`isAccepted` char(1) NOT NULL,
`isAdmin` char(1) NOT NULL,
PRIMARY KEY (`RSOID`,`UserID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `university`
--
CREATE TABLE IF NOT EXISTS `university` (
`UniversityID` int(11) NOT NULL AUTO_INCREMENT,
`UniversityName` varchar(35) NOT NULL,
`Latitude` float DEFAULT NULL,
`Longitude` float DEFAULT NULL,
`EmailDomain` varchar(35) NOT NULL,
`NumberOfStudents` int(11) NOT NULL,
`Description` text NOT NULL,
PRIMARY KEY (`UniversityID`),
UNIQUE KEY `EmailDomain` (`EmailDomain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`UserID` int(11) NOT NULL AUTO_INCREMENT,
`First` varchar(35) DEFAULT NULL,
`Last` varchar(35) DEFAULT NULL,
`UserEmail` varchar(254) NOT NULL,
`Password` char(60) NOT NULL,
`UserPhoneNumber` varchar(15) DEFAULT NULL,
`IsAdmin` char(1) NOT NULL,
`IsSuperAdmin` char(1) NOT NULL,
`UniversityID` int(11) NOT NULL,
PRIMARY KEY (`UserID`),
UNIQUE KEY `UserEmail` (`UserEmail`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
/*!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 */;
CREATE TABLE `event` (
`EventID` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(100) NOT NULL,
`Location` varchar(50) DEFAULT NULL,
`Adress` varchar(50) NOT NULL,
`Description` varchar(1000) DEFAULT NULL,
`Time` time DEFAULT NULL,
`NumAttendees` int(11) DEFAULT NULL,
`ContactEmail` varchar(254) DEFAULT NULL,
`ContactPhone` varchar(15) DEFAULT NULL,
`Type` varchar(4) DEFAULT NULL,
`Approved` char(1) DEFAULT NULL,
PRIMARY KEY (`EventID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
# __
# .--------.--.--.-----.-----.| |
# | | | |__ --| _ || |
# |__|__|__|___ |_____|__ ||__|
# |_____| |__|
#
# MySQL DML Exercises 10/20 - The IS NULL and IS NOT NULL conditions
# Write a query to select all staff members without a password.
# Include all columns.
SELECT * FROM sakila.staff WHERE password IS NULL;
# Write a query to select all staff members with a password.
# Include all columns, except the password column.
SELECT staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,last_update FROM sakila.staff WHERE password IS NOT NULL;
|
set hive.execution.engine=spark;
drop table if exists dws.dws_activity_salesman_month;
CREATE TABLE dws.dws_activity_salesman_month (
`report_month` string COMMENT '年月',
`city` string COMMENT '分公司',
`market_department` string COMMENT '市场部',
`name` string COMMENT '销售人员',
`has_reach_goal` string COMMENT '是否达标',
`reach_goal_day_rate` double COMMENT '达标天数比例',
`total_activity_num` double COMMENT '活动量合计',
`day_avg_activity_num` double COMMENT '日均活动量',
`reach_goal_day` double COMMENT '累计达标天数',
`csh_num` double COMMENT '累计产说会次数',
`interview_sign_num` double COMMENT '面签笔数',
`loan_num` double COMMENT '放款笔数',
`visit_num` double COMMENT '拜访次数',
`reach_goal_total_rate` double COMMENT '累计活动量达标率',
`isworkday` bigint comment '工作日天数',
`staff_no` string COMMENT '工号',
`higher_level_no` string COMMENT '上级工号',
`higher_level_name` string COMMENT '上级姓名',
`user_type` string COMMENT '用户类型(大道:DADAO,加盟商:FRANC)',
`etl_update_time` timestamp COMMENT '更新时间'
);
------------------------------------------------------------------------------
----月活动量统计-销售人员
------------------------------------------------------------------------------
insert overwrite table dws.dws_activity_salesman_month
select
substr(cast(mm.report_date as string), 1, 7) report_month,--年月
mm.city,--分公司
mm.market_department,--市场部
mm.`name`,--销售人员
if(sum(mm.has_reach_goal)/sum(mm.isworkday)>0.8 or sum(mm.activity_num)/(sum(mm.isworkday)*6)>=1,'是','否') has_reach_goal,--'是否达标',
sum(mm.has_reach_goal)/sum(mm.isworkday) reach_goal_day_rate,--达标天数比例
sum(mm.activity_num) total_activity_num,--活动量合计
sum(mm.activity_num)/sum(mm.isworkday) day_avg_activity_num,--日均活动量
sum(mm.has_reach_goal) reach_goal_day, --累计达标天数
sum(mm.csh_num) csh_num, --累计产说会次数',
sum(mm.interview_sign_num) interview_sign_num, --面签笔数
sum(mm.loan_num) loan_num, --放款笔数
sum(mm.visit_num) visit_num, --拜访次数
sum(mm.activity_num)/(sum(mm.isworkday)*6) reach_goal_total_rate, --累计活动量达标率
sum(mm.isworkday) isworkday, --工作日天数
staff_no,--工号
higher_level_no, --上级工号
higher_level_name, --上级姓名
user_type, --用户类型(大道:DADAO,加盟商:FRANC)
from_unixtime(unix_timestamp(),'yyyy-MM-dd')
from
(
select
vv.*,
if((vv.visit_num+(vv.interview_sign_num+vv.loan_num+vv.csh_num)*4)>=6,'1','0') has_reach_goal,--是否达标
(vv.visit_num+(vv.interview_sign_num+vv.loan_num+vv.csh_num)*4) activity_num --折算活动量
from
dws.tmp_report_activity_base vv
where vv.position = "销售人员"
and vv.report_date > '2018-12-31' and vv.report_date < from_unixtime(unix_timestamp(),'yyyy-MM-dd') and vv.isworkday=1
)mm
group by mm.city, mm.market_department, substr(cast(mm.report_date as string), 1, 7), mm.`name`, staff_no, higher_level_no, higher_level_name, user_type
|
-- 客户表Customer1045,用户购买Product1045所有产品
select customer_id from Customer1045
group by customer_id having count(*) = (select count(*) from Product1045)
create table Customer1045(
customer_id int,
product_key int
);
create table Product1045(
product_key int
);
insert into Customer1045 values (1,5),(2,6),(3,5),(3,6),(1,6);
insert into Product1045 values (5),(6); |
DROP DATABASE IF EXISTS expend_daily;
CREATE DATABASE expend_daily DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
use expend_daily;
#建表
DROP table IF EXISTS `expend_record`;
create table expend_record (
id bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
user_id bigint(20) DEFAULT NULL COMMENT '用户id',
user_name varchar(64) DEFAULT NULL COMMENT '花费者',
time_type int(2) DEFAULT NULL COMMENT '消耗时间,0:早/1:中/2:晚',
action varchar(250) DEFAULT NULL COMMENT '操作',
action_name varchar(250) DEFAULT NULL COMMENT '操作名',
description varchar(255) DEFAULT NULL COMMENT '描述,备注',
expend double DEFAULT NULL COMMENT '花费',
record_time date NULL DEFAULT NULL COMMENT '花费时间',
KEY `id` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '费用记录表';
DROP table IF EXISTS `expend_action`;
CREATE TABLE `expend_action` (
`action` varchar(96) DEFAULT NULL COMMENT '操作动作',
`meta` varchar(225) DEFAULT NULL COMMENT '操作名称',
`description` varchar(225) DEFAULT NULL COMMENT '操作描述',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY `expend_action` (`action`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '费用活动总字典表';
DROP table IF EXISTS `expend_user`;
CREATE TABLE `expend_user` (
user_id bigint(20) NOT NULL COMMENT '用户id',
user_name varchar(64) DEFAULT NULL COMMENT '用户名',
paasword varchar(64) NOT NULL COMMENT '密码',
status int(2) NOT NULL DEFAULT '0' COMMENT '用户使用状态',
full_name varchar(250) DEFAULT NULL COMMENT '昵称',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_time datetime DEFAULT NULL COMMENT '修改时间',
KEY `id` (`user_id`),
UNIQUE KEY (user_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '用户主表';
|
# change the default value of the study name column
ALTER TABLE study CHANGE name name varchar(255) DEFAULT NULL;
# patch identifier
INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL,'patch', 'patch_62_63_e.sql|change the default value of the study name column');
|
use pharmaview;
drop table if exists pvprods;
create table pvprods select * from pvsuperset group by product_id ;
|
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 25-01-2017 a las 04:41:59
-- Versión del servidor: 10.1.13-MariaDB
-- Versión de PHP: 5.6.21
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 datos: `informatica`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `actualizaciones`
--
CREATE TABLE `actualizaciones` (
`id` int(10) UNSIGNED NOT NULL,
`equipos_id` int(10) UNSIGNED NOT NULL,
`soportes_id` int(10) UNSIGNED NOT NULL,
`descripcion` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `departamentos`
--
CREATE TABLE `departamentos` (
`id` int(10) UNSIGNED NOT NULL,
`trabajadores_id` int(10) UNSIGNED NOT NULL,
`nombre` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`descripcion` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `equipos`
--
CREATE TABLE `equipos` (
`id` int(10) UNSIGNED NOT NULL,
`trabajador_id` int(10) UNSIGNED NOT NULL,
`bm` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`nom_equipo` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`ip` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`descripcion` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `migrations`
--
CREATE TABLE `migrations` (
`migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Volcado de datos para la tabla `migrations`
--
INSERT INTO `migrations` (`migration`, `batch`) VALUES
('2014_10_12_000000_create_users_table', 1),
('2014_10_12_100000_create_password_resets_table', 1),
('2017_01_23_132748_create_equipos_table', 1),
('2017_01_24_110456_create_departamentos_table', 1),
('2017_01_24_133750_create_soportes_table', 1),
('2017_01_24_230434_create_trabajadores_table', 1),
('2017_01_24_230623_create_actualizaciones_table', 1),
('2017_01_24_230743_create_tareas_table', 1);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `soportes`
--
CREATE TABLE `soportes` (
`id` int(10) UNSIGNED NOT NULL,
`nombre_completo` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`cedula` int(11) NOT NULL,
`tareas_id` int(10) UNSIGNED NOT NULL,
`actualizaciones_id` int(10) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `tareas`
--
CREATE TABLE `tareas` (
`id` int(10) UNSIGNED NOT NULL,
`trabajadores_id` int(10) UNSIGNED NOT NULL,
`soporte` int(10) UNSIGNED NOT NULL,
`equipo_id` int(10) UNSIGNED NOT NULL,
`descripcion` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`fecha_tarea` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`tipo` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `trabajadores`
--
CREATE TABLE `trabajadores` (
`id` int(10) UNSIGNED NOT NULL,
`tareas_id` int(10) UNSIGNED NOT NULL,
`equipos_id` int(10) UNSIGNED NOT NULL,
`nombre_completo` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`cedula` int(11) NOT NULL,
`telefono` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`departamento_id` int(10) UNSIGNED NOT NULL,
`email` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `users`
--
CREATE TABLE `users` (
`id_user` int(10) UNSIGNED NOT NULL,
`name` varchar(120) COLLATE utf8_unicode_ci NOT NULL,
`apellido` varchar(155) COLLATE utf8_unicode_ci NOT NULL,
`usuario` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(70) COLLATE utf8_unicode_ci NOT NULL,
`nivel` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Volcado de datos para la tabla `users`
--
INSERT INTO `users` (`id_user`, `name`, `apellido`, `usuario`, `password`, `nivel`, `remember_token`, `created_at`, `updated_at`) VALUES
(17, 'Fran', 'Fran', 'fran', '$2y$10$1t25DYdMSmv739AyOpYjyupg3RgRxyRCgm.7IRsYlZInqA3epO1KK', '1', 'IH3VGC2JJpk7w21njJcCM2v77rtSw5DC6lpa6gd1EldnFAHUBapexvVZwMIL', '2017-01-20 18:21:22', '2017-01-23 15:00:16'),
(18, 'Fran', 'Hernandez', 'francis', '$2y$10$KXUP7qBesT5lnaLY9BDzpuoae5m86A9R.ZP2fGOurlAYodMsJNQpO', '3', 'j9guBu9XXMHjPQX7DSEol2pRjIX5rb5EMt7rkCnqrUlzXXjSOcCIXahfuIA5', '2017-01-20 18:31:20', '2017-01-20 18:31:24'),
(19, 'Zulima', 'Cordero', 'kaka', '$2y$10$pZkYNa/Qe4Z2nlIwruk.O.sw23mtrcyr0SiIiJ2s58ncAGCINYWN6', '2', '2lrEgGQP2UXI8cUdFFt0McvOnlbeFLivdGMB862AHLhfAW8JZdKzxgaPc1VR', '2017-01-20 18:56:33', '2017-01-20 18:56:33'),
(20, 'Manu', 'manu', 'manu', '$2y$10$5pbmNiolqTm4krn7pTIkVeCh.sz7.VGewF0iz92wBfgwxbJrjayeq', '1', 'RRmARsXwrHBdbbvHnAFrgCIXxIOcGHTJxu9CC5PjKhZFAnNIDhqd5c1Q3o14', '2017-01-20 19:01:49', '2017-01-20 19:05:03'),
(21, 'zulima', 'zulima', 'zuli', '$2y$10$HRPN38Q6k6FXlJ.7k0fi4u1flbnVuxrXaFW1B2Nya5rtJSa6gOdhi', '1', 'DKrI9umlXkQgGcpPFL6TwR7c8Xd8uutCzhWVCw8nIRilKqxd8prfCDWVT1Us', '2017-01-23 12:09:43', '2017-01-23 12:27:34'),
(22, 'fran', 'fran', 'ronaldo', '$2y$10$.6nx1PW02kFDxJm857PNSOXUT0tPk2iHw0Kp.eRlTuIQjva5JaftG', '1', 'JxrT6NGWErG1xZF87XqPbN6WIjZAetBXAJIA6drfPbU27tiAFtsiaS2LW9gd', '2017-01-23 13:08:01', '2017-01-23 13:08:47');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `users1`
--
CREATE TABLE `users1` (
`id_user` int(10) UNSIGNED NOT NULL,
`id_tarea` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
`cedula` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(120) COLLATE utf8_unicode_ci NOT NULL,
`apellido` varchar(155) COLLATE utf8_unicode_ci NOT NULL,
`usuario` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(70) COLLATE utf8_unicode_ci NOT NULL,
`nivel` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Volcado de datos para la tabla `users1`
--
INSERT INTO `users1` (`id_user`, `id_tarea`, `cedula`, `name`, `apellido`, `usuario`, `password`, `nivel`, `remember_token`, `created_at`, `updated_at`) VALUES
(17, '', '20990397', 'Fran', 'Fran', 'fran', '$2y$10$1t25DYdMSmv739AyOpYjyupg3RgRxyRCgm.7IRsYlZInqA3epO1KK', '1', 'IH3VGC2JJpk7w21njJcCM2v77rtSw5DC6lpa6gd1EldnFAHUBapexvVZwMIL', '2017-01-20 18:21:22', '2017-01-23 15:00:16'),
(18, '', '0', 'Fran', 'Hernandez', 'francis', '$2y$10$KXUP7qBesT5lnaLY9BDzpuoae5m86A9R.ZP2fGOurlAYodMsJNQpO', '3', 'j9guBu9XXMHjPQX7DSEol2pRjIX5rb5EMt7rkCnqrUlzXXjSOcCIXahfuIA5', '2017-01-20 18:31:20', '2017-01-20 18:31:24'),
(19, '', '', 'Zulima', 'Cordero', 'kaka', '$2y$10$pZkYNa/Qe4Z2nlIwruk.O.sw23mtrcyr0SiIiJ2s58ncAGCINYWN6', '2', '2lrEgGQP2UXI8cUdFFt0McvOnlbeFLivdGMB862AHLhfAW8JZdKzxgaPc1VR', '2017-01-20 18:56:33', '2017-01-20 18:56:33'),
(20, '', '', 'Manu', 'manu', 'manu', '$2y$10$5pbmNiolqTm4krn7pTIkVeCh.sz7.VGewF0iz92wBfgwxbJrjayeq', '1', 'RRmARsXwrHBdbbvHnAFrgCIXxIOcGHTJxu9CC5PjKhZFAnNIDhqd5c1Q3o14', '2017-01-20 19:01:49', '2017-01-20 19:05:03'),
(21, '', '', 'zulima', 'zulima', 'zuli', '$2y$10$HRPN38Q6k6FXlJ.7k0fi4u1flbnVuxrXaFW1B2Nya5rtJSa6gOdhi', '1', 'DKrI9umlXkQgGcpPFL6TwR7c8Xd8uutCzhWVCw8nIRilKqxd8prfCDWVT1Us', '2017-01-23 12:09:43', '2017-01-23 12:27:34'),
(22, '', '', 'fran', 'fran', 'ronaldo', '$2y$10$.6nx1PW02kFDxJm857PNSOXUT0tPk2iHw0Kp.eRlTuIQjva5JaftG', '1', 'JxrT6NGWErG1xZF87XqPbN6WIjZAetBXAJIA6drfPbU27tiAFtsiaS2LW9gd', '2017-01-23 13:08:01', '2017-01-23 13:08:47');
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `actualizaciones`
--
ALTER TABLE `actualizaciones`
ADD PRIMARY KEY (`id`),
ADD KEY `actualizaciones_equipos_id_foreign` (`equipos_id`),
ADD KEY `actualizaciones_soportes_id_foreign` (`soportes_id`);
--
-- Indices de la tabla `departamentos`
--
ALTER TABLE `departamentos`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `equipos`
--
ALTER TABLE `equipos`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`),
ADD KEY `password_resets_token_index` (`token`);
--
-- Indices de la tabla `soportes`
--
ALTER TABLE `soportes`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `tareas`
--
ALTER TABLE `tareas`
ADD PRIMARY KEY (`id`),
ADD KEY `tareas_equipo_id_foreign` (`equipo_id`),
ADD KEY `tareas_trabajadores_id_foreign` (`trabajadores_id`);
--
-- Indices de la tabla `trabajadores`
--
ALTER TABLE `trabajadores`
ADD PRIMARY KEY (`id`),
ADD KEY `trabajadores_departamento_id_foreign` (`departamento_id`),
ADD KEY `trabajadores_equipos_id_foreign` (`equipos_id`);
--
-- Indices de la tabla `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id_user`),
ADD UNIQUE KEY `users_usuario_unique` (`usuario`);
--
-- Indices de la tabla `users1`
--
ALTER TABLE `users1`
ADD PRIMARY KEY (`id_user`),
ADD UNIQUE KEY `users_usuario_unique` (`usuario`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `actualizaciones`
--
ALTER TABLE `actualizaciones`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `departamentos`
--
ALTER TABLE `departamentos`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `equipos`
--
ALTER TABLE `equipos`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `soportes`
--
ALTER TABLE `soportes`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `tareas`
--
ALTER TABLE `tareas`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `trabajadores`
--
ALTER TABLE `trabajadores`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `users`
--
ALTER TABLE `users`
MODIFY `id_user` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT de la tabla `users1`
--
ALTER TABLE `users1`
MODIFY `id_user` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `actualizaciones`
--
ALTER TABLE `actualizaciones`
ADD CONSTRAINT `actualizaciones_equipos_id_foreign` FOREIGN KEY (`equipos_id`) REFERENCES `equipos` (`id`),
ADD CONSTRAINT `actualizaciones_soportes_id_foreign` FOREIGN KEY (`soportes_id`) REFERENCES `soportes` (`id`);
--
-- Filtros para la tabla `tareas`
--
ALTER TABLE `tareas`
ADD CONSTRAINT `tareas_equipo_id_foreign` FOREIGN KEY (`equipo_id`) REFERENCES `equipos` (`id`),
ADD CONSTRAINT `tareas_trabajadores_id_foreign` FOREIGN KEY (`trabajadores_id`) REFERENCES `trabajadores` (`id`);
--
-- Filtros para la tabla `trabajadores`
--
ALTER TABLE `trabajadores`
ADD CONSTRAINT `trabajadores_departamento_id_foreign` FOREIGN KEY (`departamento_id`) REFERENCES `departamentos` (`id`),
ADD CONSTRAINT `trabajadores_equipos_id_foreign` FOREIGN KEY (`equipos_id`) REFERENCES `equipos` (`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 */;
|
--numCheckins = sum of all check-ins for that business
update business
set numCheckins = temp2.numCheckins
from (select business_id, sum(tempSum) as numCheckins
from (select business_id, (night + evening + afternoon + morning) as tempSum
from checkin) as temp
group by business_id) as temp2
where business.business_id = temp2.business_id;
--review_count = number of reviews provided for the business (overwrite the values extracted from the JSON data)
update business
set review_count = temp.tempCount
from (select business_id, count(review_id) as tempCount
from review
group by business_id) as temp
where business.business_id = temp.business_id;
--review_rating = average of the review star ratings provided for each business
update business
set review_rating = temp.tempRating
from (select business_id, avg(stars) as tempRating
from review
group by business_id) as temp
where business.business_id = temp.business_id; |
DECLARE
e_date EXCEPTION;
PRAGMA EXCEPTION_INIT(e_date, -1858);
v_date DATE;
BEGIN
SELECT TO_DATE( '13-DEC-2004 6:56 PM', 'DD-MON-YYYY HH:MI:SS') INTO v_date FROM dual;
EXCEPTION
WHEN e_date THEN
PRC_LOG_ERROR( 'error', SQLCODE, SQLERRM, 'anonymous block');
DBMS_OUTPUT.PUT_LINE('Exceptia pentru data a fost prinsa');
END;
/ |
create or replace FUNCTION NombreModalidadProfesor(Profesor IN Profesores.OID_P%TYPE)
RETURN VARCHAR2 IS modalidad modalidades.NOMBRE%type;
BEGIN
SELECT NOMBRE INTO modalidad FROM profesores, MODALIDADES
WHERE (Profesores.OID_P=Profesor AND PROFESORES.OID_M=MODALIDADES.OID_M);
RETURN(modalidad);
END; |
with t as
(
select
project,
percentile_cont(array[0.5, 0.9, 0.95, 0.99]) within group (order by cts-ats) as pers
from commitlog
where ats <> cts
group by project
)
select
project,
pers[1] as median,
pers[2] as "90%th",
pers[3] as "95%th",
pers[4] as "99%th"
from t
;
|
-- DELETE DATA t_resume_career TABLE
DELETE RC.* FROM t_resume_career RC
WHERE RC.T_RESUME_ID NOT IN (SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume_industry TABLE
DELETE RI.* FROM t_resume_industry RI
WHERE RI.T_RESUME_ID NOT IN ( SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume_school TABLE
DELETE RS.* FROM t_resume_school RS
WHERE RS.T_RESUME_ID NOT IN ( SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume_skill TABLE
DELETE RK.* FROM t_resume_skill RK
WHERE RK.T_RESUME_ID NOT IN ( SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume_type_position TABLE
DELETE RT.* FROM t_resume_type_position RT
WHERE RT.T_RESUME_ID NOT IN ( SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume_type_position TABLE
DELETE RW.* FROM t_resume_workplace RW
WHERE RW.T_RESUME_ID NOT IN ( SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume_license TABLE
DELETE RL.* FROM t_resume_license RL
WHERE RL.T_RESUME_ID NOT IN ( SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume_language_level TABLE
DELETE RL.* FROM t_resume_language_level RL
WHERE RL.T_RESUME_ID NOT IN ( SELECT R.ID FROM T_RESUME R
LEFT JOIN m_candidate CAN ON R.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- DELETE DATA t_resume TABLE
DELETE R1.* FROM T_RESUME R1
LEFT JOIN m_candidate CAN ON R1.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` NOT LIKE 'CSG%';
-- DELETE DATA t_matching_step TABLE
DELETE TS.* FROM t_matching_step TS
WHERE TS.`CODE` NOT IN (SELECT T.`CODE` FROM t_matching T
LEFT JOIN m_candidate CAN ON T.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- delete DATA T_MATCHING TABLE
DELETE T.* FROM t_matching T
LEFT JOIN m_candidate CAN ON T.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` NOT LIKE 'CSG%';
-- DELETE DATA t_matching_finalize_step TABLE
DELETE TSF.* FROM t_matching_step_finalize TSF
WHERE TSF.`CODE` NOT IN (SELECT TF.`CODE` FROM t_matching_finalize TF
LEFT JOIN m_candidate CAN ON TF.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` LIKE 'CSG%');
-- delete DATA T_MATCHING TABLE
DELETE TF.* FROM t_matching_finalize TF
LEFT JOIN m_candidate CAN ON TF.M_CANDIDATE_ID = CAN.ID
WHERE CAN.`CODE` NOT LIKE 'CSG%';
-- DELETE DATA t_job_workplace TABLE
DELETE JW.* FROM t_job_workplace JW
LEFT JOIN t_job J ON J.ID = JW.T_JOB_ID
WHERE J.`CODE` NOT LIKE 'JSG%'
-- DELETE DATA t_job_target_office TABLE
DELETE JT.* FROM t_job_target_office JT
LEFT JOIN t_job J ON J.ID = JT.T_JOB_ID
WHERE J.`CODE` NOT LIKE 'JSG%'
-- DELETE DATA t_job_skill TABLE
DELETE JK.* FROM t_job_skill JK
LEFT JOIN t_job J ON J.ID = JK.T_JOB_ID
WHERE J.`CODE` NOT LIKE 'JSG%'
-- DELETE DATA t_job_license TABLE
DELETE JL.* FROM t_job_license JL
LEFT JOIN t_job J ON J.ID = JL.T_JOB_ID
WHERE J.`CODE` NOT LIKE 'JSG%'
-- DELETE DATA t_job_language_level TABLE
DELETE JL.* FROM t_job_language_level JL
LEFT JOIN t_job J ON J.ID = JL.T_JOB_ID
WHERE J.`CODE` NOT LIKE 'JSG%'
-- DELETE DATA t_job_nationality TABLE
DELETE JN.* FROM t_job_nationality JN
LEFT JOIN t_job J ON J.ID = JN.T_JOB_ID
WHERE J.`CODE` NOT LIKE 'JSG%'
-- t_dealing_history TABLE
DELETE D.* FROM t_dealing_history D
LEFT JOIN m_candidate CAN ON D.M_USER_ID = CAN.ID
WHERE D.TYPE = 1 AND CAN.`CODE` NOT LIKE 'CS%';
DELETE D.* FROM t_dealing_history D
LEFT JOIN m_company COM ON D.M_USER_ID = COM.ID
WHERE D.TYPE = 2 AND COM.`CODE` NOT LIKE 'KSG%';
-- DELETE DATA t_job TABLE
DELETE FROM t_job
WHERE CODE NOT LIKE 'JSG%';
-- DELETE DATA m_candidate
DELETE FROM m_candidate
WHERE CODE NOT LIKE 'CS%';
-- DELETE m_company_client TABLE
DELETE CL.* FROM m_company_client CL
LEFT JOIN m_company COM ON COM.ID = CL.M_COMPANY_ID
WHERE COM.`CODE` NOT LIKE 'KSG%';
-- DELETE m_company_contract TABLE
DELETE CT.* FROM m_company_contract CT
LEFT JOIN m_company COM ON COM.ID = CT.M_COMPANY_ID
WHERE COM.`CODE` NOT LIKE 'KSG%';
-- DELETE m_company_industry TABLE
DELETE CI.* FROM m_company_industry CI
LEFT JOIN m_company COM ON COM.ID = CI.M_COMPANY_ID
WHERE COM.`CODE` not LIKE 'KSG%';
-- DELETE t_file TABLE
DELETE FROM t_file;
DELETE FROM t_file_string;
DELETE FROM t_payment;
DELETE FROM t_payment_detail;
DELETE FROM t_journal;
DELETE FROM t_journal_detail;
DELETE FROM t_sales;
DELETE FROM t_sales_detail;
DELETE FROM t_sales_slip;
DELETE FROM t_sales_slip_detail;
DELETE FROM t_sales_slip_file;
DELETE FROM t_updating_history;
DELETE FROM t_updating_history_detail;
|
INSERT INTO core_erp_l_category_apomiosi(myid,title,mykatastima) VALUES
(1,'ΛΗΓΜΕΝΑ','krestena'),
(2,'ΛΑΘΟΣ STOCK (ΦΡΕΣΚΑ)','krestena'),
(3,'ΦΥΡΑ','krestena'),
(4,'ΚΑΤΕΣΤΡΑΜΕΝΑ (ΚΑΤΑ ΤΗ ΠΑΡΑΛΑΒΗ)','krestena'),
(5,'ΚΑΤΕΣΤΡΑΜΕΝΑ ΚΛΕΜΕΝΑ ΑΠΟ ΠΕΛΑΤΕΣ','krestena'),
(6,'ΕΝΤΟΛΗ ΔΙΕΥΘΗΝΣΗΣ ΑΓΟΡΩΝ','krestena'),
(7,'ΒΛΑΒΗ ΨΥΓΕΙΟΥ','krestena'),
(8,'ΛΟΓΩ ΦΥΣΙΚΩΝ ΚΑΤΑΣΤΡΟΦΩΝ','krestena'),
(9,'ΔΙΑΤΡΟΦΙΚΗ ΚΡΙΣΗ','krestena'),
(10,'ΚΟΝΤΟΛΗΞΗΜΑ ΔΩΡΕΑ','krestena'),
(11,'ΕΣΩΤΕΡΙΚΗ ΔΙΑΚΙΝΗΣΗ','krestena'),
(12,'ΑΔΙΕΥΚΡΙΝΙΣΤΟ (ΚΛΟΠΗ)','krestena'),
(13,'ΦΙΛΑΝΘΡΩΠΙΑ','krestena'); |
-- 16. Выберите самый широко используемый ингредиент. Ингредиент будем считать самым широко используемым, если его
-- включает большее число блюд. Выбрать нужно только название ингредиента.
SELECT alternative_name FROM (
SELECT ingredients_list.dishes_id, ingredients_list.ingr_id, alternative_name FROM ingredients_list RIGHT JOIN ingredients ON `ingredients_list`.`ingr_id` = `ingredients`.`ingr_id`
) AS T
GROUP BY `ingr_id`,`alternative_name` ORDER BY COUNT(`ingr_id`) DESC LIMIT 1 ;
-- Тут я сделал так чтобы получались все имена широкоиспользуеммых ингредиентов
CREATE TABLE TEMP
( name text(255) not null,
counts int(11) not Null);
INSERT INTO TEMP
SELECT alternative_name, COUNT(alternative_name)
FROM ingredients_list
RIGHT JOIN ingredients
ON `ingredients_list`.`ingr_id` = `ingredients`.`ingr_id`
GROUP BY alternative_name ;
SELECT name FROM TEMP WHERE counts = (SELECT MAX(counts) FROM TEMP);
DROP TABLE TEMP;
|
SPOOL C:\Nur_Suhaira_5841549_A2\solution6Output;
/* ==============================================
Student Name: Nur Suhaira
Student Number: 5841549
Description: Assignment 2 Task 6
Date written: 10th May 2018
================================================
======================Qn 6=====================*/
-- Lists the names and the sizes (in KBytes) of the data objects
-- (relational tables, indexes, etc) created and owned by you.
-- The script should produce the following output.
-- Object Names Size in KB
--------------------------- ----------------
-- ALLMAC 64
-- SERVES 64
-- ...
SELECT SEGMENT_NAME AS OBJECT_NAMES, SUM(BLOCKS * 8 *1024) AS SIZE_IN_KB
FROM USER_SEGMENTS
GROUP BY SEGMENT_NAME;
SPOOL OFF;
--================END OF Qn 6================== |
SELECT CONCEPT_CD, COUNT (*) FROM
(SELECT CONCEPT_CD FROM OBSERVATION_FACT
WHERE (CONCEPT_CD LIKE 'DEM|RACE%' OR CONCEPT_CD LIKE 'DEM|AGE%' OR CONCEPT_CD LIKE 'DEM|RELIGION%' OR CONCEPT_CD LIKE 'DEM|LANGUAGE%' OR CONCEPT_CD LIKE 'DEM|SEX%') AND PATIENT_NUM IN (SELECT DISTINCT(PATIENT_NUM)
FROM OBSERVATION_FACT
WHERE CONCEPT_CD LIKE '%LOINC:1920-8%')) A GROUP BY concept_cd ORDER BY 1;
SELECT ENCOUNTER_NUM, PATIENT_NUM, CONCEPT_CD FROM OBSERVATION_FACT WHERE /*CONCEPT_CD LIKE '%LOINC:1920-8%' AND*/ PATIENT_NUM=1000000016 AND /*ENCOUNTER_NUM=471794 AND*/ (CONCEPT_CD LIKE 'DEM|RACE%' OR CONCEPT_CD LIKE 'DEM|AGE%' OR CONCEPT_CD LIKE 'DEM|RELIGION%' OR CONCEPT_CD LIKE 'DEM|LANGUAGE%' OR CONCEPT_CD LIKE 'DEM|SEX%');
SELECT OB.PATIENT_NUM,
(SELECT OB2.CONCEPT_CD FROM OBSERVATION_FACT
FROM OBSERVATION_FACT OB WHERE OB.CONCEPT_CD LIKE '%LOINC:1920-8%'
SELECT SUBSTRING(CONCEPT_CD, 9) AS SEX, COUNT(*) FROM OBSERVATION_FACT WHERE CONCEPT_CD LIKE 'DEM|SEX%' AND PATIENT_NUM IN (SELECT DISTINCT(PATIENT_NUM)
FROM OBSERVATION_FACT
WHERE CONCEPT_CD LIKE '%LOINC:1920-8%')
GROUP BY CONCEPT_CD;
|
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Sep 25, 2020 at 05:11 AM
-- Server version: 5.7.26
-- PHP Version: 7.2.18
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: `medical`
--
-- --------------------------------------------------------
--
-- Table structure for table `departments`
--
DROP TABLE IF EXISTS `departments`;
CREATE TABLE IF NOT EXISTS `departments` (
`dept_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`status` char(1) NOT NULL,
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`dept_id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `departments`
--
INSERT INTO `departments` (`dept_id`, `name`, `status`, `date_created`) VALUES
(2, 'Admin', '1', '2020-05-13 20:21:09'),
(3, 'Security', '1', '2020-05-13 20:21:20'),
(5, 'Doctors', '1', '2020-05-13 20:21:51'),
(6, 'Pharmacy', '1', '2020-05-13 20:22:10'),
(7, 'Stock', '1', '2020-05-13 20:22:19'),
(8, 'Cleaning', '1', '2020-05-13 21:27:26'),
(9, 'Receptionist', '1', '2020-05-13 21:28:21'),
(10, 'Electrical', '1', '2020-05-16 06:15:05'),
(11, 'ICT', '1', '2020-05-16 07:48:42'),
(12, 'Planning', '0', '2020-09-16 12:18:31'),
(13, 'Research', '0', '2020-09-16 12:19:13'),
(14, 'Sports', '0', '2020-09-21 11:33:36');
-- --------------------------------------------------------
--
-- Table structure for table `doctors`
--
DROP TABLE IF EXISTS `doctors`;
CREATE TABLE IF NOT EXISTS `doctors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`username` varchar(25) NOT NULL,
`password` varchar(255) DEFAULT NULL,
`email` varchar(50) NOT NULL,
`phone` text NOT NULL,
`address` varchar(40) NOT NULL,
`category_id` int(11) DEFAULT NULL,
`status` int(1) NOT NULL,
`pic` varchar(255) NOT NULL,
`addedby` int(11) NOT NULL,
`date_of_birth` varchar(20) NOT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`),
KEY `foreign key to doc_category table` (`category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `doctors`
--
INSERT INTO `doctors` (`id`, `name`, `username`, `password`, `email`, `phone`, `address`, `category_id`, `status`, `pic`, `addedby`, `date_of_birth`, `date_added`) VALUES
(3, 'Kintu Fahad', 'fahad', '', 'fahad@gmail.com', '0700968574', 'kyanja, kampala', 2, 1, '_20170519_184430HJ.jpg', 2, '1990-12-31', '2020-05-16 07:43:16'),
(4, 'Abaliwano Francis', 'francis', '', 'francis@gmail.com', '0700968574', 'Jinja', 4, 1, '_20170519_1844304TJGW.jpg', 2, '1992-12-06', '2020-05-16 07:44:10'),
(6, 'Nambi Janet', 'jenet', '', 'jenet@gmail.com', '256778968511', 'Makerere', 1, 1, '1.jpg', 2, '1999-01-01', '2020-05-16 09:51:56'),
(7, 'Namberoy Asina', 'asina', '', 'asina123@gmail.com', '256778968511', 'Banda', 5, 1, '4.jpg', 2, '2000-12-20', '2020-05-16 09:54:22'),
(8, 'Ashley Williams', 'willl', NULL, 'asio@gmail.com', '0778101574', 'Gayaza', 3, 1, '234.jpg', 2, '2020-09-02', '2020-09-16 12:17:54'),
(10, 'Ann Taylor', 'ann', NULL, 'ann@gmail.com', '0778223443', 'Gayaza', 5, 0, 'www.jpg', 2, '2020-09-20', '2020-09-24 12:48:51');
-- --------------------------------------------------------
--
-- Table structure for table `doc_category`
--
DROP TABLE IF EXISTS `doc_category`;
CREATE TABLE IF NOT EXISTS `doc_category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`added_by` int(11) NOT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `doc_category_ibfk_1` (`added_by`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `doc_category`
--
INSERT INTO `doc_category` (`id`, `name`, `added_by`, `date_added`) VALUES
(1, 'Nurse', 1, '2020-05-13 20:51:05'),
(2, 'Optician', 1, '2020-05-13 20:51:27'),
(3, 'Dentist', 1, '2020-05-13 20:51:42'),
(4, 'Surgion', 1, '2020-05-13 20:52:00'),
(5, 'Midwife', 1, '2020-05-13 20:52:25');
-- --------------------------------------------------------
--
-- Table structure for table `messages`
--
DROP TABLE IF EXISTS `messages`;
CREATE TABLE IF NOT EXISTS `messages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`body` varchar(255) NOT NULL,
`sender` int(11) NOT NULL,
`receiver` int(11) NOT NULL,
`date_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `messages`
--
INSERT INTO `messages` (`id`, `body`, `sender`, `receiver`, `date_time`, `status`) VALUES
(1, 'Hello', 2, 1, '2020-05-19 13:39:58', 0),
(2, 'How are you', 2, 2, '2020-05-19 13:40:43', 1),
(3, 'I wanted to see yuo todeay', 1, 1, '2020-05-20 19:47:27', 1),
(5, 'How are you doing sir', 1, 2, '2020-05-21 09:16:27', 1);
-- --------------------------------------------------------
--
-- Table structure for table `patients`
--
DROP TABLE IF EXISTS `patients`;
CREATE TABLE IF NOT EXISTS `patients` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`address` varchar(100) DEFAULT NULL,
`contact` varchar(12) DEFAULT NULL,
`weight` int(11) DEFAULT NULL,
`date_of_birth` varchar(20) DEFAULT NULL,
`gander` text NOT NULL,
`next_of_kin` varchar(50) DEFAULT NULL,
`next_of_kin_contact` varchar(12) DEFAULT NULL,
`doc_id` int(11) DEFAULT NULL,
`status` int(1) DEFAULT NULL,
`status1` int(1) DEFAULT NULL,
`symptoms` varchar(255) DEFAULT NULL,
`medication` varchar(255) DEFAULT NULL,
`addedby` int(11) DEFAULT NULL,
`date_added` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`discharged` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `doc_id` (`doc_id`),
KEY `addedby` (`addedby`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `patients`
--
INSERT INTO `patients` (`id`, `name`, `address`, `contact`, `weight`, `date_of_birth`, `gander`, `next_of_kin`, `next_of_kin_contact`, `doc_id`, `status`, `status1`, `symptoms`, `medication`, `addedby`, `date_added`, `discharged`) VALUES
(4, 'Kalenzi Fahad', 'Jinja', '07777777709', 78, '24/06/1998', 'M', 'Samuel Davis', '0778995566', 7, 1, 1, 'Wound, flue', '', 2, '2020-05-17 14:00:41', ''),
(5, 'Nambi Johnson', 'Banda', '0774590323', 80, '18/10/1989', 'F', 'Samuel Davis', '0778431009', 7, 0, 1, 'Cougg, Fever', 'Panadol, ARVs, Headex', 2, '2020-05-17 14:02:28', ''),
(6, 'Ashley Williams', 'Gayaza', '07777777777', 90, '16/09/2020', 'M', 'Sam Daniel', '0778995008', 6, 1, 1, 'death', NULL, 2, '2020-09-16 15:12:10', NULL),
(7, 'Smith Smith', 'Kabale', '07777777777', 59, '21/02/2017', 'M', 'Sam Daniel', '0778995017', 6, 0, 0, 'Hunger, Stress', 'Food', 2, '2020-09-23 18:10:46', '23/09/2020');
-- --------------------------------------------------------
--
-- Table structure for table `staffroles`
--
DROP TABLE IF EXISTS `staffroles`;
CREATE TABLE IF NOT EXISTS `staffroles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`AddedBy` int(11) DEFAULT NULL,
`Addedon` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `staffroles`
--
INSERT INTO `staffroles` (`id`, `name`, `description`, `AddedBy`, `Addedon`) VALUES
(1, 'Head of Department', 'Leading a Department', 2, '2020-09-24 12:39:49'),
(3, 'Supervisor', 'Inspecting work done', 2, '2020-09-24 12:47:12'),
(4, 'News Reporter', 'Making sure news reach staff members', 1, '2020-09-24 14:37:53'),
(5, 'Orientation', 'Showing new workers places', 2, '2020-09-24 14:47:56');
-- --------------------------------------------------------
--
-- Table structure for table `sys_users`
--
DROP TABLE IF EXISTS `sys_users`;
CREATE TABLE IF NOT EXISTS `sys_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(25) DEFAULT NULL,
`role` int(11) NOT NULL,
`email` varchar(100) DEFAULT NULL,
`phone` varchar(12) DEFAULT NULL,
`address` varchar(100) NOT NULL,
`username` varchar(50) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`pic` varchar(255) NOT NULL,
`status` int(1) NOT NULL,
`addedby` int(11) NOT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `username` (`username`),
KEY `role` (`role`),
KEY `addedby` (`addedby`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `sys_users`
--
INSERT INTO `sys_users` (`id`, `name`, `role`, `email`, `phone`, `address`, `username`, `password`, `pic`, `status`, `addedby`, `date_added`) VALUES
(1, 'Abaliwano Francis', 2, 'francis@gmail.com', '0778968574', 'kyanja, kampala', 'francis', 'francis', '_20170519_184430.JPG', 1, 2, '2020-05-13 20:25:50'),
(2, 'Gabula Pius', 3, 'pius@gmail.com', '0778968090', 'Gayaza', 'pius', 'pius', '234.jpg', 1, 2, '2020-05-16 07:48:01');
-- --------------------------------------------------------
--
-- Table structure for table `t_stock`
--
DROP TABLE IF EXISTS `t_stock`;
CREATE TABLE IF NOT EXISTS `t_stock` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL,
`unit_price` int(11) DEFAULT NULL,
`total_price` int(11) DEFAULT NULL,
`supplier_name` varchar(50) NOT NULL,
`supplier_contact` varchar(12) NOT NULL,
`exp_date` varchar(20) NOT NULL,
`unit_id` int(11) DEFAULT NULL,
`user_id` int(11) NOT NULL,
`date_added` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `t_stock`
--
INSERT INTO `t_stock` (`id`, `name`, `quantity`, `unit_price`, `total_price`, `supplier_name`, `supplier_contact`, `exp_date`, `unit_id`, `user_id`, `date_added`) VALUES
(3, 'Gloves', 4, 40000, 160000, 'Quram Plus', '256778968511', '2029-12-08', 1, 2, '2020-05-21 11:16:47'),
(4, 'Panadol', 1, 20000, 20000, 'Menthyl ', '256778968500', '2023-12-06', 1, 2, '2020-05-21 12:57:22'),
(5, 'Coatem', 100, 2500, 250000, 'Menthyl', '256778968500', '2023-02-12', 3, 2, '2020-05-21 13:00:02'),
(6, 'Cotton', 3, 10000, 30000, 'Quram', '256778968511', '2024-11-24', 1, 2, '2020-05-21 13:02:48'),
(7, 'Syring', 100, 1500, 150000, 'Menthyl', '256778968500', '2028-07-25', 4, 2, '2020-05-21 13:08:49'),
(8, 'Headex', 20, 3500, 70000, 'Cyprus', '256700968574', '2022-09-19', 3, 2, '2020-05-21 13:11:11');
-- --------------------------------------------------------
--
-- Table structure for table `units`
--
DROP TABLE IF EXISTS `units`;
CREATE TABLE IF NOT EXISTS `units` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`symbol` varchar(10) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`date_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `symol` (`symbol`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `units`
--
INSERT INTO `units` (`id`, `name`, `symbol`, `user_id`, `date_time`) VALUES
(1, 'Boxes', 'boxes', 1, '2020-05-21 10:06:43'),
(2, 'Tablets', 'tabs', 1, '2020-05-21 10:09:34'),
(3, 'Packets', 'pkts', 1, '2020-05-21 10:09:57'),
(4, 'Pieces', 'pieces', 1, '2020-05-21 13:07:42');
-- --------------------------------------------------------
--
-- Table structure for table `workers`
--
DROP TABLE IF EXISTS `workers`;
CREATE TABLE IF NOT EXISTS `workers` (
`w_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`phone` text,
`address` varchar(100) DEFAULT NULL,
`dept` int(11) DEFAULT NULL,
`salary` int(50) DEFAULT NULL,
`status` int(1) DEFAULT NULL,
`pic` varchar(255) DEFAULT NULL,
`addedby` int(11) DEFAULT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`w_id`),
KEY `addedby` (`addedby`),
KEY `dept` (`dept`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `workers`
--
INSERT INTO `workers` (`w_id`, `name`, `email`, `phone`, `address`, `dept`, `salary`, `status`, `pic`, `addedby`, `date_added`) VALUES
(3, 'Kalenzi Fahad', 'fahad@gmail.com', '0774567584', 'Luwero', 8, 788766, 0, 'ken.jpg', 15, '2020-09-19 05:33:49'),
(4, 'Asinde Jenet', 'asio@gmail.com', '0774563456', 'Banda', 8, 346673, 1, '1.jpg', 15, '2020-09-19 06:13:55'),
(5, 'Andy Synoid', 'synoid@gmail.com', '0774567584', 'Jinja', 8, 776665, 1, '98f72f43-1c69-4a5a-93e8-afee47f76461.jpg', 15, '2020-09-24 09:17:31'),
(6, 'Ezekiel Ben', 'ben@gmail.com', '0774563456', 'Luwero', 8, 346673, 0, '262671e7-cb17-4ee1-8f5a-26f766c4a855.jpg', 15, '2020-09-24 12:37:57'),
(7, 'Ande Johnson', 'ande@gmail.com', '0774567584', 'Banda', 8, 388945, 1, 'c09d71f9-fb9d-4fe3-aa4c-9e6b2b1cd549.jpg', 15, '2020-09-24 12:40:50'),
(8, 'Ashley Williams', 'williams@gmail.com', '0774567584', 'Kyanja', 8, 399000, 1, 'a93e4d16-d77c-4db8-87e5-39fd24bd7704.jpg', 15, '2020-09-24 13:20:19'),
(9, 'Daniel Johnson', 'dan@gmail.com', '0774567584', 'Kyanja', 11, 575777, 1, '8e5a959f-4e0a-48db-ab65-33bfa63dd61d.jpg', 2, '2020-09-24 13:27:10'),
(10, 'Dickson Mike', 'mike@gmail.com', '0774567584', 'Gayaza', 12, 788766, 1, '9e7399ba-e434-422c-a7b9-53411c64ef03.jpg', 2, '2020-09-24 13:28:00');
-- --------------------------------------------------------
--
-- Table structure for table `wstaffroles`
--
DROP TABLE IF EXISTS `wstaffroles`;
CREATE TABLE IF NOT EXISTS `wstaffroles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`w_id` int(11) DEFAULT NULL,
`RoleID` int(11) DEFAULT NULL,
`deptID` int(11) DEFAULT NULL,
`AddedOn` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `wstaffroles`
--
INSERT INTO `wstaffroles` (`id`, `w_id`, `RoleID`, `deptID`, `AddedOn`) VALUES
(1, 5, 1, NULL, '2020-09-24 15:34:11'),
(2, 4, 3, NULL, '2020-09-24 15:35:04');
--
-- Constraints for dumped tables
--
--
-- Constraints for table `doctors`
--
ALTER TABLE `doctors`
ADD CONSTRAINT `foreign key to doc_category table` FOREIGN KEY (`category_id`) REFERENCES `doc_category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `doc_category`
--
ALTER TABLE `doc_category`
ADD CONSTRAINT `doc_category_ibfk_1` FOREIGN KEY (`added_by`) REFERENCES `sys_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `sys_users`
--
ALTER TABLE `sys_users`
ADD CONSTRAINT `foreign key to department table` FOREIGN KEY (`role`) REFERENCES `departments` (`dept_id`) ON DELETE CASCADE ON UPDATE CASCADE;
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 */;
|
-- phpMyAdmin SQL Dump
-- version 4.9.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Sep 28, 2020 at 10:32 AM
-- Server version: 8.0.18
-- PHP Version: 7.3.12
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: `abcd`
--
-- --------------------------------------------------------
--
-- Table structure for table `customer`
--
DROP TABLE IF EXISTS `customer`;
CREATE TABLE IF NOT EXISTS `customer` (
`CustID` int(11) NOT NULL AUTO_INCREMENT,
`UserID` int(11) NOT NULL,
`CustFname` varchar(255) NOT NULL,
`CustLname` varchar(255) NOT NULL,
`Country` varchar(255) NOT NULL,
`Address` varchar(255) NOT NULL,
`Phone` varchar(255) NOT NULL,
`profilebic` varchar(255) DEFAULT NULL,
PRIMARY KEY (`CustID`),
KEY `UserID` (`UserID`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `customer`
--
INSERT INTO `customer` (`CustID`, `UserID`, `CustFname`, `CustLname`, `Country`, `Address`, `Phone`, `profilebic`) VALUES
(24, 27, 'jet', 'Jun', 'Malaysia', 'No', '0102062626', NULL),
(38, 41, 'Wong', 'Tai bei', 'Bahamas', 'No house also', '0102662020', NULL),
(39, 42, 'Wang', 'Yao Seng', 'America', 'Got house but lost his keys', '101022933', NULL);
-- --------------------------------------------------------
--
-- Table structure for table `payment`
--
DROP TABLE IF EXISTS `payment`;
CREATE TABLE IF NOT EXISTS `payment` (
`ReceiptID` int(11) NOT NULL AUTO_INCREMENT,
`ReserveID` int(11) NOT NULL,
PRIMARY KEY (`ReceiptID`),
KEY `ReserveID` (`ReserveID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- --------------------------------------------------------
--
-- Table structure for table `registered_user`
--
DROP TABLE IF EXISTS `registered_user`;
CREATE TABLE IF NOT EXISTS `registered_user` (
`UserID` int(11) NOT NULL AUTO_INCREMENT,
`Username` varchar(255) NOT NULL,
`Password` varchar(255) NOT NULL,
`Email` varchar(255) NOT NULL,
`RoleID` int(11) NOT NULL,
PRIMARY KEY (`UserID`),
KEY `RoleID` (`RoleID`)
) ENGINE=InnoDB AUTO_INCREMENT=62 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `registered_user`
--
INSERT INTO `registered_user` (`UserID`, `Username`, `Password`, `Email`, `RoleID`) VALUES
(27, 'a', '$2y$10$6ObcEu/f7EMT/Qqhe6Y5Ze.CvT7JXt73nJbW0iJtgUpzF4XW0TtSa', 'a@mail.com', 3),
(32, 's', '$2y$10$CZK4olHyZu22C5Ur2FB61.z/HNJEe7ngQaCt6WXNpbg4RbI.IkigO', 's@mail.com', 2),
(41, 'b', '$2y$10$msdtlccdb9fKVd7IbDvJ7eQkiK0vrFcxBZPVIuQn2XQs7X6QNReJC', 'b@mail.com', 3),
(42, 'c', '$2y$10$XLaKneFlHw3YUupVhFAzo.LiwJW/pnVHr.ZpBvPUreg6dvxi7fqn2', 'c@mail.com', 3),
(44, 'admin', '$2y$10$ML96wRiZwrRCr3nAnyYVNuKdwbXT0AZXd803yKSGJbw55k51F6i0C', 'admin@mail.com', 1),
(59, 'v', '$2y$10$HjgqMWg.bSTHsaCSgg58DOPbXvHyDb6I6zEhD2iTJtymkaWlwqVDa', 'v@gmail.com', 3),
(60, 'd', '$2y$10$rIPRVBi.hA9ZVT/lMc2IbOyx2PLcrRmsZgR7DY5Ifx/nNRg/KVsRu', 'd@mail.com', 3),
(61, 'e', '$2y$10$tAuePwuGwEE9nWjAJBACcedDBjTycrOTxjaY.KGADtj28SUY.7Ile', 'e@email.com', 3);
-- --------------------------------------------------------
--
-- Table structure for table `reservation`
--
DROP TABLE IF EXISTS `reservation`;
CREATE TABLE IF NOT EXISTS `reservation` (
`ReserveID` int(11) NOT NULL AUTO_INCREMENT,
`RoomID` int(11) DEFAULT NULL,
`CustID` int(11) DEFAULT NULL,
`CheckInDate` date NOT NULL,
`CheckOutDate` date NOT NULL,
`Payment_Status` varchar(255) NOT NULL,
PRIMARY KEY (`ReserveID`),
KEY `RoomID` (`RoomID`),
KEY `CustID` (`CustID`)
) ENGINE=InnoDB AUTO_INCREMENT=131 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- --------------------------------------------------------
--
-- Table structure for table `role_name`
--
DROP TABLE IF EXISTS `role_name`;
CREATE TABLE IF NOT EXISTS `role_name` (
`RoleID` int(11) NOT NULL AUTO_INCREMENT,
`RoleName` varchar(255) NOT NULL,
PRIMARY KEY (`RoleID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `role_name`
--
INSERT INTO `role_name` (`RoleID`, `RoleName`) VALUES
(1, 'Admin'),
(2, 'Staff'),
(3, 'Customer');
-- --------------------------------------------------------
--
-- Table structure for table `room`
--
DROP TABLE IF EXISTS `room`;
CREATE TABLE IF NOT EXISTS `room` (
`RoomID` int(11) NOT NULL AUTO_INCREMENT,
`RoomType` varchar(255) NOT NULL,
`PricePerNight` int(255) NOT NULL,
PRIMARY KEY (`RoomID`)
) ENGINE=InnoDB AUTO_INCREMENT=23123126 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `room`
--
INSERT INTO `room` (`RoomID`, `RoomType`, `PricePerNight`) VALUES
(1, 'Family', 100),
(2, 'Deluxe', 100),
(8, 'Premier', 1),
(9, 'Superior', 1),
(10, 'Twin', 1),
(23123125, 'Luxury', 1);
-- --------------------------------------------------------
--
-- Table structure for table `staff`
--
DROP TABLE IF EXISTS `staff`;
CREATE TABLE IF NOT EXISTS `staff` (
`StaffID` int(11) NOT NULL AUTO_INCREMENT,
`UserID` int(11) NOT NULL,
`StaffFname` varchar(255) NOT NULL,
`StaffLname` varchar(255) NOT NULL,
PRIMARY KEY (`StaffID`),
KEY `UserID` (`UserID`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `staff`
--
INSERT INTO `staff` (`StaffID`, `UserID`, `StaffFname`, `StaffLname`) VALUES
(1, 32, 'Gary moder first name', 'Gary sister last name'),
(13, 44, 'May', 'December'),
(14, 44, 'Buttercup', 'Earthbound');
--
-- Constraints for dumped tables
--
--
-- Constraints for table `customer`
--
ALTER TABLE `customer`
ADD CONSTRAINT `customer_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `registered_user` (`UserID`);
--
-- Constraints for table `payment`
--
ALTER TABLE `payment`
ADD CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`ReserveID`) REFERENCES `reservation` (`ReserveID`);
--
-- Constraints for table `registered_user`
--
ALTER TABLE `registered_user`
ADD CONSTRAINT `registered_user_ibfk_1` FOREIGN KEY (`RoleID`) REFERENCES `role_name` (`RoleID`);
--
-- Constraints for table `reservation`
--
ALTER TABLE `reservation`
ADD CONSTRAINT `reservation_ibfk_1` FOREIGN KEY (`CustID`) REFERENCES `customer` (`CustID`),
ADD CONSTRAINT `reservation_ibfk_2` FOREIGN KEY (`RoomID`) REFERENCES `room` (`RoomID`);
--
-- Constraints for table `staff`
--
ALTER TABLE `staff`
ADD CONSTRAINT `staff_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `registered_user` (`UserID`);
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 */;
|
UPDATE raw_property SET sqft = REPLACE(sqft, ',', '');
UPDATE raw_property SET hlfbath = 0 WHERE hlfbath IS NULL;
DELETE FROM raw_property WHERE lati IS NULL;
DELETE FROM raw_property WHERE longi IS NULL;
DELETE FROM raw_property WHERE bath IS NULL;
DELETE FROM raW_property WHERE sqft = '';
INSERT INTO property (type, bedrooms, bathrooms, garage, square_feet, price, latitude, longitude)
SELECT type, bed, bath*1.0+(hlfbath*0.5), 0, CAST(sqft as FLOAT), price, lati, longi FROM raw_property; |
--将用户按照创建订单时间降序排序,获取用户最早的下单时间,并且位于2017年10月1日至11月30日之间
use bnb_hive_db;
drop table if exists tmp_zc_uid_createdtime;
create table tmp_zc_uid_createdtime as
select uid,orderid,createdtime from
(select uid,orderid,row_number() over(partition by uid order by createdtime) as createdtime
from ods_htl_bnborderdb.order_header_v2
where d = '2018-06-20'
and row_number() over(partition by uid order by createdtime) = 1) a
where substr(createdtime,1,8) >= '2017-10-01'
and createdtime <= '2018-11-30'
--计算首单用户在下单时及接下来半年内的累积消费
select sum(b.payamount)/count(distinct a.uid) from
(select uid,orderid,createdtime from bnb_hive_db.tmp_zc_uid_createdtime) a
join (select orderid,payamount from ods_htl_bnborderdb.order_pay
where reverseflag = 1
and payamounttype = 1
and paychannel = 10
and statusid = 12
and substr(createdtime,1,10) >= '2017-10-01'
and substr(createdtime,1,10) <= '2018-05-31'
and d = '2018-06-20') b
on a.orderid = b.orderid
|
-- 06-13-2010 05:36:04 PM CST
-- queuing time_explanation
UPDATE AD_Field SET Description='Queue time is the time a ob waits at a work center before begin handled.', Help='Queuing time has no implication on costs, but on Capacity Requirement Planning (CRP) to calculate the total time needed to manufacture a product.',Updated=TO_TIMESTAMP('2010-06-13 17:36:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=53405
;
-- 06-13-2010 05:45:24 PM CST
-- queuing time_explanation
UPDATE AD_Field SET Name='Queuing Time', Description='Queue time is the time a ob waits at a work center before begin handled.', Help='Queuing time has no implication on costs, but on Capacity Requirement Planning (CRP) to calculate the total time needed to manufacture a product.' WHERE AD_Column_ID=53310 AND IsCentrallyMaintained='Y'
;
-- Jun 13, 2010 8:18:43 PM COT
-- FR3015053_queuing time_explanation
UPDATE AD_Element SET Description='Queue time is the time a job waits at a work center before begin handled.', Help='Queuing time has no implication on costs, but on Capacity Requirement Planning (CRP) to calculate the total time needed to manufacture a product.',Updated=TO_TIMESTAMP('2010-06-13 20:18:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53234
;
-- Jun 13, 2010 8:18:43 PM COT
-- FR3015053_queuing time_explanation
UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=53234
;
-- Jun 13, 2010 8:18:43 PM COT
-- FR3015053_queuing time_explanation
UPDATE AD_Column SET ColumnName='QueuingTime', Name='Queuing Time', Description='Queue time is the time a job waits at a work center before begin handled.', Help='Queuing time has no implication on costs, but on Capacity Requirement Planning (CRP) to calculate the total time needed to manufacture a product.' WHERE AD_Element_ID=53234
;
-- Jun 13, 2010 8:18:43 PM COT
-- FR3015053_queuing time_explanation
UPDATE AD_Process_Para SET ColumnName='QueuingTime', Name='Queuing Time', Description='Queue time is the time a job waits at a work center before begin handled.', Help='Queuing time has no implication on costs, but on Capacity Requirement Planning (CRP) to calculate the total time needed to manufacture a product.', AD_Element_ID=53234 WHERE UPPER(ColumnName)='QUEUINGTIME' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
;
-- Jun 13, 2010 8:18:43 PM COT
-- FR3015053_queuing time_explanation
UPDATE AD_Process_Para SET ColumnName='QueuingTime', Name='Queuing Time', Description='Queue time is the time a job waits at a work center before begin handled.', Help='Queuing time has no implication on costs, but on Capacity Requirement Planning (CRP) to calculate the total time needed to manufacture a product.' WHERE AD_Element_ID=53234 AND IsCentrallyMaintained='Y'
;
-- Jun 13, 2010 8:18:43 PM COT
-- FR3015053_queuing time_explanation
UPDATE AD_Field SET Name='Queuing Time', Description='Queue time is the time a job waits at a work center before begin handled.', Help='Queuing time has no implication on costs, but on Capacity Requirement Planning (CRP) to calculate the total time needed to manufacture a product.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53234) AND IsCentrallyMaintained='Y'
;
|
-- Script deletes a database
-- If database doesn't exist, script won't fail
DROP DATABASE IF EXISTS hbtn_0c_0;
|
-- BEF initialize (insert) tables used by jpa in h2 db
INSERT INTO staff(id, first_name, last_name) VALUES(1, 'halit', 'argun'); -- NOTE ilker, using auto_increment that is used by @GeneratedValue
--INSERT INTO staff(id, first_name, last_name) VALUES(2, 'ender', 'argun');
--INSERT INTO staff(id, first_name, last_name) VALUES(3, 'yildiz', 'yilmaz');
--INSERT INTO staff(id, first_name, last_name) VALUES(4, 'zeynep', 'yilmaz');
--INSERT INTO staff(id, first_name, last_name) VALUES(5, 'alihan', 'tasdemir');
-- EOF initialize (insert) tables used by jpa in h2 db
|
--liquibase formatted sql
--changeset eibldavid:1 splitStatements:true endDelimiter:;
CREATE SEQUENCE hibernate_sequence
START WITH 100
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
create table category
(
id integer NOT NULL PRIMARY KEY,
domain_id UUID NOT NULL,
name varchar(255) NOT NULL,
parent_id UUID
);
create table product
(
id integer NOT NULL PRIMARY KEY,
domain_id UUID NOT NULL,
name varchar(255) NOT NULL,
price float NOT NULL,
category_id UUID NOT NULL
);
ALTER TABLE product ADD CONSTRAINT product_category_fk FOREIGN KEY (category_id) REFERENCES category(domain_id);
CREATE UNIQUE INDEX category_domain_id_index on category(domain_id);
CREATE UNIQUE INDEX cproduct_domain_id_index on product(domain_id);
|
create database library;
use library;
create table library.book(
id int not null unique,
title varchar(100) not null,
book_description text,
price float not null,
isbn varchar(50) not null unique,
primary key(id)
);
create table library.genre(
id int not null unique,
name varchar(30) not null unique,
primary key(id)
);
create table library.author(
id int not null unique,
name varchar(50) not null,
surname varchar(50) not null,
email varchar(100) not null unique,
adress varchar(200) not null unique,
date_of_birth date not null,
primary key(id)
);
alter table book add book_genre int;
alter table book add foreign key(book_genre) references genre(id);
alter table author add book_id int;
alter table author add foreign key(book_id) references book(id); |
--1 마당서점의고객이요구하는다음질문에대해SQL 문을작성하시오.
--(5) 박지성이구매한도서의출판사수
select custid from customer where name='박지성';
select count(distinct publisher)
from orders o, book b
where custid = (select custid from customer where name='박지성')
and o.bookid=b.bookid
;
select count(distinct publisher)
from book
where bookid in (select bookid from orders o, customer c where o.custid=c.custid and c.name='박지성')
;
--(6) 박지성이구매한도서의이름, 가격, 정가와판매가격의차이
select b.price-o.saleprice from orders o, book b where o.bookid=b.bookid;
select bookname, price, b.price-o.saleprice as salgap
from orders o, book b
where custid = (select custid from customer where name='박지성')
and o.bookid=b.bookid
;
select bookname, price, b.price-o.saleprice as salgap
from orders o, book b, customer c
where o.custid=c.custid and o.bookid=b.bookid
and c.name='박지성';
--(7) 박지성이 구매하지않은 도서의 이름
select b.bookname
from book b
where b.bookid not in (select o.bookid from orders o, customer c where o.custid=c.custid and c.name='박지성');
select distinct b.bookname
from orders o, book b
where b.bookid not in (select bookid from orders o, customer c where name='박지성'
and o.custid=c.custid)
order by b.bookname desc
;
--2 마당서점의운영자와경영자가요구하는다음질문에대해SQL 문을작성하시오.
--(8) 주문하지 않은 고객의 이름(부속질의사용)
select name
from customer
where custid not in (select distinct custid from orders)
;
select c.name
from orders o, customer c
where o.custid(+)=c.custid
and o.orderid is null
;
--(9) 주문 금액의 총액과 주문의 평균 금액
select sum(saleprice) as sum, trunc(avg(saleprice)) as avg
from orders
;
--★(10) 고객의 이름과 고객별 구매액
select c.name, sum(o.saleprice)
from customer c, orders o
where c.custid=o.custid
group by c.name;
--(11) 고객의 이름과 고객이 구매한 도서 목록
select c.name, b.bookname
from customer c, orders o, book b
where o.custid=c.custid and o.bookid=b.bookid
order by c.name
;
--(12) 도서의가격(Book 테이블)과 판매가격(Orders 테이블)의 차이가 가장 많은 주문
select *
from book b, orders o
where b.bookid=o.bookid
and abs(b.price-o.saleprice) >=
all (select abs(b.price-o.saleprice) from book b, orders o where b.bookid=o.bookid)
;
--★(13) 도서의 판매액 평균보다 자신의 구매액 평균이 더 높은 고객의 이름
select avg(saleprice) from orders;
select avg(o.saleprice) from orders o, customer c where o.custid=c.custid
group by c.custid;
select c.name
from orders o, customer c
where o.custid=c.custid
group by c.name
having avg(o.saleprice) > (select avg(saleprice) from orders)
;
--3. 마당서점에서 다음의 심화된 질문에 대해 SQL 문을 작성하시오.
--(1) 박지성이 구매한 도서의 출판사와 같은 출판사에서 도서를 구매한 고객의 이름
select distinct b.publisher
from book b, orders o, customer c
where b.bookid=o.bookid and c.custid=o.custid
and c.name='박지성'
;
select c.name
from book b, orders o, customer c
where b.bookid=o.bookid and c.custid=o.custid
and b.publisher in (select distinct b.publisher
from book b, orders o, customer c
where b.bookid=o.bookid and c.custid=o.custid
and c.name='박지성'
) and c.name != '박지성'
;
--(2) 두 개 이상의 서로 다른 출판사에서 도서를 구매한 고객의 이름
select c.name
from customer c, orders o, book b
where c.custid=o.custid and o.bookid=b.bookid
group by c.name
having count(distinct b.publisher) >= 2
order by c.name;
|
CREATE VIEW [sn].[user]
AS
SELECT
--TOP (1000)
DISTINCT([incidentA].[sys_created_by_value]) AS [user short name]
,[incidentA].[caller_id_value] AS [user sys id]
,[sys_userA].[employee_number_value] AS [employee number]
,[sys_userA].[first_name_value] AS [first name]
,[sys_userA].[last_name_value] AS [last name]
,[sys_userA].[name_value] AS [user full name]
,[sys_userA].[title_value] AS [title value]
,[sys_userA].[vip_value] AS [vip value]
,[sys_userA].[department_value] AS [department_value]
,[sys_userA].[company_value] AS [company value]
,[sys_userA].[location_value] AS [location value]
,[sys_userA].[country_value] AS [country value]
FROM [actual].[incident] AS [incidentA]
LEFT OUTER JOIN [actual].[sys_user] AS [sys_userA] ON [incidentA].[caller_id_value] = [sys_userA].[sys_id_value]
--[sys_userA].[sys_id_value] AS [sys id value]
--,[incidentSN].[caller id value] AS [caller id value]
--,[incidentSN].[caller id display value] AS [caller id display value]
--,[sys_userA].[employee_number_value] AS [employee number value]
--,[incidentSN].[sys created by value] AS [short name]
--,[incidentSN].[sys created by display value] AS [short name display]
--,[sys_userA].[first_name_value] AS [first name value]
--,[sys_userA].[last_name_value] AS [last name value]
--,[sys_userA].[name_value] AS [name value]
--,[sys_userA].[title_value] AS [title value]
--,[sys_userA].[department_value] AS [department value]
----,[cmn_departmentA].[sys_id_value] AS [department sys id]
----,[cmn_departmentA].[name_value] AS [department name]
----,[cmn_departmentA].[parent_value] AS [department parent]
----,[cmn_departmentA].[description_value] AS [description value]
----,[cmn_departmentA].[id_value] AS [department id]
--,[sys_userA].[company_value] AS [company value]
--,[sys_userA].[vip_value] AS [vip value]
--,[sys_userA].[location_value] AS [location value]
--,[sys_userA].[country_value] AS [country value]
--FROM [actual].[sys_user] AS [sys_userA]
--LEFT OUTER JOIN [sn].[incident] AS [incidentSN]
-- ON [sys_userA].[sys_id_value] = [incidentSN].[caller id value]
----LEFT OUTER JOIN [actual].[cmn_department] AS [cmn_departmentA]
---- ON [sys_userA].[department value] = [cmn_departmentA].[department sys id]
|
CREATE TABLE `user_info` (
`user_id` int(11) DEFAULT NULL,
`user_name` varchar(500) DEFAULT NULL,
`user_pwd` varchar(500) DEFAULT NULL,
`user_email` varchar(500) DEFAULT NULL,
`user_phone` int(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
INSERT INTO user_info(user_id,user_name, user_pwd, user_email, user_phone) VALUES (1, 'user0', 'abc000', 'user0@insurance.com',88880000);
INSERT INTO user_info(user_id,user_name, user_pwd, user_email, user_phone) VALUES (2, 'user1', 'abc001', 'user1@insurance.com',88881111); |
-- a lo mas habria dos banos en un autobus
ALTER TABLE autobus
ADD CONSTRAINT chk_autobus_wc
CHECK (wc BETWEEN 0 AND 2);
|
DROP TABLE MATCH CASCADE CONSTRAINT;
DROP TABLE SEASON CASCADE CONSTRAINT;
DROP TABLE COACH CASCADE CONSTRAINT;
DROP TABLE CLUB CASCADE CONSTRAINT;
DROP TABLE CATEGORY CASCADE CONSTRAINT;
DROP TABLE TEAM CASCADE CONSTRAINT;
DROP TABLE PLAYER CASCADE CONSTRAINT;
DROP TABLE SECRETARY CASCADE CONSTRAINT;
DROP TABLE TREASURER CASCADE CONSTRAINT;
DROP TABLE VICE_PRESIDENT CASCADE CONSTRAINT;
DROP TABLE PRESIDENT CASCADE CONSTRAINT;
DROP TABLE OFFICE CASCADE CONSTRAINT;
DROP TABLE USERBASKET CASCADE CONSTRAINT;
CREATE TABLE USERBASKET OF T_USER
/
CREATE TABLE OFFICE OF T_OFFICE
/
CREATE TABLE PRESIDENT OF T_PRESIDENT
/
CREATE TABLE VICE_PRESIDENT OF T_VICE_PRESIDENT
/
CREATE TABLE TREASURER OF T_TREASURER
/
CREATE TABLE SECRETARY OF T_SECRETARY
/
CREATE TABLE PLAYER OF T_PLAYER
NESTED TABLE "TEAM_WITH_PLAYERS" STORE AS "NT_TEAM_WITH_PLAYERS"
/
CREATE TABLE TEAM OF T_TEAM
/
CREATE TABLE CATEGORY OF T_CATEGORY
NESTED TABLE "LISTTEAM" STORE AS "NT_CATEGORY_TEAM"
/
CREATE TABLE CLUB OF T_CLUB
NESTED TABLE "LISTCATEGORY" STORE AS "NT_CLUB_CATEGORY"
(NESTED TABLE "LISTTEAM" STORE AS "NT_CLUB_TEAM")
/
CREATE TABLE COACH OF "BASKET_USER"."T_COACH"
NESTED TABLE "TEAM_WITH_COACH" STORE AS "NT_TEAM_WITH_COACH"
/
CREATE TABLE SEASON OF T_SEASON
/
CREATE TABLE MATCH OF T_MATCH
NESTED TABLE DETAILS STORE AS NT_MATCH_DETAILS
/
COMMIT;
|
insert into atdVrCategory (seq, CASE) values (1, '연차');
insert into atdVrCategory (seq, CASE) values (2, '반차');
insert into atdVrCategory (seq, CASE) values (4, '경조휴가');
insert into atdVrCategory (seq, CASE) values (5, '하계휴가');
insert into atdVrCategory (seq, CASE) values (6, '동계휴가'); |
-- table_ddl.sql
@clears
col v_owner new_value v_owner noprint
col v_table_name new_value v_table_name noprint
prompt
prompt Table Owner:
prompt
set feed off term off
select upper('&1') v_owner from dual;
set feed on term on
prompt
prompt Table Name:
prompt
set feed off term off
select upper('&2') v_table_name from dual;
set feed on term on
-- use binds to avoid stressing shared pool and hard parsing
var v_owner varchar2(30)
var v_table_name varchar2(30)
begin
:v_owner := '&&v_owner';
:v_table_name := '&&v_table_name';
end;
/
@clear_for_spool
set pagesize 50000
set linesize 200 trimspool on
col ddl format a200
set long 2000000
col mydb noprint new_value mydb
set term off
select lower(name) mydb from v$database;
set term on
define sqlfile=_gen_tab_&&mydb
-- dbms_metadata setup
begin
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'PRETTY',TRUE);
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'SQLTERMINATOR',TRUE);
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'SEGMENT_ATTRIBUTES',TRUE);
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'STORAGE', TRUE);
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'TABLESPACE',TRUE);
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'SPECIFICATION',TRUE);
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'BODY',TRUE);
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'CONSTRAINTS',TRUE);
end;
/
col ddl format a200
spool &&sqlfile..sql
prompt set echo on
prompt spool &&sqlfile..log
-- dbms_metadata here
prompt --########################################
prompt --## TABLE DDL
prompt --########################################
select replace(dbms_metadata.get_ddl('TABLE',:v_table_name,:v_owner),'"','') ddl from dual
/
prompt --########################################
prompt --## INDEX DDL
prompt --########################################
select replace(dbms_metadata.get_ddl('INDEX',i.index_name, i.owner),'"','') ddl
from dba_indexes i
where i.owner = :v_owner
and i.table_name = :v_table_name
/
prompt --########################################
prompt --## PRIMARY KEY
prompt --########################################
select replace(dbms_metadata.get_ddl('CONSTRAINT',c.constraint_name, c.owner),'"','') ddl
from dba_constraints c
where c.owner = :v_owner
and c.table_name = :v_table_name
and c.constraint_type = 'P'
/
prompt --########################################
prompt --## FOREIGN KEYS
prompt --########################################
select replace(dbms_metadata.get_ddl('REF_CONSTRAINT',c.constraint_name, c.owner),'"','') ddl
from dba_constraints c
where c.owner = :v_owner
and c.table_name = :v_table_name
and c.constraint_type = 'R'
/
prompt --########################################
prompt --## CHECK CONSTRAINTS
prompt --########################################
select replace(dbms_metadata.get_ddl('CONSTRAINT',c.constraint_name, c.owner),'"','') ddl
from dba_constraints c
where c.owner = :v_owner
and c.table_name = :v_table_name
and c.constraint_type = 'C'
and c.generated not like 'GENERATED%'
/
prompt spool off
prompt set echo off
spool off
@clears
undef 1 2
prompt
prompt ===========================================================================
prompt == &&sqlfile..sql contains DDL for table &v_owner..&v_table_name
prompt ===========================================================================
prompt
|
CREATE TABLE IF NOT EXISTS assento_sala (
`idAssento` INT NOT NULL,
`sala_idSala` INT UNSIGNED NOT NULL,
PRIMARY KEY (`idAssento`),
INDEX `fk_assento_sala1_idx` (`sala_idSala` ASC),
CONSTRAINT `fk_assento_sala1`
FOREIGN KEY (`sala_idSala`)
REFERENCES `sala` (`idSala`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
|
DROP DATABASE IF EXISTS library_eval;
CREATE DATABASE library;
USE library;
CREATE TABLE IF NOT EXISTS book (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
tittle VARCHAR(40) NOT NULL,
author VARCHAR(40) NOT NULL,
resume TEXT,
publication_date DATETIME,
category VARCHAR(15) NOT NULL
)
ENGINE = INNODB;
CREATE TABLE IF NOT EXISTS user (
id INT AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(20),
lastname VARCHAR(20),
sex VARCHAR(6),
birth_date DATETIME,
address VARCHAR(50),
postal_code INT,
city VARCHAR(20)
)
ENGINE = INNODB;
ALTER TABLE `book`
ADD CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
INSERT INTO book (tittle, author, category)
VALUES ('Silence of the lamb', 'Thomas Harris', 'roman'),
('Fondation', 'Isaac Asimov', 'roamn'),
('H2G2', 'Douglas Admas', 'roman');
INSERT INTO user (firstname, lastname, sex, address, postal_code,city)
VALUES ('Baptsite', 'Collignon', 'male', '2c rue du ponney qui tousse', '76000', 'Rouen'),
('Tyler', 'Durden', 'male', '2 rue Mayhem street', '7600', 'Rouen');
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.