text
stringlengths
6
9.38M
SELECT TOP (5) e.EmployeeID, e.JobTitle, a.AddressID, a.AddressText FROM [Employees] e JOIN [Addresses] a ON a.AddressID = e.AddressID ORDER BY a.AddressID
-- 1098. 小众书籍 -- 书籍表 Books: -- -- +----------------+---------+ -- | Column Name | Type | -- +----------------+---------+ -- | book_id | int | -- | name | varchar | -- | available_from | date | -- +----------------+---------+ -- book_id 是这个表的主键。 -- 订单表 Orders: -- -- +----------------+---------+ -- | Column Name | Type | -- +----------------+---------+ -- | order_id | int | -- | book_id | int | -- | quantity | int | -- | dispatch_date | date | -- +----------------+---------+ -- order_id 是这个表的主键。 -- book_id 是 Books 表的外键。 --   -- -- 你需要写一段 SQL 命令,筛选出过去一年中订单总量 少于10本 的 书籍 。 -- -- 注意:不考虑 上架(available from)距今 不满一个月 的书籍。并且 假设今天是 2019-06-23 。 -- --   -- -- 下面是样例输出结果: -- -- Books 表: -- +---------+--------------------+----------------+ -- | book_id | name | available_from | -- +---------+--------------------+----------------+ -- | 1 | "Kalila And Demna" | 2010-01-01 | -- | 2 | "28 Letters" | 2012-05-12 | -- | 3 | "The Hobbit" | 2019-06-10 | -- | 4 | "13 Reasons Why" | 2019-06-01 | -- | 5 | "The Hunger Games" | 2008-09-21 | -- +---------+--------------------+----------------+ -- -- Orders 表: -- +----------+---------+----------+---------------+ -- | order_id | book_id | quantity | dispatch_date | -- +----------+---------+----------+---------------+ -- | 1 | 1 | 2 | 2018-07-26 | -- | 2 | 1 | 1 | 2018-11-05 | -- | 3 | 3 | 8 | 2019-06-11 | -- | 4 | 4 | 6 | 2019-06-05 | -- | 5 | 4 | 5 | 2019-06-20 | -- | 6 | 5 | 9 | 2009-02-02 | -- | 7 | 5 | 8 | 2010-04-13 | -- +----------+---------+----------+---------------+ -- -- Result 表: -- +-----------+--------------------+ -- | book_id | name | -- +-----------+--------------------+ -- | 1 | "Kalila And Demna" | -- | 2 | "28 Letters" | -- | 5 | "The Hunger Games" | -- +-----------+--------------------+ -- -- 来源:力扣(LeetCode) -- 链接:https://leetcode-cn.com/problems/unpopular-books -- 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 SELECT b.book_id, b.NAME FROM Books AS b LEFT JOIN Orders AS o ON b.book_id = o.book_id AND o.dispatch_date BETWEEN '2018-06-23' AND '2019-06-23' WHERE b.available_from <= '2019-05-23' GROUP BY b.book_id HAVING ifnull( sum( o.quantity ), 0 ) < 10;
-- SQL 2 -- -- alter table --adding a new column and its value type ALTER TABLE <table name> ( ADD COLUMN <column_name> <valuetype> ); --deleting columns from your table ALTER TABLE <table name> DROP COLUMN <column_name>; --changing a column’s data type ALTER TABLE <table name> ALTER <column_name> SET DATA TYPE decimal; --rename table name ALTER TABLE <table name> RENAME TO <new table name>; --rename column name ALTER TABLE <table name> RENAME COLUMN <column_name> TO <new column_name>; --add primary keys to a column after column has been created ALTER TABLE <table name> ADD PRIMARY KEY (column_name you are setting as primary key); --add foreign keys to a column after column has been created ALTER TABLE <table name> ADD FOREIGN KEY (column_name you are setting as foreign key); -when creating a table and you are setting up REFERENCES CREATE TABLE <table name> ( id SERIAL PRIMARY KEY, name VARCHAR(50), subject_id INT REFERENCES subjects (id) ) --Joins --inner joins SELECT <column names> FROM <table 1> INNER JOIN <table 2> ON <primary key> = <foreign key>
SELECT purchases.user_id, purchases.stream_id, stream_title, stream_desc, stream_date, stream_hours, purchases.streamer_id, purchase_timestamp, purchases.purchase_price, purchases.purchase_id FROM purchases INNER JOIN streams ON streams.stream_id = purchases.stream_id WHERE purchases.user_id = $1 AND purchases.stream_id = $2
-- phpMyAdmin SQL Dump -- version 4.1.14 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Oct 28, 2015 at 03:47 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: `book` -- -- -------------------------------------------------------- -- -- Table structure for table `book` -- CREATE TABLE IF NOT EXISTS `book` ( `book_id` int(11) NOT NULL, `title` varchar(30) NOT NULL, `year` int(11) NOT NULL, `price` float NOT NULL, `category` varchar(30) NOT NULL, PRIMARY KEY (`book_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `book` -- INSERT INTO `book` (`book_id`, `title`, `year`, `price`, `category`) VALUES (1, 'Everyday Italian', 2005, 30, 'cooking'), (2, 'Harry Potter', 2005, 29.99, 'children'), (3, 'XQuery Kick Start', 2003, 49.99, 'web'), (4, 'Learning XML', 2003, 39.95, 'web'); /*!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 */;
-- Initialisation spécifiques pour un jeu de test INSERT INTO Galerie(id, nom, adresse) VALUES (1, 'Saatchi', 'King\''s Road, London'); INSERT INTO Exposition (id , debut, intitule ,duree, organisateur_id) VALUES (1, NULL, 'L Art Brut Contemporain', NULL, 1) ; INSERT INTO Exposition (id, debut, intitule, duree, organisateur_id) VALUES (2, TO_DATE ('2021/02/01','YYYY/MM/DD'), 'Art de la Renaissance', 20,1) ; INSERT INTO Personne (id, nom, adresse) VALUES (1, 'M.Bastide', null); INSERT INTO Personne (id, nom, adresse) VALUES (2, 'Léonard De Vinci', null); INSERT INTO Artiste (id, biographie) VALUES (2,'...') ; INSERT INTO Tableau (id, titre, support, largeur, hauteur, auteur_id) VALUES (1, 'bacchus 1st Version IV','huile sur toile', 4, 4, 2) ; INSERT INTO Exposition_oeuvres (accrochages_id, oeuvres_id) VALUES (1,1) ; INSERT INTO Transactions (id, vendu_Le, prix_Vente, client_id, lieu_de_vente_id, oeuvre_id) VALUES (1, TO_DATE ('2010/01/01','YYYY/MM/DD') ,0, 1 , 1, 1);
@clears set line 200 trimspool on set pagesize 60 col member format a50 head 'MEMBER' col group# format 999 head 'GRP' col thread# format 999 head 'THR' col sequence# format 999999 head 'SEQ' col group_status format a8 head 'GROUP|STATUS' col member_status head 'MEMBER|STATUS' col systime format a18 head 'SYSTEM TIME' col bytes format 99,999,999,999 head 'SIZE IN BYTES' col first_time format a20 head 'TIME OF FIRST SCN' col archived head 'ARCH?' format a5 col inst_id format 9999 head 'INST|ID' clear break break on thread# skip 1 select --l.inst_id, l.thread#, l.group#, sequence#, bytes, member, l.status group_status, f.status member_status, l.archived, to_char(first_time,'yyyy-mm-dd hh24:mi:ss') first_time from v$log l, v$logfile f where l.group# = f.group# --and l.inst_id = f.inst_id order by thread#,group# /
alter table "public"."SkillTag" drop constraint "SkillTag_skillId_tagId_key";
DROP DATABASE IF EXISTS pulstime_db_test; CREATE DATABASE pulstime_db_test; USE pulstime_db_test; create table Orders_Contents ( orderid int, itemid int, qty int not null, promo varchar(255) not null, price double not null, `instock` varchar(45) DEFAULT NULL ) engine=InnoDB; CREATE TABLE `orders` ( `orderid` int (11) NOT NULL AUTO_INCREMENT, `customer_email` varchar (255) DEFAULT NULL, `date` varchar (255) NOT NULL, `status` varchar (255) NOT NULL, `total_sum` double DEFAULT NULL, `comment` longtext, PRIMARY KEY (`orderid`) ) ENGINE=InnoDB; create table Payment ( orderid int, payment_type varchar(255), payment_id varchar(255), primary key(orderid) ) engine=InnoDB; create table Delivery ( orderid int, `type` varchar (255) not null, tariff varchar (255) not null, city varchar (255) not null, `address` varchar (255), post_index varchar (255), delivery_cost double, delivery_date varchar (255) ) engine=InnoDB; create table Promo ( promo varchar(255) not null, promo_items text not null, amount int, primary key(promo) ) engine=InnoDB; create table Customers ( email varchar(255) unique not null, `name` varchar (255) not null, tel varchar (255) not null, city varchar (255), street varchar (255), house varchar (255), primary key (email) ) engine=InnoDB; create table Status ( statusid int unique, `status` varchar (255), primary key (statusid) ) engine=InnoDB; create table Products ( productid int, idx int, `name` varchar (255), `type` varchar (255), `description` longtext, short longtext, opinion longtext, complect longtext, hit boolean default '0', new boolean default '0', primary key (productid) ) engine=InnoDB; create table Products_Categories ( productid int, categoryid smallint(5), primary key(productid, categoryid) ) engine=InnoDB; create table Categories ( categoryid smallint(5), category varchar(255), primary key(categoryid) ) engine=InnoDB; create table Products_Funcs ( productid int, funcid int, primary key(productid, funcid) ) engine=InnoDB; create table Funcs ( funcid int, func varchar(255), primary key(funcid) ) engine=InnoDB; CREATE TABLE Items ( `itemid` int(11) NOT NULL, `productid` int(11) DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `colorid` int(11) DEFAULT NULL, `sizeid` int(11) DEFAULT NULL, `image_list` varchar(255) DEFAULT NULL, `chars` longtext, `complect` longtext, `price` double DEFAULT NULL, `oldprice` double DEFAULT NULL, `instock` varchar(255) DEFAULT NULL, `date_arrive` varchar(45) DEFAULT NULL, `no_order` int(1) DEFAULT '0', -- Можно приобрести без заказа PRIMARY KEY (`itemid`) ) ENGINE=InnoDB; create table Colors ( colorid int, color varchar(40), color_eng varchar(40), primary key(colorid) ) engine=InnoDB; create table Size ( sizeid int, size varchar(255), primary key(sizeid) ) engine=InnoDB;
insert into Pirkejai(ID,Vardas, Pavarde, Amzius, Kredito_Kortele) Values(1, 'Simas', 'Purtokas', '21', 'VISA'); insert into Pirkejai(ID,Vardas, Pavarde, Amzius, Kredito_Kortele) Values(2, 'Lukas', 'Burokauskas', '32', 'MasterCard'); insert into Pirkejai(ID,Vardas, Pavarde, Amzius, Kredito_Kortele) Values(3, 'Saulius', 'Fokinas', '26', 'VISA'); insert into Pirkejai(ID,Vardas, Pavarde, Amzius, Kredito_Kortele) Values(4, 'Paulius', 'Birunas', '19', 'MasterCard'); insert into Pirkejai(ID,Vardas, Pavarde, Amzius, Kredito_Kortele) Values(5, 'Mindaugas', 'Barzda', '43', 'MasterCard'); insert into Pirkiniu_krepselis(ID, Prekiu_sarasas, Apsipirkimu_data, Pirkejas_ID, Islaidu_suma) Values(1,'YEEZY BOOST 350 V2 size 11', '2017-03-29',1,700); insert into Pirkiniu_krepselis(ID, Prekiu_sarasas, Apsipirkimu_data, Pirkejas_ID, Islaidu_suma) Values(2,'Nike Roshe Run, size 12', '2017-03-30',2,175); insert into Pirkiniu_krepselis(ID, Prekiu_sarasas, Apsipirkimu_data, Pirkejas_ID, Islaidu_suma) Values(3,'YEEZY BOOST 750, size 12.5', '2017-04-01',3,1250); insert into Pirkiniu_krepselis(ID, Prekiu_sarasas, Apsipirkimu_data, Pirkejas_ID, Islaidu_suma) Values(4,'AIR JORDAN XXXI, size 10.5', '2017-04-01',4,185); insert into Pirkiniu_krepselis(ID, Prekiu_sarasas, Apsipirkimu_data, Pirkejas_ID, Islaidu_suma) Values(5,'JORDAN FORMULA 23, size 12', '2017-04-02',5,99); insert into Parduotuve(ID, Pavadinimas, Miestas, Gatve,Pirkejas_ID, Namo_Nr) Values (1, 'H&M', 'Kaunas', 'Studentu g.', '1', 69); insert into Parduotuve(ID, Pavadinimas, Miestas, Gatve,Pirkejas_ID, Namo_Nr) Values (2, 'CROPP', 'Vilnius', 'Naujoji g.', '2', 54); insert into Parduotuve(ID, Pavadinimas, Miestas, Gatve,Pirkejas_ID, Namo_Nr) Values (3, 'BERKA', 'Vilnius', 'Nadruvos g.', '3', 55); insert into Parduotuve(ID, Pavadinimas, Miestas, Gatve,Pirkejas_ID, Namo_Nr) Values (4, 'VINTAGE', 'Kaunas', 'Savanorių pr.', '4', 192); insert into Parduotuve(ID, Pavadinimas, Miestas, Gatve,Pirkejas_ID, Namo_Nr) Values (5, 'VOYAGE', 'Kaunas', 'Simono Daukanto g.', '5', 15);
/* Swiss army/spaghetti query for returning all pertinent information in this hierarchy: Folder-->workflow-->mapping-->session-->MAPPLET. Adapted from Informatica PC forums; used in Powercenter 9.6.1 */ SELECT * FROM ( SELECT DISTINCT (SELECT F.SUBJ_NAME FROM PC_REPO.OPB_SUBJECT F WHERE F.SUBJ_ID = S.SUBJECT_ID ) FOLDER_NAME , (SELECT WF.TASK_NAME FROM PC_REPO.OPB_TASK WF, PC_REPO.OPB_TASK_INST WF_INST WHERE WF.TASK_ID = WF_INST.WORKFLOW_ID AND WF_INST.TASK_ID = S.TASK_ID ) WORKFLOW_NAME , M.MAPPING_NAME MAPPING_NAME , S.TASK_NAME SESS_NAME , (SELECT DECODE(OPB_SWIDGET_INST.MAPPLET_MAP_ID, 0, 'NO MAPPLET', MPLT.MAPPING_NAME ) MAPPLET_NAME FROM PC_REPO.OPB_MAPPING MPLT WHERE OPB_SWIDGET_INST.MAPPLET_MAP_ID = MPLT.MAPPING_ID ) MAPPLET_NAME FROM PC_REPO.OPB_SWIDGET_INST , PC_REPO.OPB_TASK S , PC_REPO.OPB_MAPPING M WHERE OPB_SWIDGET_INST.SESSION_ID = S.TASK_ID AND OPB_SWIDGET_INST.MAPPING_ID = M.MAPPING_ID --AND S.TASK_NAME = 'YOUR_SESSION_NAME' ) --WHERE FOLDER_NAME NOT LIKE '%/%' --AND UPPER(MAPPING_NAME) LIKE '%%' --AND WORKFLOW_NAME LIKE '%%' --AND SESS_NAME LIKE '%%'
CREATE TABLE rv.s_WeatherObservation_DataPoint ( WeatherObservationHashKey CHAR(32) NOT NULL , LoadDate DATETIME2 NOT NULL , RecordSource VARCHAR(500) NOT NULL , HashDiff CHAR(32) NOT NULL , [G] NUMERIC(10,2) , [T] NUMERIC(10,2) , [V] NUMERIC(10,2) , [D] NVARCHAR(4) , [S] NUMERIC(10,2) , [W] NUMERIC(10,2) , [P] NUMERIC(10,2) , [Pt] NVARCHAR(4) , [Dp] NUMERIC(10,2) , [H] NUMERIC(10,2) , [ObservationDate] DATE , [$] INT , CONSTRAINT [PK_s_WeatherObservation_DataPoint] PRIMARY KEY NONCLUSTERED ( WeatherObservationHashKey ASC , LoadDate ASC ) );
-- 1. Составьте список пользователей users, которые осуществили хотя бы один заказ orders в интернет магазине. SELECT DISTINCT users.name from orders JOIN users ON orders.user_id = users.id; --2. Выведите список товаров products и разделов catalogs, который соответствует товару. SELECT products.name product_name, catalogs.name catalog_name FROM products JOIN catalogs ON catalogs.id = products.catalog_id --3. (по желанию) Пусть имеется таблица рейсов flights (id, from, to) и таблица городов cities (label, name). Поля from, to и label содержат английские названия городов, поле name — русское. Выведите список рейсов flights с русскими названиями городов. SELECT flights.id, from_name.name f_from, to_name.name f_to FROM flights JOIN (SELECT id, f_from, cities.name FROM flights JOIN cities ON flights.f_from = cities.label ORDER BY flights.id) from_name ON from_name.id = flights.id JOIN (SELECT id, f_to, cities.name FROM flights JOIN cities ON flights.f_to = cities.label ORDER BY flights.id) to_name ON to_name.id = flights.id ORDER BY id;
CREATE TABLE [display].[spotlight] ( [sys_id_display_value] NVARCHAR(MAX) NULL, [spotlight_group_display_value] NVARCHAR(MAX) NULL, [sys_mod_count_display_value] NVARCHAR(MAX) NULL, [active_display_value] NVARCHAR(MAX) NULL, [sys_updated_on_display_value] NVARCHAR(MAX) NULL, [sys_tags_display_value] NVARCHAR(MAX) NULL, [evaluated_at_display_value] NVARCHAR(MAX) NULL, [score_display_value] NVARCHAR(MAX) NULL, [sys_updated_by_display_value] NVARCHAR(MAX) NULL, [sys_created_on_display_value] NVARCHAR(MAX) NULL, [id_display_value] NVARCHAR(MAX) NULL, [table_display_value] NVARCHAR(MAX) NULL, [sys_created_by_display_value] NVARCHAR(MAX) NULL )
left join person p on p.id = f.id JOIN foo f on f.id=p.id
 SELECT [0] +' '+ [1] AS Район, CITY.Сокращение AS [Тип НП], CITY.Название AS [Населенный пункт], STREET.Сокращение AS [Тип улицы], STREET.Название AS Улица, HOUSE.Номер AS Дом, HOUSE.Фамилия AS Корпус, FLAT.Номер AS Квартира, FLAT.Фамилия AS [Литерал квартиры], (ISNULL(CITY.Сокращение+'.'+' '+CITY.Название, ' ') + ' '+ISNULL(STREET.Сокращение+'.'+' '+STREET.Название, ' ')+' ' + ISNULL(CAST(HOUSE.Номер AS nvarchar(12)), ' ') + ' '+ISNULL(CAST(HOUSE.Фамилия AS nvarchar(12)), ' ') +' ' +ISNULL(CAST(FLAT.Номер AS nvarchar(12)), ' ')+' '+ISNULL(CAST(FLAT.Фамилия AS nvarchar(12)), ' ') ) AS Адрес FROM ( SELECT LI.РодительТип, LI.Потомок, CASE WHEN LI.РодительТип=0 THEN LS.Фамилия WHEN LI.РодительТип=1 THEN ORG.Название WHEN LI.РодительТип IN (12,2) THEN CAST(CY.ROW_ID AS nvarchar(12)) WHEN LI.РодительТип IN (11,2) THEN CAST(CY.ROW_ID AS nvarchar(12)) WHEN LI.РодительТип IN (13,2) THEN CAST(CY.ROW_ID AS nvarchar(12)) WHEN LI.РодительТип=3 THEN CAST(LS.ROW_ID AS nvarchar(12)) WHEN LI.РодительТип=4 THEN CAST(LS.ROW_ID AS nvarchar(12)) WHEN LI.РодительТип=5 THEN CAST(LS.Номер AS nvarchar(12)) END AS Адрес FROM stack.[Лицевые иерархия] AS LI JOIN stack.[Лицевые счета] AS LS ON LI.Родитель=LS.ROW_ID LEFT JOIN stack.Города AS CY ON LS.[Улица-Лицевой счет]=CY.ROW_ID --Участок LEFT JOIN stack.Организации AS ORG ON ORG.ROW_ID=LS.[Счет-Линейный участок] WHERE LI.ПотомокТип=5 AND LI.Потомок=164171 --формирование пивот-таблицы ) AS pvt_adrs PIVOT ( MAX(Адрес) FOR pvt_adrs.РодительТип IN ([0],[1],[12],[13],[11],[2],[3],[4],[5]) ) AS pvt_adrs LEFT JOIN stack.Города AS CITY ON CITY.ROW_ID=CAST([12] AS int) LEFT JOIN stack.Города AS STREET ON STREET.ROW_ID=CAST([2] AS int) LEFT JOIN stack.[Лицевые счета] AS HOUSE ON HOUSE.ROW_ID=CAST([3] AS int) LEFT JOIN stack.[Лицевые счета] AS FLAT ON FLAT.ROW_ID=CAST([4] AS int)
DROP TABLE credit_line; CREATE TABLE credit_line ( credit_line_id NUMBER CONSTRAINT credit_line_id PRIMARY KEY, customer_id NUMBER(8), credit_limit NUMBER(10,2) DEFAULT 10000 NOT NULL, creation_date DATE DEFAULT SYSDATE NOT NULL, valid_from DATE DEFAULT TO_DATE('01.01.2017','DD.MM.YYYY') NOT NULL, valid_to DATE DEFAULT TO_DATE('31.12.2020','DD.MM.YYYY') NOT NULL, last_change_date DATE DEFAULT SYSDATE NOT NULL, CONSTRAINT fk_customer_id FOREIGN KEY(customer_id) REFERENCES customers(customer_id), CONSTRAINT check_credit_limit CHECK(credit_limit>0) ); COMMENT ON COLUMN credit_line.credit_line_id IS 'primary key for table'; COMMENT ON COLUMN credit_line.customer_id IS 'Customer if for Credit line'; COMMENT ON COLUMN credit_line.credit_limit IS 'The amount of credit available to the customer'; COMMENT ON COLUMN credit_line.creation_date IS 'Creation date of the credit line'; COMMENT ON COLUMN credit_line.valid_from IS 'Credit line valid from date'; COMMENT ON COLUMN credit_line.valid_to IS 'Credit line valid to date'; COMMENT ON COLUMN credit_line.last_change_date IS 'Date of the last change of credit line amount'; DROP SEQUENCE seq_09_credit_line; CREATE SEQUENCE seq_09_credit_line INCREMENT BY 1 START WITH 1 MAXVALUE 9999 NOCYCLE;
DELETE FROM DB_CEIBA_RENTA_PELICULA.PRESTAMO; DELETE FROM DB_CEIBA_RENTA_PELICULA.CLIENTE; DELETE FROM DB_CEIBA_RENTA_PELICULA.PELICULA; INSERT INTO DB_CEIBA_RENTA_PELICULA.CLIENTE(DOC_IDENTIDAD,NOMBRES,APELLIDOS) VALUES ( 123, 'gabriel', 'arboleda' ); INSERT INTO DB_CEIBA_RENTA_PELICULA.CLIENTE(DOC_IDENTIDAD,NOMBRES,APELLIDOS) VALUES ( 321, 'andres', 'tolosa' ); INSERT INTO DB_CEIBA_RENTA_PELICULA.PELICULA(ID_PELICULA,NOMBRE_PELICULA,GENERO) VALUES ( 1, 'matrix', 'accion' ); INSERT INTO DB_CEIBA_RENTA_PELICULA.PELICULA(ID_PELICULA,NOMBRE_PELICULA,GENERO) VALUES ( 2, 'avengers', 'accion' ); INSERT INTO DB_CEIBA_RENTA_PELICULA.PRESTAMO(ID_PRESTAMO,FECHA_PRESTAMO,FECHA_DEVOLUCION,VALOR_PRESTAMO,DOC_IDENTIDAD,ID_PELICULA) VALUES ( 1, PARSEDATETIME('14/12/2020', 'dd/MM/yyyy'), PARSEDATETIME('14/08/2021', 'dd/MM/yyyy'), 15000, 123, 1 );
CREATE VIEW `vista 1` AS select Libros.titulo as "Titulo", Autores.nombre as "Nombre", Autores.apellido as "Apellido", Libros.fecha_publicacion as "Fecha" from Biblioteca.Libros join Biblioteca.libros_autores on Libros.id_libro = libros_autores.id_libro join Biblioteca.Autores on Autores.id_autor = libros_autores.id_autor order by Libros.fecha_publicacion ASC;
SELECT UPPER(last_name) AS 'NAME', first_name, subscription.price FROM user_card INNER JOIN member ON user_card.id_user = member.id_member INNER JOIN subscription ON member.id_sub = subscription.id_sub WHERE subscription.price > 42 ORDER BY last_name, first_name;
SELECT CHAVE FROM TESTE1 WHERE CHAVE = 'pudim'
CREATE TABLE users ( user_id SERIAL PRIMARY KEY, username VARCHAR (75), password VARCHAR (75) ); INSERT INTO users (username, password) VALUES ('test_user', 'password'); CREATE TABLE products ( product_id SERIAL PRIMARY KEY, product_url text, product_name VARCHAR (75), product_description VARCHAR (500), product_price int ); alter table products add column user_id int references users(user_id); INSERT INTO products (product_url, product_name, product_description, product_price) VALUES ('test_url', 'test_shirt', 'test_this shirt is blue', '5'); select * from products join users on products.user_id = users.user_id
SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for goods -- ---------------------------- DROP TABLE IF EXISTS `goods`; CREATE TABLE `goods` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` int(10) UNSIGNED NOT NULL COMMENT '商家id', `goods_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品编码', `goods_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品名称', `goods_pics` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '头图', `goods_ad` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品广告语15个字', `goods_stock` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '商品库存', `goods_price` decimal(12, 2) NOT NULL DEFAULT 0.00 COMMENT '商品价格', `goods_cost_price` decimal(12, 2) NOT NULL COMMENT '成本价', `sale_num` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '累计销售量', `goods_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '商品状态 0下架 1上架', `goods_status_time` timestamp(0) NOT NULL COMMENT '上下架时间', `created_time` timestamp(0) NULL DEFAULT NULL COMMENT '添加时间', `updated_time` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间', PRIMARY KEY (`id`) USING BTREE, INDEX `goods_name`(`goods_name`) USING BTREE, INDEX `user_id`(`user_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品表' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of goods -- ---------------------------- -- ---------------------------- -- Table structure for order_details -- ---------------------------- DROP TABLE IF EXISTS `order_details`; CREATE TABLE `order_details` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `order_id` int(10) UNSIGNED NOT NULL COMMENT '订单ID', `user_id` int(10) UNSIGNED NOT NULL COMMENT '用户ID', `goods_id` int(10) UNSIGNED NOT NULL COMMENT '商品id', `goods_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '冗余商品名称', `goods_pic` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '冗余商品头图', `goods_price` decimal(12, 2) NOT NULL DEFAULT 0.00 COMMENT '商品价格', `buy_num` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '购买件数', `pay_price` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '实付价格', `is_comment` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否评价过(暂不使用)', PRIMARY KEY (`id`) USING BTREE, INDEX `order_id`(`order_id`) USING BTREE, INDEX `user_id`(`user_id`) USING BTREE, INDEX `goods_id`(`goods_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '订单商品详情表' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of order_details -- ---------------------------- -- ---------------------------- -- Table structure for order_refunds -- ---------------------------- DROP TABLE IF EXISTS `order_refunds`; CREATE TABLE `order_refunds` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `order_id` int(10) UNSIGNED NOT NULL COMMENT '订单ID', `user_id` int(10) UNSIGNED NOT NULL COMMENT '用户ID', `refund_money` decimal(12, 2) UNSIGNED NOT NULL COMMENT '总退款金额', `refund_status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态 1申请退款 2退款成功 3退款失败 ', `refunded_time` timestamp(0) NULL DEFAULT NULL COMMENT '退款时间', `created_time` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间', `updated_time` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间', PRIMARY KEY (`id`) USING BTREE, INDEX `order_id`(`order_id`) USING BTREE, INDEX `user_id`(`user_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '退款单表(简单设计,整单退,不包含物流)' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of order_refunds -- ---------------------------- -- ---------------------------- -- Table structure for orders -- ---------------------------- DROP TABLE IF EXISTS `orders`; CREATE TABLE `orders` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '订单号 不单独设计订单ID了', `order_title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单简介', `user_id` int(10) UNSIGNED NOT NULL COMMENT '用户ID', `goods_total_price` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '商品总价', `freight_price` decimal(8, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '运费', `order_pay_price` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '需要支付', `order_total_price` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '原总价', `created_time` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间', `updated_time` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间', `paid_time` timestamp(0) NULL DEFAULT NULL COMMENT '支付时间', `sended_time` timestamp(0) NULL DEFAULT NULL COMMENT '发货时间', `taked_time` timestamp(0) NULL DEFAULT NULL COMMENT '收货时间', `closed_time` timestamp(0) NULL DEFAULT NULL COMMENT '关闭时间', `buy_note` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '买家附言', `order_state` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '订单状态 0:新订单 1已支付,2已发货,3:已完成 5:关闭', `close_state` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '关闭原因 0未关闭 1未支付 2退款关闭(退款不涉及复杂单个商品退款)', `refund_status` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '冗余退款状态 状态 0未申请 1申请退款 2退款成功 3退款失败 ', `refund_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '退款申请单号 当有退款时', `post_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '收货人 物流这一部分简单设计了', `post_phone` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '收货电话', `post_address` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '收货地址', `express_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '快递号', `express_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '快递公司', PRIMARY KEY (`id`) USING BTREE, INDEX `user_id`(`user_id`) USING BTREE, INDEX `created_time`(`created_time`) USING BTREE, INDEX `paid_time`(`paid_time`) USING BTREE, INDEX `taked_time`(`taked_time`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '订单主表' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of orders -- ---------------------------- -- ---------------------------- -- Table structure for users -- ---------------------------- DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '用户ID', `user_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '用户名', `user_pass` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '用户密码', `phone` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机号码(按监管要求这里要加密)', `balance` decimal(12, 2) NULL DEFAULT NULL COMMENT '账户余额(本来分表,这里简单设计到一起)', `real_name` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '真实姓名', `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地址(本来应该设计一个地址表,省区县详细地址,多地址选择,这里简单处理)', `created_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '注册IP', `created_time` timestamp(0) NULL DEFAULT NULL COMMENT '注册时间', `updated_time` timestamp(0) NULL DEFAULT NULL COMMENT '更新时间', `last_login_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '最近登录IP', `last_login_time` timestamp(0) NULL DEFAULT NULL COMMENT '最近登录时间', `is_lock` tinyint(1) NULL DEFAULT NULL COMMENT '是否锁定 0为正常 1为锁定', `lock_mark` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '锁定原因', `lock_time` timestamp(0) NULL DEFAULT NULL COMMENT '账号锁定时间', PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `user_name`(`user_name`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户表' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of users -- ---------------------------- SET FOREIGN_KEY_CHECKS = 1;
with `sr_items` as (select `i_item_id` as `item_id`, sum(`sr_return_quantity`) as `sr_item_qty` from `store_returns` where `sr_item_sk` = `i_item_sk` and `d_date` in (select `d_date` from `date_dim` where `d_week_seq` in (select `d_week_seq` from `date_dim` where `d_date` in (cast('2000-06-30' as date), cast('2000-09-27' as date), cast('2000-11-17' as date)))) and `sr_returned_date_sk` = `d_date_sk` group by `i_item_id`), `cr_items` as (select `i_item_id` as `item_id`, sum(`cr_return_quantity`) as `cr_item_qty` from `catalog_returns` where `cr_item_sk` = `i_item_sk` and `d_date` in (select `d_date` from `date_dim` where `d_week_seq` in (select `d_week_seq` from `date_dim` where `d_date` in (cast('2000-06-30' as date), cast('2000-09-27' as date), cast('2000-11-17' as date)))) and `cr_returned_date_sk` = `d_date_sk` group by `i_item_id`), `wr_items` as (select `i_item_id` as `item_id`, sum(`wr_return_quantity`) as `wr_item_qty` from `web_returns` where `wr_item_sk` = `i_item_sk` and `d_date` in (select `d_date` from `date_dim` where `d_week_seq` in (select `d_week_seq` from `date_dim` where `d_date` in (cast('2000-06-30' as date), cast('2000-09-27' as date), cast('2000-11-17' as date)))) and `wr_returned_date_sk` = `d_date_sk` group by `i_item_id`) (select `sr_items`.`item_id`, `sr_item_qty`, cast(`sr_item_qty` / (cast(`sr_item_qty` as decimal(9, 9)) + `cr_item_qty` + `wr_item_qty`) / 3.0 * 100 as decimal(7, 7)) as `sr_dev`, `cr_item_qty`, cast(`cr_item_qty` / (cast(`sr_item_qty` as decimal(9, 9)) + `cr_item_qty` + `wr_item_qty`) / 3.0 * 100 as decimal(7, 7)) as `cr_dev`, `wr_item_qty`, cast(`wr_item_qty` / (cast(`sr_item_qty` as decimal(9, 9)) + `cr_item_qty` + `wr_item_qty`) / 3.0 * 100 as decimal(7, 7)) as `wr_dev`, (`sr_item_qty` + `cr_item_qty` + `wr_item_qty`) / 3.00 as `average` from `sr_items` where `sr_items`.`item_id` = `cr_items`.`item_id` and `sr_items`.`item_id` = `wr_items`.`item_id` order by `sr_items`.`item_id`, `sr_item_qty` fetch next 100 rows only)
SELECT c.`uuid` AS uuid, c.`name` AS name, c.`user` AS user, c.`open` AS open, null as control, b.`uri` AS brokerUri, b.`name` AS brokerName, b.`user` AS brokerUser FROM `clients` c INNER JOIN `brokers`b ON b.`uri` = c.`broker` WHERE c.`user` <> ? AND b.`user`= c.`user` AND c.`open` = TRUE AND c.`uuid` NOT IN (SELECT s.`client` FROM `shares` s WHERE s.`user` = ?) LIMIT ?,?;
USE `dbphp7`; DROP procedure IF EXISTS `sp_usuarios_insert`; DELIMITER $$ USE `dbphp7`$$ CREATE PROCEDURE `sp_usuarios_insert` ( pdeslogin VARCHAR (64), pdessenha VARCHAR (256) ) BEGIN INSERT INTO tb_usuarios (deslogin,dessenha) VALUES (pdeslogin,pdessenha); SELECT * FROM tb_usuarios WHERE idusuario = LAST_INSERT_ID(); END $$ DELIMITER ;
-- Select the burgers_db USE rentals_db; -- Insert new rows of data. INSERT INTO bikes (bike_name, devoured) VALUES ("schwinn", false), ("bmx", false), ("dirt bike", false);
--修改人:蒲勇军 --修改时间:2012-10-24 17:04:26 --修改内容:添加资金预警查询菜单 insert into bt_sys_res (RES_CODE, RES_NAME, SYS_CODE, FATHER_CODE, RES_URL, FUNC_FLAG, RES_TYPE, LINK_TARGET, STATUS, RES_ORDER, RMK, REVERSE1, REVERSE2, REVERSE3, REVERSE4, REVERSE5, REVERSE6, REVERSE7, REVERSE8, REVERSE9, REVERSE10, RES_LEVEL, RES_ROLE) values ((select max(s1.RES_CODE)+1 from bt_sys_res s1), '资金预警查询', 'fwg', (select s2.res_code from bt_sys_res s2 where s2.res_name='预警展示处理' and s2.sys_code = 'fwg' ), '/fundwarning/queryFundwarningAction.do?method=queryWarningAll', '0', '1', '0', '0', 9, '', '', '', '', '', '', null, null, null, null, null, 2, ''); commit; --修改日期:2012.10.25 --修改人:周兵 --修改内容:增加摘要预警三个字段,(zhaiyao_operator 中1为‘且’,2为‘或’;operator2中3为‘包含’,4为‘不包含’;warning_rmk2为内容。 --修改原因:在摘要预警中需要多加入是否包含这一条件 alter table bt_warning_strategy_detail add zhaiyao_operator varchar2(1); alter table bt_warning_strategy_detail add operator2 varchar2(1); alter table bt_warning_strategy_detail add warning_rmk2 varchar2(200); comment on column bt_warning_strategy_detail.zhaiyao_operator is '且或'; comment on column bt_warning_strategy_detail.operator2 is '是否包含'; comment on column bt_warning_strategy_detail.warning_rmk2 is '包含内容'; --修改日期:2012.10.26 --修改人:刘之三 --修改内容:增加预警展示中十一个表的一个字段,(remark 备注) --修改原因:预警查询时,如果将预警状态进行更改,需要进行备注说明。 alter table bt_warning_cash add remark varchar2(200); comment on column bt_warning_cash.remark is '备注'; alter table bt_warning_bal add remark varchar2(200); comment on column bt_warning_bal.remark is '备注'; alter table bt_warning_payee add remark varchar2(200); comment on column bt_warning_payee.remark is '备注'; alter table bt_warning_largepay add remark varchar2(200); comment on column bt_warning_largepay.remark is '备注'; alter table bt_warning_overflow add remark varchar2(200); comment on column bt_warning_overflow.remark is '备注'; alter table bt_warning_balancedown add remark varchar2(200); comment on column bt_warning_balancedown.remark is '备注'; alter table bt_warning_dtlrmk add remark varchar2(200); comment on column bt_warning_dtlrmk.remark is '备注'; alter table bt_warning_outpay add remark varchar2(200); comment on column bt_warning_outpay.remark is '备注'; alter table bt_warning_dezjzc add remark varchar2(200); comment on column bt_warning_dezjzc.remark is '备注'; alter table bt_warning_swyzsb add remark varchar2(200); comment on column bt_warning_swyzsb.remark is '备注'; alter table bt_warning_zchlr add remark varchar2(200); comment on column bt_warning_zchlr.remark is '备注'; --修改日期:2012.10.30 --修改人:周兵 --修改内容: 账户余额持续下降预警信息,增加 上4月末(last_four_month_end),上4月平均(last_four_month_ave),上5月末(last_five_month_end),上5月平均(last_five_month_ave) --修改原因:在账户余额持续下降预警信息,原需求为不论一级、二级、三级预警都是扫描最近四个月。而现在改为一级预警扫描最近两个个月,二级预警扫描最近四个月,三级预警扫描最近六个月 alter table bt_warning_balancedown add last_four_month_end number(15,2); alter table bt_warning_balancedown add last_four_month_ave number(15,2); alter table bt_warning_balancedown add last_five_month_end number(15,2); alter table bt_warning_balancedown add last_five_month_ave number(15,2); comment on column bt_warning_balancedown.last_four_month_end is '上4月末'; comment on column bt_warning_balancedown.last_four_month_ave is '上4月平均'; comment on column bt_warning_balancedown.last_five_month_end is '上5月末'; comment on column bt_warning_balancedown.last_five_month_ave is '上5月平均'; --修改日期:2012.11.01 --修改人:周兵 --修改内容: 增加预警限额说明 --修改原因:以前的为strategy_money,现在改为一段字符串,显示在某个数值之间。如1<且>2等.并且把strategy_money的值放入strategy_detail_str alter table bt_warning_bal add strategy_detail_str varchar2(40); comment on column bt_warning_bal.strategy_detail_str is '预警限额说明'; alter table bt_warning_cash add strategy_detail_str varchar2(40); comment on column bt_warning_cash.strategy_detail_str is '预警限额说明'; alter table bt_warning_payee add strategy_detail_str varchar2(40); comment on column bt_warning_payee.strategy_detail_str is '预警限额说明'; alter table bt_warning_largepay add strategy_detail_str varchar2(40); comment on column bt_warning_largepay.strategy_detail_str is '预警限额说明'; update bt_warning_bal set strategy_detail_str=strategy_money where strategy_detail_str is null; update bt_warning_cash set strategy_detail_str=strategy_money where strategy_detail_str is null; update bt_warning_payee set strategy_detail_str=strategy_money where strategy_detail_str is null; update bt_warning_largepay set strategy_detail_str=strategy_money where strategy_detail_str is null;
-- QUESTION #1: -- Create a new table in your database. -- Give it an auto-incrementing primary key, -- and one column each with the data type date, time, and decimal. CREATE TABLE labSeven ( id INT PRIMARY KEY AUTO_INCREMENT, date_values DATE, time_values TIME, decimal_values DECIMAL(6,2) ); -- QUESTION #2: -- Insert three rows, without explicitly adding a value to the primary key column. INSERT INTO labSeven ( date_values, time_values, decimal_values ) VALUES (NOW(), '21:18', 428.32), ('1985-10-17', '20:18', 69.69), ('1960-12-30', '2:00', 20.30); -- QUESTION #3: -- Replace one of the existing rows. REPLACE INTO labSeven ( id, date_values, time_values, decimal_values ) VALUES (1, NOW(), NOW(), 69.69); -- QUESTION #4: -- Update one (and only one) of the other rows. UPDATE labSeven SET decimal_values = 69.69 WHERE id = 4; -- QUESTION #5: -- Delete one row. DELETE FROM labSeven WHERE id = 1; -- QUESTION #6: -- Add a column. -- Make it so that this column will only accept whole numbers, -- and will not accept null values. ALTER TABLE labSeven ADD COLUMN whole_numbers INT NOT NULL; -- QUESTION #7: -- Rename this column. ALTER TABLE labSeven CHANGE whole_numbers new_whole_numbers INT NOT NULL; -- QUESTION #8: -- Give this column a default value. ALTER TABLE labSeven MODIFY new_whole_numbers INT NOT NULL DEFAULT 5; -- QUESTION #9: -- Delete a column. ALTER TABLE labSeven DROP COLUMN time_values; -- QUESTION #10: -- Delete your table. DROP TABLE labSeven;
SELECT FirstName FROM Employees WHERE (DepartmentID = 10 OR DepartmentID = 3) AND (HireDate BETWEEN '1995/01/01' AND '2005/12/31')
-- Criando sequences CREATE SEQUENCE db_plugin_db145_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; -- TABELAS E ESTRUTURA -- Módulo: configuracoes CREATE TABLE db_plugin( db145_sequencial int4 NOT NULL default 0, db145_nome varchar(200) NOT NULL , db145_label varchar(200) NOT NULL , db145_situacao bool , CONSTRAINT db_plugin_sequ_pk PRIMARY KEY (db145_sequencial)); -- Criando sequences CREATE SEQUENCE db_pluginitensmenu_db146_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; -- TABELAS E ESTRUTURA -- Módulo: configuracoes CREATE TABLE db_pluginitensmenu( db146_sequencial int4 NOT NULL default nextval('db_pluginitensmenu_db146_sequencial_seq'), db146_db_plugin int4 NOT NULL default 0, db146_db_itensmenu int4 default 0, CONSTRAINT db_pluginitensmenu_sequ_pk PRIMARY KEY (db146_sequencial)); -- CHAVE ESTRANGEIRA ALTER TABLE db_pluginitensmenu ADD CONSTRAINT db_pluginitensmenu_plugin_fk FOREIGN KEY (db146_db_plugin) REFERENCES db_plugin; ALTER TABLE db_pluginitensmenu ADD CONSTRAINT db_pluginitensmenu_itensmenu_fk FOREIGN KEY (db146_db_itensmenu) REFERENCES db_itensmenu; -- INDICES CREATE INDEX db_plugin_db146_db_itensmenu_in ON db_pluginitensmenu(db146_db_itensmenu); CREATE INDEX db_plugin_db146_db_plugin_in ON db_pluginitensmenu(db146_db_plugin); /** * -------------------------------------------------------------------------------------------------------------------- * TIME C INICIO * -------------------------------------------------------------------------------------------------------------------- */ -- Tarefa 87471 ALTER TABLE regraarredondamento ADD COLUMN ed316_casasdecimaisarredondamento int4 DEFAULT 1 NOT NULL; select nextval('regraarredondamento_ed316_sequencial_seq'); -- Tarefa 80922 alter table turmaturno rename TO turmaturnoadicional; CREATE SEQUENCE ensinoinfantil_ed117_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE TABLE ensinoinfantil( ed117_sequencial int4 NOT NULL default nextval('ensinoinfantil_ed117_sequencial_seq'), ed117_ensino int4 , CONSTRAINT ensinoinfantil_sequ_pk PRIMARY KEY (ed117_sequencial)); ALTER TABLE ensinoinfantil ADD CONSTRAINT ensinoinfantil_ensino_fk FOREIGN KEY (ed117_ensino) REFERENCES ensino; CREATE UNIQUE INDEX ensinoinfantil_ensino_in ON ensinoinfantil(ed117_ensino); CREATE SEQUENCE matriculaturnoreferente_ed337_codigo_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE SEQUENCE turmaturnoreferente_ed336_codigo_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE TABLE matriculaturnoreferente( ed337_codigo int4 NOT NULL default 0, ed337_matricula int4 NOT NULL default 0, ed337_turmaturnoreferente int4 NOT NULL default 0 ); CREATE TABLE turmaturnoreferente( ed336_codigo int4 NOT NULL default 0, ed336_turma int4 NOT NULL default 0, ed336_turnoreferente int4 NOT NULL default 0, ed336_vagas int4 default 0, CONSTRAINT turmaturnoreferente_codi_pk PRIMARY KEY (ed336_codigo)); ALTER TABLE turmaturnoreferente ADD CONSTRAINT turmaturnoreferente_turma_fk FOREIGN KEY (ed336_turma) REFERENCES turma; ALTER TABLE matriculaturnoreferente ADD CONSTRAINT matriculaturnoreferente_matricula_fk FOREIGN KEY (ed337_matricula) REFERENCES matricula; ALTER TABLE matriculaturnoreferente ADD CONSTRAINT matriculaturnoreferente_turmaturnoreferente_fk FOREIGN KEY (ed337_turmaturnoreferente) REFERENCES turmaturnoreferente; CREATE INDEX matriculaturnoreferente_matricula_turmaturnoreferente_in ON matriculaturnoreferente(ed337_matricula,ed337_turmaturnoreferente); CREATE INDEX turmaturnoreferente_turma_in ON turmaturnoreferente(ed336_turma); insert into turmaturnoreferente select nextval('turmaturnoreferente_ed336_codigo_seq'), ed57_i_codigo, ed231_i_referencia, ed57_i_numvagas from turma inner join turno on ed15_i_codigo = ed57_i_turno inner join turnoreferente on ed231_i_turno = ed15_i_codigo; insert into matriculaturnoreferente select nextval('matriculaturnoreferente_ed337_codigo_seq'), ed60_i_codigo, ed336_codigo from matricula inner join turmaturnoreferente on ed336_turma = ed60_i_turma; alter table turma drop column ed57_i_numvagas; alter table turma drop column ed57_i_nummatr; /** * -------------------------------------------------------------------------------------------------------------------- * TIME C FIM * -------------------------------------------------------------------------------------------------------------------- */ /** * -------------------------------------------------------------------------------------------------------------------- * TIME A INICIO * -------------------------------------------------------------------------------------------------------------------- */ -- Tarefa 84718 / Geração E-CONSIG create sequence econsigmovimento_rh133_sequencia_seq increment 1 minvalue 1 maxvalue 9223372036854775807 start 1 cache 1; create sequence econsigmovimentoservidor_rh134_sequencial_seq increment 1 minvalue 1 maxvalue 9223372036854775807 start 1 cache 1; create sequence econsigmovimentoservidorrubrica_rh135_sequencial_seq increment 1 minvalue 1 maxvalue 9223372036854775807 start 1 cache 1; create table econsigmovimento( rh133_sequencial int4 not null default 0, rh133_ano int4 not null , rh133_mes int4 not null , rh133_nomearquivo varchar(100) not null , rh133_instit int4, constraint econsigmovimento_sequencial_pk primary key (rh133_sequencial)); create table econsigmovimentoservidor( rh134_sequencial int4 not null default nextval('econsigmovimentoservidor_rh134_sequencial_seq'), rh134_econsigmovimento int4 not null , rh134_regist int4 , constraint econsigmovimentoservidor_sequencial_pk primary key (rh134_sequencial)); create table econsigmovimentoservidorrubrica( rh135_sequencial int4 not null default nextval('econsigmovimentoservidorrubrica_rh135_sequencial_seq'), rh135_econsigmovimentoservidor int4 not null , rh135_rubrica varchar(4) not null , rh135_instit int4, rh135_valor float4, constraint econsigmovimentoservidorrubrica_sequencial_pk primary key (rh135_sequencial)); alter table econsigmovimento add constraint econsigmovimento_instit_fk foreign key (rh133_instit) references db_config; alter table econsigmovimentoservidor add constraint econsigmovimentoservidor_econsigmovimento_fk foreign key (rh134_econsigmovimento) references econsigmovimento; alter table econsigmovimentoservidor add constraint econsigmovimentoservidor_regist_fk foreign key (rh134_regist) references rhpessoal; alter table econsigmovimentoservidorrubrica add constraint econsigmovimentoservidorrubrica_econsigmovimentoservidor_fk foreign key (rh135_econsigmovimentoservidor) references econsigmovimentoservidor; alter table econsigmovimentoservidorrubrica add constraint econsigmovimentoservidorrubrica_instit_fk foreign key (rh135_instit) references db_config; alter table econsigmovimentoservidorrubrica add constraint econsigmovimentoservidorrubrica_rubrica_instit_fk foreign key (rh135_rubrica,rh135_instit) references rhrubricas; create index econsigmovimento_sequencial_in on econsigmovimento(rh133_sequencial); CREATE SEQUENCE obrasalvarahistorico_ob35_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE TABLE obrasalvarahistorico( ob35_sequencial int4 NOT NULL default nextval('obrasalvarahistorico_ob35_sequencial_seq'), ob35_codobra int4 NOT NULL , ob35_datainicial date NOT NULL , ob35_datafinal date , CONSTRAINT obrasalvarahistorico_sequ_pk PRIMARY KEY (ob35_sequencial)); ALTER TABLE obrasalvarahistorico ADD CONSTRAINT obrasalvarahistorico_codobra_fk FOREIGN KEY (ob35_codobra) REFERENCES obras; CREATE UNIQUE INDEX obrasalvarahistorico_sequencial_in ON obrasalvarahistorico(ob35_sequencial); ALTER TABLE obrasalvara ADD COLUMN ob04_dataexpedicao date default null; /** * Migracao da coluna ob04_dataexpedicao. */ update obrasalvara set ob04_dataexpedicao = obrasalvara.ob04_data; /** * Adicionado campo de AnoUsu e Instit na tabela rhcontasrec */ ALTER TABLE rhcontasrec ADD COLUMN rh41_instit int4 NOT NULL default 0; ALTER TABLE rhcontasrec ADD COLUMN rh41_anousu int4 NOT NULL default 0; /* Migracao da tabela antiga. Faz backup depois atualiza os valores */ CREATE TABLE w_rhcontasrec AS SELECT * FROM rhcontasrec; UPDATE rhcontasrec SET rh41_anousu = novo.c61_anousu, rh41_instit = novo.c61_instit FROM (SELECT rh41_conta, rh41_codigo, max(c61_anousu) AS c61_anousu, max(c61_instit) AS c61_instit FROM rhcontasrec INNER JOIN saltes ON rh41_conta = k13_conta INNER JOIN conplanoreduz ON k13_reduz = c61_reduz WHERE c61_anousu <= 2014 GROUP BY rh41_conta, rh41_codigo) AS novo WHERE rhcontasrec.rh41_conta = novo.rh41_conta AND rhcontasrec.rh41_codigo = novo.rh41_codigo; /* Fim migracao */ ALTER TABLE rhcontasrec ADD CONSTRAINT rhcontasrec_instit_fk FOREIGN KEY (rh41_instit) REFERENCES db_config; drop index rhcontasrec_codigo_in; create unique index rhcontasrec_codigo_instit_anousu_in on rhcontasrec(rh41_codigo, rh41_instit, rh41_anousu); CREATE INDEX rhcontasrec_rh41_instit_in ON rhcontasrec(rh41_instit); CREATE INDEX rhcontasrec_rh41_conta_in ON rhcontasrec(rh41_conta); alter table rhcontasrec drop CONSTRAINT rhcontasrec_cont_codi_pk; alter table rhcontasrec add constraint "rhcontasrec_cont_codi_pk" PRIMARY KEY (rh41_conta, rh41_codigo, rh41_instit, rh41_anousu); -- Tarefa 73379 - Vistorias -- Criando sequences CREATE SEQUENCE tabativportetipcalc_q143_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; -- Módulo: issqn CREATE TABLE tabativportetipcalc( q143_sequencial int4 NOT NULL default nextval('tabativportetipcalc_q143_sequencial_seq'), q143_ativid int4 NOT NULL default 0, q143_issporte int8 NOT NULL default 0, q143_tipcalc int4 default 0, CONSTRAINT tabativportetipcalc_sequ_pk PRIMARY KEY (q143_sequencial)); -- CHAVE ESTRANGEIRA ALTER TABLE tabativportetipcalc ADD CONSTRAINT tabativportetipcalc_issporte_fk FOREIGN KEY (q143_issporte) REFERENCES issporte; ALTER TABLE tabativportetipcalc ADD CONSTRAINT tabativportetipcalc_ativid_fk FOREIGN KEY (q143_ativid) REFERENCES ativid; ALTER TABLE tabativportetipcalc ADD CONSTRAINT tabativportetipcalc_tipcalc_fk FOREIGN KEY (q143_tipcalc) REFERENCES tipcalc; -- INDICES CREATE INDEX tabativportetipcalc_tipcalc_in ON tabativportetipcalc(q143_tipcalc); CREATE INDEX tabativportetipcalc_issporte_in ON tabativportetipcalc(q143_issporte); CREATE INDEX tabativportetipcalc_ativid_in ON tabativportetipcalc(q143_ativid); ALTER TABLE parfiscal ADD COLUMN y32_utilizacalculoporteatividade bool default 'f'; -- Tarefa 85514 - Portaria Assintauras DROP TABLE IF EXISTS portariaassinatura CASCADE; DROP SEQUENCE IF EXISTS portariaassinatura_rh136_sequencial_seq; CREATE SEQUENCE portariaassinatura_rh136_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; alter table portaria add column h31_portariaassinatura int4 default null; -- Módulo: recursoshumanos CREATE TABLE portariaassinatura( rh136_sequencial int4 NOT NULL default nextval('portariaassinatura_rh136_sequencial_seq'), rh136_nome varchar(100) NOT NULL , rh136_cargo varchar(200) NOT NULL , rh136_amparo text , CONSTRAINT portariaassinatura_sequ_pk PRIMARY KEY (rh136_sequencial)); -- CHAVE ESTRANGEIRA ALTER TABLE portaria ADD CONSTRAINT portaria_portariaassinatura_fk FOREIGN KEY (h31_portariaassinatura) REFERENCES portariaassinatura; -- INDICES CREATE INDEX portaria_portariaassinatura_in ON portaria(h31_portariaassinatura); /** * -------------------------------------------------------------------------------------------------------------------- * TIME A FIM * -------------------------------------------------------------------------------------------------------------------- */ CREATE SEQUENCE tiporeferenciaalnumericofaixaidade_la59_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE SEQUENCE tiporeferenciaalnumericosexo_la60_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE SEQUENCE tiporeferenciacalculo_la61_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE TABLE tiporeferenciaalnumericofaixaidade( la59_sequencial int4 NOT NULL default 0, la59_tiporeferencialnumerico int4 NOT NULL default 0, la59_periodoinicial interval default null, la59_periodofinal interval , CONSTRAINT tiporeferenciaalnumericofaixaidade_sequ_pk PRIMARY KEY (la59_sequencial)); -- Módulo: laboratorio CREATE TABLE tiporeferenciaalnumericosexo( la60_sequencial int4 NOT NULL default 0, la60_tiporeferencialnumerico int4 NOT NULL default 0, la60_sexo char(1), CONSTRAINT tiporeferenciaalnumericosexo_sequ_pk PRIMARY KEY (la60_sequencial)); -- Módulo: laboratorio CREATE TABLE tiporeferenciacalculo( la61_sequencial int4 NOT NULL default 0, la61_tiporeferencialnumerico int4 NOT NULL default 0, la61_atributobase int4 NOT NULL default 0, la61_tipocalculo int4 NOT NULL default 0, CONSTRAINT tiporeferenciacalculo_sequ_pk PRIMARY KEY (la61_sequencial)); alter table lab_resultadonum add la41_valorpercentual float default null; alter table lab_resultadonum add la41_faixaescolhida integer; alter table lab_resultado add la52_diagnostico text; ALTER TABLE tiporeferenciaalnumericofaixaidade ADD CONSTRAINT tiporeferenciaalnumericofaixaidade_tiporeferencialnumerico_fk FOREIGN KEY (la59_tiporeferencialnumerico) REFERENCES lab_tiporeferenciaalnumerico; ALTER TABLE tiporeferenciaalnumericosexo ADD CONSTRAINT tiporeferenciaalnumericosexo_tiporeferencialnumerico_fk FOREIGN KEY (la60_tiporeferencialnumerico) REFERENCES lab_tiporeferenciaalnumerico; ALTER TABLE tiporeferenciacalculo ADD CONSTRAINT tiporeferenciacalculo_atributobase_fk FOREIGN KEY (la61_atributobase) REFERENCES lab_atributo; ALTER TABLE tiporeferenciacalculo ADD CONSTRAINT tiporeferenciacalculo_tiporeferencialnumerico_fk FOREIGN KEY (la61_tiporeferencialnumerico) REFERENCES lab_tiporeferenciaalnumerico; ALTER TABLE lab_tiporeferenciaalnumerico ADD CONSTRAINT lab_tiporeferencialnumerico_valorref_fk FOREIGN KEY (la30_i_valorref) references lab_valorreferencia; CREATE INDEX tiporeferenciaalnumericofaixaidade_referencia_in ON tiporeferenciaalnumericofaixaidade(la59_tiporeferencialnumerico); CREATE INDEX tiporeferenciaalnumericosexo_referencia_in ON tiporeferenciaalnumericosexo(la60_tiporeferencialnumerico); CREATE INDEX tiporeferenciacalculo_atributo_in ON tiporeferenciacalculo(la61_atributobase); CREATE INDEX tiporeferenciacalculo_referencia_in ON tiporeferenciacalculo(la61_tiporeferencialnumerico); CREATE INDEX lab_tiporeferenciaalnumerico_valorref_in on lab_tiporeferenciaalnumerico(la30_i_valorref);
drop procedure if exists itemsNotSold; DELIMITER // CREATE PROCEDURE itemsNotSold() BEGIN SELECT inventory.itemId, itemName FROM inventory LEFT JOIN purchased ON purchased.itemId = inventory.itemId WHERE purchased.itemId IS NULL; END // delimiter ;
select user.name as name, photo_post.createdAt as date, photo_post.description as description FROM mydb.photo_post left join mydb.user on photo_post.user_iduser = user.iduser where user.name = 'Chernyakov' order by createdAt asc;
Create Procedure sp_acc_UpdateServiceInwardBalance(@Invoiceid int,@Adjusted Decimal(18,2)) as Update ServiceAbstract Set Balance = Balance - @Adjusted Where InvoiceID = @Invoiceid
ALTER TABLE JOURNALPOST ADD COLUMN type VARCHAR
set SERVEROUTPUT on; BEGIN DBMS_OUTPUT.PUT_LINE('----FOR TRANSACTION----'); END; / --TRANSACTION MOVIE-- DECLARE user_id user_table.user_id%TYPE; quantity transaction_movie.quantity%type; selection_id slot_selection.selection_id%type; Begin user_id:='&user_id'; quantity:=&quantity; selection_id:='&selection_id'; insert_transaction_movie(quantity,user_id,selection_id); END; /
--Problem 11 SELECT DepositGroup ,IsDepositExpired ,AVG(DepositInterest) AS AverageInterest FROM WizzardDeposits WHERE DepositStartDate > '1985/01/01' GROUP BY DepositGroup,IsDepositExpired ORDER BY DepositGroup DESC,IsDepositExpired
INSERT INTO `materials` (`id`, `category`) VALUES (1, '18k'), (2, '14k'), (3, '9k'), (4, 'Silver'), (5, 'Platinum'), (6, 'Bi Colour with Gold'), (7, 'Three Colour with Gold'), (8, 'Black Metal');
USE CarFactory; ALTER TABLE Car_Engine ADD COLUMN assembly_days int; UPDATE Car_Engine SET assembly_days = 3 WHERE EngineId IN (3,4,5); UPDATE Car_Engine SET assembly_days = 1 WHERE EngineId IN (1); UPDATE Car_Engine SET assembly_days = 4 WHERE EngineId IN (2,6); ALTER TABLE Car_Engine MODIFY assembly_days int NOT NULL; SELECT * FROM Car_Engine;
/* Name: Amount of clicks to Berkshire web page ext Data source: 4 Created By: Admin Last Update At: 2016-02-19T14:09:44.960550+00:00 */ SELECT post_prop10, page_url, post_prop1, count(*) AS ExternalClicks FROM (TABLE_QUERY(djomniture:cipomniture_djmansionglobal,'CONCAT(REPLACE(table_id,"_","-"),"-01") BETWEEN STRFTIME_UTC_USEC("{{startdate}}", "%Y-%m-01") and STRFTIME_UTC_USEC("{{enddate}}", "%Y-%m-31")')) WHERE DATE(date_time) >= DATE('{{startdate}}') AND DATE('{{startdate}}') >= DATE('2015-02-01') AND DATE(date_time) <= DATE('{{enddate}}') AND post_prop75= 'article_page_berkshire_hathaway_widget' AND post_prop1 = 'article' GROUP BY post_prop10, page_url, post_prop1 ORDER BY ExternalClicks DESC
select `n_name` from `nation` where `n_nationkey` = 17 intersect select `n_name` from `nation` where `n_regionkey` = 1 union select `n_name` from `nation` where `n_regionkey` = 2
SELECT productName, productLine, productScale,productVendor from products WHERE productLine = "Classic Cars" OR productLine="Vintage Cars" ORDER By productLine DESC , productName ASC;
CREATE DATABASE exam_sql USE exam_sql CREATE TABLE Users( UserID char(5), FirstName varchar(255) NOT NULL, LastName varchar(255) NOT NULL, School varchar(255) NOT NULL, AddressUser varchar(255) NOT NULL, Email varchar(255) NOT NULL, PhoneNumber varchar(255) NOT NULL, LocationUser varchar(255) NOT NULL, DateOfBirth date NOT NULL, Gender varchar(6) NOT NULL, CONSTRAINT UsersPK PRIMARY KEY(UserID), CONSTRAINT UsersPKCheck CHECK(UserID like 'US[0-9][0-9][0-9]') ) select * from Users CREATE TABLE Posts( PostID char(5), postDate date, postContent varchar(255), UserID char(5), CONSTRAINT PostsPK PRIMARY KEY(PostID), CONSTRAINT PostsFK FOREIGN KEY(UserID) REFERENCES Users(UserID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT PostsPKCheck CHECK(PostID like 'PO[0-9][0-9][0-9]'), CONSTRAINT UsersFKCheck CHECK(UserID like 'US[0-9][0-9][0-9]') ) CREATE TABLE PostLikes( UserID char(5), PostID char(5), CONSTRAINT PostLikesFK1 FOREIGN KEY(UserID) REFERENCES Users(UserID) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT PostLikesFK2 FOREIGN KEY(PostID) REFERENCES Posts(PostID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT PostLikesFK1Check CHECK(PostID like 'PO[0-9][0-9][0-9]'), CONSTRAINT PostLikesFK2Check CHECK(UserID like 'US[0-9][0-9][0-9]') ) CREATE TABLE Shares( UserID char(5), PostID char(5), CONSTRAINT SharesFK1 FOREIGN KEY(UserID) REFERENCES Users(UserID) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT SharesFK2 FOREIGN KEY(PostID) REFERENCES Posts(PostID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT SharesFK1Check CHECK(PostID like 'PO[0-9][0-9][0-9]'), CONSTRAINT SharesFK2Check CHECK(UserID like 'US[0-9][0-9][0-9]') ) CREATE TABLE Photos( PhotoID char(5), PostID char(5), imageContent varchar(255), CONSTRAINT PhotosPK PRIMARY KEY(PhotoID), CONSTRAINT PhotosFK FOREIGN KEY(PostID) REFERENCES Posts(PostID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT PhotosPKCheck CHECK(PhotoID like 'PH[0-9][0-9][0-9]'), CONSTRAINT PhotosFKCheck CHECK(PostID like 'PO[0-9][0-9][0-9]') ) CREATE TABLE Comments( CommentID char(5), CommentContent varchar(255), UserID char(5), PostID char(5), CommentDate date, CONSTRAINT CommentsPK PRIMARY KEY(CommentID), CONSTRAINT CommentsFK1 FOREIGN KEY(UserID) REFERENCES Users(UserID) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT CommentsFK2 FOREIGN KEY(PostID) REFERENCES Posts(PostID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT CommentsPKCheck CHECK(CommentID like 'CO[0-9][0-9][0-9]'), CONSTRAINT CommentsFK1Check CHECK(UserID like 'US[0-9][0-9][0-9]'), CONSTRAINT CommentsFK2Check CHECK(PostID like 'PO[0-9][0-9][0-9]') ) CREATE TABLE CommentLikes( CommentID char(5), UserID char(5), CONSTRAINT CommentLikesFK1 FOREIGN KEY(CommentID) REFERENCES Comments(CommentID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT CommentLikesFK2 FOREIGN KEY(UserID) REFERENCES Users(UserID) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT CommentLikesFK1Check CHECK(CommentID like 'CO[0-9][0-9][0-9]'), CONSTRAINT CommentLikesFK2Check CHECK(UserID like 'US[0-9][0-9][0-9]') ) CREATE TABLE Friends( FriendID char(5), UserID char(5), CONSTRAINT FriendsPK PRIMARY KEY(FriendID), CONSTRAINT FriendsFK FOREIGN KEY(UserID) REFERENCES Users(UserID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT FriendsPKCheck CHECK(FriendID like 'FR[0-9][0-9][0-9]'), CONSTRAINT FriendsFKCheck CHECK(UserID like 'US[0-9][0-9][0-9]') ) CREATE TABLE Pages( PageID char(5), PageName varchar(255), pageContent varchar(255), CONSTRAINT PagesPK PRIMARY KEY(PageID), CONSTRAINT PagesPKCheck CHECK(PageID like 'PA[0-9][0-9][0-9]') ) CREATE TABLE PageLikes( UserID char(5), PageID char(5), CONSTRAINT PageLikesFK1 FOREIGN KEY(UserID) REFERENCES Users(UserID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT PageLikesFK2 FOREIGN KEY(PageID) REFERENCES Pages(PageID) ON UPDATE CASCADE ON DELETE SET NULL, CONSTRAINT PageLikesFK1Check CHECK(UserID like 'US[0-9][0-9][0-9]'), CONSTRAINT PageLikesFK2Check CHECK(PageID like 'PA[0-9][0-9][0-9]') )
-- 修改用户表,删除是否组织管理员字段,添加用户可见组织范围字段 ALTER TABLE `unified_user_access_control`.`user_info` DROP COLUMN `is_admin`, ADD COLUMN `view_root_code` VARCHAR(50) NULL COMMENT '用户可见组织范围-最高层组织编码' AFTER `gender`, ADD COLUMN `view_root_name` VARCHAR(200) NULL COMMENT '用户可见组织范围-最高层组织名称' AFTER `view_root_code`; -- 修改组织结构表,添加树级支持 ALTER TABLE `unified_user_access_control`.`organization` ADD COLUMN `left` INT NOT NULL DEFAULT 0 COMMENT '左侧节点-标示' AFTER `last_modify_time`, ADD COLUMN `right` INT NOT NULL DEFAULT 0 COMMENT '右侧节点标识' AFTER `left`; -- 修改角色表,添加树级支持 ALTER TABLE `unified_user_access_control`.`role_info` DROP COLUMN `role_path`, ADD COLUMN `left` INT NOT NULL DEFAULT 0 AFTER `last_modify_time`, ADD COLUMN `right` INT NOT NULL DEFAULT 0 AFTER `left`;
-- phpMyAdmin SQL Dump -- version 5.1.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Apr 21, 2021 at 03:38 PM -- Server version: 10.4.18-MariaDB -- PHP Version: 8.0.3 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: `root123` -- -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` int(3) NOT NULL, `name` text NOT NULL, `email` varchar(30) NOT NULL, `balance` int(8) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `name`, `email`, `balance`) VALUES (1, 'Sravya', 'sravya@gmail.com', 70000), (2, 'Aparna', 'aparna@gmail.com', 10000), (3, 'Christa', 'christa@gmail.com', 100000), (4, 'Nedya', 'nedya@gmail.com', 80000), (5, 'Nishana', 'nishana@gmail.com', 30000), (6, 'Namitha', 'namitha@gmail.com', 35000), (7, 'Tiya', 'tiya@gmail.com', 70000); -- -- Indexes for dumped tables -- -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(3) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; 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 */;
CREATE Procedure sp_acc_GetAmendedFACollection(@CollectionID Int) As Select CollectionDetail.OriginalID, CollectionDetail.DocumentDate, CollectionDetail.DocumentValue, CollectionDetail.AdjustedAmount, CollectionDetail.DocumentType, CollectionDetail.ExtraCollection, CollectionDetail.DocRef, CollectionDetail.Adjustment, CollectionDetail.DocumentID, dbo.LookupDictionaryItem('Credit Note',Default), CreditNote.Balance + CollectionDetail.AdjustedAmount + CollectionDetail.ExtraCollection + CollectionDetail.Adjustment, CreditNote.Memo From CollectionDetail, CreditNote Where CollectionDetail.CollectionID = @CollectionID And CollectionDetail.DocumentType = 2 And CreditNote.CreditID = CollectionDetail.DocumentID Union ALL Select CollectionDetail.OriginalID, CollectionDetail.DocumentDate, CollectionDetail.DocumentValue, CollectionDetail.AdjustedAmount, CollectionDetail.DocumentType, CollectionDetail.ExtraCollection, CollectionDetail.DocRef, CollectionDetail.Adjustment, CollectionDetail.DocumentID, dbo.LookupDictionaryItem('Collections',Default), Collections.Balance + CollectionDetail.AdjustedAmount + CollectionDetail.ExtraCollection + CollectionDetail.Adjustment, Collections.Narration From CollectionDetail, Collections Where CollectionDetail.CollectionID = @CollectionID And CollectionDetail.DocumentType = 3 And Collections.DocumentID = CollectionDetail.DocumentID Union ALL Select CollectionDetail.OriginalID, CollectionDetail.DocumentDate, CollectionDetail.DocumentValue, CollectionDetail.AdjustedAmount, CollectionDetail.DocumentType, CollectionDetail.ExtraCollection, CollectionDetail.DocRef, CollectionDetail.Adjustment, CollectionDetail.DocumentID,dbo.LookupDictionaryItem('APV',Default), APVAbstract.Balance + CollectionDetail.AdjustedAmount + CollectionDetail.ExtraCollection + CollectionDetail.Adjustment, APVAbstract.APVRemarks From CollectionDetail, APVAbstract Where CollectionDetail.CollectionID = @CollectionID And CollectionDetail.DocumentType = 6 And APVAbstract.DocumentID = CollectionDetail.DocumentID Union All Select CollectionDetail.OriginalID, CollectionDetail.DocumentDate, CollectionDetail.DocumentValue, CollectionDetail.AdjustedAmount, CollectionDetail.DocumentType, CollectionDetail.ExtraCollection, CollectionDetail.DocRef, CollectionDetail.Adjustment, CollectionDetail.DocumentID, dbo.LookupDictionaryItem('Debit Note',Default), DebitNote.Balance + CollectionDetail.AdjustedAmount + CollectionDetail.ExtraCollection + CollectionDetail.Adjustment, DebitNote.Memo From CollectionDetail, DebitNote Where CollectionDetail.CollectionID = @CollectionID And CollectionDetail.DocumentType = 5 And DebitNote.DebitID = CollectionDetail.DocumentID Union ALL Select CollectionDetail.OriginalID, CollectionDetail.DocumentDate, CollectionDetail.DocumentValue, CollectionDetail.AdjustedAmount, CollectionDetail.DocumentType, CollectionDetail.ExtraCollection, CollectionDetail.DocRef, CollectionDetail.Adjustment, CollectionDetail.DocumentID, dbo.LookupDictionaryItem('ARV',Default), ARVAbstract.Balance + CollectionDetail.AdjustedAmount + CollectionDetail.ExtraCollection + CollectionDetail.Adjustment, ARVAbstract.ARVRemarks From CollectionDetail, ARVAbstract Where CollectionDetail.CollectionID = @CollectionID And CollectionDetail.DocumentType = 4 And ARVAbstract.DocumentID = CollectionDetail.DocumentID Union ALL Select CollectionDetail.OriginalID, CollectionDetail.DocumentDate, CollectionDetail.DocumentValue, CollectionDetail.AdjustedAmount, CollectionDetail.DocumentType, CollectionDetail.ExtraCollection, CollectionDetail.DocRef, CollectionDetail.Adjustment, CollectionDetail.DocumentID, dbo.LookupDictionaryItem('Payments',Default), Payments.Balance + CollectionDetail.AdjustedAmount + CollectionDetail.ExtraCollection + CollectionDetail.Adjustment, Payments.Narration From CollectionDetail, Payments Where CollectionDetail.CollectionID = @CollectionID And CollectionDetail.DocumentType = 7 And Payments.DocumentID = CollectionDetail.DocumentID --Service Invoice Outward Union ALL Select CollectionDetail.OriginalID, CollectionDetail.DocumentDate, CollectionDetail.DocumentValue, CollectionDetail.AdjustedAmount, CollectionDetail.DocumentType, CollectionDetail.ExtraCollection, CollectionDetail.DocRef, CollectionDetail.Adjustment, CollectionDetail.DocumentID, dbo.LookupDictionaryItem('Service Outward',Default), ServiceAbstract.Balance + CollectionDetail.AdjustedAmount + CollectionDetail.ExtraCollection + CollectionDetail.Adjustment, ServiceAbstract.ReferenceDescription From CollectionDetail, ServiceAbstract Where CollectionDetail.CollectionID = @CollectionID And CollectionDetail.DocumentType = 153 And ServiceAbstract.InvoiceID = CollectionDetail.DocumentID
drop table member; create table member ( no number(10) primary key, name varchar(20 char), regdate date ); select table_name from user_tables; select * from member; insert into member (no, name, regdate) values (20, 'xxx', '2020/11/11'); delete from member; commit;
CREATE ROLE [PASAgreementGovernmentAffairs]
CREATE TABLE selective_courses_year_parameters( id SERIAL PRIMARY KEY, first_round_start_date TIMESTAMP NOT NULL, first_round_end_date TIMESTAMP NOT NULL, second_round_start_date TIMESTAMP NOT NULL, second_round_end_date TIMESTAMP NOT NULL, study_year INTEGER NOT NULL, bachelor_general_min_students_count INTEGER NOT NULL, bachelor_professional_min_students_count INTEGER NOT NULL, master_general_min_students_count INTEGER NOT NULL, master_professional_min_students_count INTEGER NOT NULL, phd_general_min_students_count INTEGER NOT NULL, phd_professional_min_students_count INTEGER NOT NULL, max_students_count INTEGER NOT NULL ); ALTER TABLE selective_courses_year_parameters ADD CONSTRAINT uk_sc_year_parameters_fr_start_date UNIQUE(first_round_start_date); ALTER TABLE selective_courses_year_parameters ADD CONSTRAINT uk_sc_year_parameters_fr_end_date UNIQUE(first_round_end_date); ALTER TABLE selective_courses_year_parameters ADD CONSTRAINT uk_sc_year_parameters_sr_start_date UNIQUE(second_round_start_date); ALTER TABLE selective_courses_year_parameters ADD CONSTRAINT uk_sc_year_parameters_sr_end_date UNIQUE(second_round_end_date); ALTER TABLE selective_courses_year_parameters ADD CONSTRAINT uk_sc_year_parameters_study_year UNIQUE(study_year);
SELECT id, effort_name, effort_primary_species, effort_status, effort_purpose, effort_agency FROM efforts WHERE id = ${id};
#------------------------------------------------------------ # Script MySQL. #------------------------------------------------------------ #------------------------------------------------------------ # Table: Editor #------------------------------------------------------------ CREATE TABLE Editor( ID Int Auto_increment NOT NULL , Name Varchar (50) NOT NULL ,CONSTRAINT Editor_PK PRIMARY KEY (ID) )ENGINE=InnoDB; #------------------------------------------------------------ # Table: Manga #------------------------------------------------------------ CREATE TABLE Manga( ID Int Auto_increment NOT NULL , Name Varchar (50) NOT NULL , Author Varchar (50) NOT NULL , ReleaseDate Date NOT NULL , AgeLimit Int NOT NULL , Genre Varchar (50) NOT NULL , photo Varchar (250) NOT NULL , StreamingLink Varchar (250) NOT NULL , Synopsis Varchar (250) NOT NULL , ID_Editor Int NOT NULL ,CONSTRAINT Manga_PK PRIMARY KEY (ID) ,CONSTRAINT Manga_Editor_FK FOREIGN KEY (ID_Editor) REFERENCES Editor(ID) )ENGINE=InnoDB; #------------------------------------------------------------ # Table: Volume #------------------------------------------------------------ CREATE TABLE Volume( ID Int Auto_increment NOT NULL , Number Int NOT NULL , Name Varchar (50) NOT NULL , Edition Varchar (50) NOT NULL , ID_Manga Int NOT NULL ,CONSTRAINT Volume_PK PRIMARY KEY (ID) ,CONSTRAINT Volume_Manga_FK FOREIGN KEY (ID_Manga) REFERENCES Manga(ID) )ENGINE=InnoDB; #------------------------------------------------------------ # Table: Chapter #------------------------------------------------------------ CREATE TABLE Chapter( ID Int Auto_increment NOT NULL , Title Varchar (50) NOT NULL , Number Int NOT NULL , photo Varchar (50) NOT NULL , ID__Volume Int NOT NULL ,CONSTRAINT Chapter_PK PRIMARY KEY (ID) ,CONSTRAINT Chapter_Volume_FK FOREIGN KEY (ID__Volume) REFERENCES Volume(ID) )ENGINE=InnoDB; #------------------------------------------------------------ # Table: User #------------------------------------------------------------ CREATE TABLE User( ID Int Auto_increment NOT NULL , Firstame Varchar (50) NOT NULL , Password Varchar (50) NOT NULL , Login Varchar (50) NOT NULL , photo Varchar (50) NOT NULL ,CONSTRAINT User_PK PRIMARY KEY (ID) )ENGINE=InnoDB; #------------------------------------------------------------ # Table: Pages #------------------------------------------------------------ CREATE TABLE Pages( ID Int Auto_increment NOT NULL , Number Int NOT NULL , photo Varchar (50) NOT NULL , ID_Chapter Int NOT NULL ,CONSTRAINT Pages_PK PRIMARY KEY (ID) ,CONSTRAINT Pages_Chapter_FK FOREIGN KEY (ID_Chapter) REFERENCES Chapter(ID) )ENGINE=InnoDB;
SELECT empno, ename, sal FROM employees WHERE sal >= (SELECT sal FROM employees WHERE empno = 1003) /
DROP TABLE IF EXISTS Users; DROP TABLE IF EXISTS Kingdoms; DROP TABLE IF EXISTS Villages; DROP TABLE IF EXISTS Variables; PRAGMA foreign_keys = ON; CREATE TABLE Users ( uid text, username text, doubloons int, rank int, rumpus_count int, block int, tax_collected int, kid text, PRIMARY KEY (uid), FOREIGN KEY (kid) REFERENCES Kingdoms ); CREATE TABLE Kingdoms ( kid text, k_name text, attack int, defence int, been_attacked int, has_attacked int, uid text NOT NULL, PRIMARY KEY (kid), FOREIGN KEY (uid) REFERENCES Users ON DELETE NO ACTION ); CREATE TABLE Villages ( vid text, v_name text, population int, kid text NOT NULL, PRIMARY KEY (vid), FOREIGN KEY (kid) REFERENCES Kingdoms ); CREATE TABLE Variables ( name text, value real, PRIMARY KEY (name) ); INSERT INTO Variables VALUES ('tax_rate', 1.0);
--Création de la base de données webDevelopment avec l'encodage UTF-8 CREATE DATABASE `webDevelopment` CHARACTER SET 'utf8';
SELECT TOP 10 total_elapsed_time/1000.0 as total_elapsed_time ,execution_count ,(total_elapsed_time/execution_count)/1000.0 AS [avg_elapsed_time_ms] ,last_elapsed_time/1000.0 as last_elapsed_time ,total_logical_reads/execution_count AS [avg_logical_reads] ,st.Query ,qp.query_plan ,qs.plan_handle FROM sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) as qp CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st1 CROSS APPLY ( SELECT REPLACE ( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( CONVERT ( NVARCHAR(MAX), N'--' + NCHAR(13) + NCHAR(10) + ist.text + NCHAR(13) + NCHAR(10) + N'--' COLLATE Latin1_General_Bin2 ) ,NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?') ,NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?') ,NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?') ,NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?') ,NCHAR(12),N'?'),NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?') ,NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?') ,NCHAR(0),N'' ) AS [processing-instruction(query)] FROM sys.dm_exec_sql_text(qs.sql_handle) AS ist FOR XML PATH(''), TYPE ) AS st(Query) WHERE st1.text like '%sys.sql_modules%' ORDER BY last_elapsed_time DESC;
CREATE DATABASE IF NOT EXISTS `workouts`; USE `workouts`; /* TODO Add proper CONSTRAINTs to the tables. */ /* TODO Revisit primary keys. */ DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `email` varchar(128) DEFAULT NULL, `password` varchar(128) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `sessions`; CREATE TABLE `sessions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `key` varchar(128) NOT NULL, `value` varchar(128) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; /* This table contains exercise definitions. */ DROP TABLE IF EXISTS `exercises`; CREATE TABLE `exercises` ( `id` INT(10) unsigned NOT NULL AUTO_INCREMENT, `title` VARCHAR(128), `default_sets` INT(1) unsigned DEFAULT 0, `default_reps` INT(1) unsigned DEFAULT 0, `wait_time` INT(2) unsigned DEFAULT 0, `category` ENUM('warm', 'pull', 'push', 'legs', 'core') DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; /* This table holds workouts started by a user */ DROP TABLE IF EXISTS `workouts`; CREATE TABLE `workouts` ( `id` INT(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `start` DATETIME NULL, `end` DATETIME NULL, `notes` VARCHAR(1024), `feel` ENUM('weak', 'average', 'strong') DEFAULT 'average', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; /* This table contains exercises completed during a workout */ DROP TABLE IF EXISTS `entries`; CREATE TABLE `entries` ( `id` INT(10) unsigned NOT NULL AUTO_INCREMENT, `exercises_id` int(10) unsigned NOT NULL, `workout_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `sets` int(1) unsigned DEFAULT 0, `feedback` ENUM('up', 'down', 'none') DEFAULT 'none', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `reps`; CREATE TABLE `reps` ( `id` INT(10) unsigned NOT NULL AUTO_INCREMENT, `entries_id` int(10) unsigned NOT NULL, `amount` varchar(8), PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
■問題 以下は、書籍目次テーブル(contents)から現在のコンテンツコードと前のコンテンツコードを、 現在のコンテンツコードについて昇順に取り出すためのSQLですが、誤りが2点あります。誤りを指摘してください。 SELECT cp.c_id AS 前のページ, cn.c_id AS 現在のページ FROM contents AS cp OUTER JOIN contents AS cn ON cp.next_id <> cn.c_id ORDER BY cn.c_id ASC ; ■実行文 指摘事項1:OUTER JOINではなくINNER JOINが正しい 指摘事項2:cp.next_id <> cn.c_idではなくcp.next_id = cn.c_idとすべき # 現在のコンテンツコードと前のコンテンツコードを取得 SELECT cp.c_id AS 前のページ, cn.c_id AS 現在のページ # 書籍目次テーブルをコンテンツIDとNEXTコンテンツIDで自己結合した値から取得 FROM contents AS cp INNER JOIN contents AS cn ON cp.next_id = cn.c_id # 現在のコンテンツコードについて昇順に取得 ORDER BY cn.c_id ASC ; ■返却値 mysql> SELECT -> cp.c_id AS 前のページ, -> cn.c_id AS 現在のページ -> FROM -> contents AS cp -> INNER JOIN -> contents AS cn -> ON -> cp.next_id = cn.c_id -> ORDER BY -> cn.c_id ASC -> ; +------------+--------------+ | 前のページ | 現在のページ | +------------+--------------+ | A001 | A011 | | A011 | A012 | | A012 | A013 | | A013 | A014 | | A014 | A015 | | A015 | A016 | | A016 | A017 | | A017 | A021 | | A021 | A022 | | A022 | A023 | | A023 | A024 | | A024 | A025 | | A025 | A026 | | A026 | A027 | | A027 | A028 | | A028 | A029 | | A029 | A031 | | A031 | A032 | | A032 | A033 | | A033 | A034 | | A034 | A035 | | A035 | A036 | | A036 | A037 | | A037 | A041 | | A041 | A042 | | A042 | A043 | | A043 | A044 | | A044 | A045 | | A045 | A046 | +------------+--------------+ 29 rows in set (0.01 sec)
-- +migrate Up ALTER TABLE repos ADD COLUMN repo_config_path TEXT; ALTER TABLE builds ADD COLUMN build_reviewer TEXT; ALTER TABLE builds ADD COLUMN build_reviewed INTEGER; ALTER TABLE builds ADD COLUMN build_sender TEXT; UPDATE repos SET repo_config_path = '.drone.yml'; UPDATE builds SET build_reviewer = ''; UPDATE builds SET build_reviewed = 0; UPDATE builds SET build_sender = ''; -- +migrate Down ALTER TABLE repos DROP COLUMN repo_config_path; ALTER TABLE builds DROP COLUMN build_reviewer; ALTER TABLE builds DROP COLUMN build_reviewed; ALTER TABLE builds DROP COLUMN build_sender;
# Write your MySQL query statement below select a.id from Weather as a join Weather as b where a.temperature > b.temperature and dateDiff(a.recordDate,b.recordDate) = 1
DELIMITER $$ create procedure eliminarCabania (_cuil int) begin delete from cabania where cuil=_cuil; end$$ DELIMITER $$ create procedure eliminarCliente (_cuit int) begin delete from cliente where cuit=_cuit; end$$ DELIMITER $$ create procedure eliminarDomicilio (_idDomicilio int) begin delete from domicilio where idDomicilio=_idDomicilio; end$$ DELIMITER $$ create procedure eliminarFactura (_idFactura int) begin delete from factura where idFactura=_idFactura; end$$ DELIMITER $$ create procedure eliminarFacturaProducto (_factura int, _producto int) begin delete from factura_has_producto where factura=_factura and producto=_producto; end$$ DELIMITER $$ create procedure eliminarGalpon (_numero int) begin delete from galpon where numero=_numero; end$$ DELIMITER $$ create procedure eliminarGenetica (_codigo int) begin delete from genetica where codigo=_codigo; end$$ DELIMITER $$ create procedure eliminarPlanilla (_idPlanilla int) begin delete from planilla where idPlanilla=_idPlanilla; end$$ DELIMITER $$ create procedure eliminarPlantel (_codigo int) begin delete from plantel where codigo=_codigo; end$$ DELIMITER $$ create procedure eliminarProducto (_codigo int) begin delete from producto where codigo=_codigo; end$$
select sub.prio from ( select sel.prio as prio, count(distinct issue_id) as cnt from ( select distinct issue_id, substring(dup_label_name from '(?i)priority/(.*)') as prio from gha_issues_labels ) sel where sel.prio is not null group by prio order by cnt desc, prio asc limit {{lim}} ) sub union select 'All' ;
-- sample SQL statements for the digi_m_auth CREATE TABLE digi_m_auth ( id int not null PRIMARY KEY, created int, updated , creator int, updater int, orderid int, parentid int, nodeid int, rolename varchar(255), username varchar(255), password varchar(255), )
select FirstName, LastName, EmployeeId from Employee where Title LIKE 'Sale%';
DELETE FROM open_street_next a USING open_street_next b WHERE a.cartodb_id < b.cartodb_id AND a.segmentid = b.segmentid AND a.segmentid <> '0000000'; --enforce whatever we started with as schema changes at DOT and open data alter table open_street_next rename column open_date TO date_open_; alter table open_street_next add constraint open_street_nextthe_geomsimple CHECK (ST_IsSimple(the_geom::geometry)); alter table open_street_next add constraint open_street_nextthe_geomvalid CHECK (ST_IsValid(the_geom::geometry));
create table POSITION ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into position(id, code) values (0, 'Начальник цеха'); insert into position(id, code) values (1, 'Мастер'); insert into position(id, code) values (2, 'Старший мастер'); insert into position(id, code) values (3, 'Зам. мастера'); insert into position(id, code) values (4, 'Технолог'); insert into position(id, code) values (5, 'Фрезеровщик'); insert into position(id, code) values (6, 'Фрезеровщик I разряда'); insert into position(id, code) values (7, 'Рабочий'); create table user ( id BIGINT primary key auto_increment, name VARCHAR(100) not null, position_id BIGINT, type NUMBER default 0 ); insert into user (id, name, position_id) values (0, 'Андрей Геннадьевич', 0); insert into user (id, name, position_id) values (1, 'Абрам Альбертович', 0); insert into user (id, name, position_id) values (10, 'Петрович', 1); insert into user (id, name, position_id) values (11, 'Иваныч', 1); insert into user (id, name, position_id) values (12, 'Георгич', 1); insert into user (id, name, position_id) values (13, 'Палыч', 1); insert into user (id, name, position_id) values (14, 'Петровна', 1); insert into user (id, name, position_id) values (15, 'Львовна', 1); insert into user (id, name, position_id) values (16, 'Ильинична', 1); insert into user (id, name, position_id) values (17, 'Петровна', 1); insert into user (id, name, position_id) values (18, 'Санна', 1); insert into user (id, name, position_id) values (19, 'Батьковна', 1); insert into user (id, name, position_id) values (100, 'Рабочий 100', 7); insert into user (id, name, position_id) values (101, 'Рабочий 101', 7); insert into user (id, name, position_id) values (102, 'Рабочий 102', 7); insert into user (id, name, position_id) values (103, 'Рабочий 103', 7); insert into user (id, name, position_id) values (104, 'Рабочий 104', 7); insert into user (id, name, position_id) values (105, 'Рабочий 105', 7); insert into user (id, name, position_id) values (106, 'Рабочий 106', 7); insert into user (id, name, position_id) values (107, 'Рабочий 107', 7); insert into user (id, name, position_id) values (108, 'Рабочий 108', 7); insert into user (id, name, position_id) values (109, 'Рабочий 109', 7); insert into user (id, name, position_id) values (110, 'Рабочий 110', 7); insert into user (id, name, position_id) values (111, 'Рабочий 111', 7); insert into user (id, name, position_id) values (112, 'Рабочий 112', 7); insert into user (id, name, position_id) values (113, 'Рабочий 113', 7); insert into user (id, name, position_id) values (114, 'Рабочий 114', 7); insert into user (id, name, position_id) values (115, 'Рабочий 115', 7); insert into user (id, name, position_id) values (116, 'Рабочий 116', 7); insert into user (id, name, position_id) values (117, 'Рабочий 117', 7); insert into user (id, name, position_id) values (118, 'Рабочий 118', 7); insert into user (id, name, position_id) values (119, 'Рабочий 119', 7); insert into user (id, name, position_id) values (120, 'Рабочий 120', 7); insert into user (id, name, position_id) values (121, 'Рабочий 121', 7); insert into user (id, name, position_id) values (122, 'Рабочий 122', 7); insert into user (id, name, position_id) values (123, 'Рабочий 123', 7); insert into user (id, name, position_id) values (124, 'Рабочий 124', 7); insert into user (id, name, position_id) values (125, 'Рабочий 125', 7); insert into user (id, name, position_id) values (126, 'Рабочий 126', 7); insert into user (id, name, position_id) values (127, 'Рабочий 127', 7); insert into user (id, name, position_id) values (128, 'Рабочий 128', 7); insert into user (id, name, position_id) values (129, 'Рабочий 129', 7); insert into user (id, name, position_id) values (130, 'Рабочий 130', 7); insert into user (id, name, position_id) values (131, 'Рабочий 131', 7); insert into user (id, name, position_id) values (132, 'Рабочий 132', 7); insert into user (id, name, position_id) values (133, 'Рабочий 133', 7); insert into user (id, name, position_id) values (134, 'Рабочий 134', 7); insert into user (id, name, position_id) values (135, 'Рабочий 135', 7); insert into user (id, name, position_id) values (136, 'Рабочий 136', 7); insert into user (id, name, position_id) values (137, 'Рабочий 137', 7); insert into user (id, name, position_id) values (138, 'Рабочий 138', 7); insert into user (id, name, position_id) values (139, 'Рабочий 139', 7); insert into user (id, name, position_id) values (140, 'Рабочий 140', 7); insert into user (id, name, position_id) values (141, 'Рабочий 141', 7); insert into user (id, name, position_id) values (142, 'Рабочий 142', 7); insert into user (id, name, position_id) values (143, 'Рабочий 143', 7); insert into user (id, name, position_id) values (144, 'Рабочий 144', 7); insert into user (id, name, position_id) values (145, 'Рабочий 145', 7); insert into user (id, name, position_id) values (146, 'Рабочий 146', 7); insert into user (id, name, position_id) values (147, 'Рабочий 147', 7); insert into user (id, name, position_id) values (148, 'Рабочий 148', 7); insert into user (id, name, position_id) values (149, 'Рабочий 149', 7); insert into user (id, name, type) values (20, 'Мастера цеха 0', 1); insert into user (id, name, type) values (21, 'Мастера цеха 1', 1); insert into user (id, name, type) values (22, 'Мастера цеха 2', 1); insert into user (id, name, type) values (23, 'Мастера цеха 3', 1); insert into user (id, name, type) values (24, 'Мастера цеха 4', 1); create table UserGroup ( group_id bigint not null, user_id bigint not null ); insert into UserGroup (group_id, user_id) values (20, 10); insert into UserGroup (group_id, user_id) values (20, 11); insert into UserGroup (group_id, user_id) values (21, 12); insert into UserGroup (group_id, user_id) values (21, 13); insert into UserGroup (group_id, user_id) values (22, 14); insert into UserGroup (group_id, user_id) values (22, 15); insert into UserGroup (group_id, user_id) values (23, 16); insert into UserGroup (group_id, user_id) values (23, 17); insert into UserGroup (group_id, user_id) values (24, 18); insert into UserGroup (group_id, user_id) values (24, 19); create table taskgroup ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into taskgroup(id, code) values (0, 'Постоянная задача'); insert into taskgroup(id, code) values (1, 'Периодическая задача'); create table TASKTYPE ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into TASKTYPE(id, code) values (0, 'Информационное сообщение'); insert into TASKTYPE(id, code) values (1, 'Поручение: организационное'); insert into TASKTYPE(id, code) values (2, 'Поручение: технологическое'); insert into TASKTYPE(id, code) values (3, 'Поручение: техническое'); create table STATUSTYPE ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into STATUSTYPE(id, code) values (0, 'Новая'); insert into STATUSTYPE(id, code) values (1, 'В работе'); insert into STATUSTYPE(id, code) values (2, 'Простаивает'); insert into STATUSTYPE(id, code) values (3, 'Выполнено'); insert into STATUSTYPE(id, code) values (4, 'Ознакомлен'); insert into STATUSTYPE(id, code) values (5, 'Отменена'); create table reaction ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into reaction(id, code) values (0, 'Принято к сведению'); insert into reaction(id, code) values (1, 'Взял в работу'); insert into reaction(id, code) values (2, 'Конфликт выполнения'); insert into reaction(id, code) values (3, 'Отказано'); create table department ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into department(id, code) values (0, 'Цех 0'); insert into department(id, code) values (1, 'Цех 1'); insert into department(id, code) values (2, 'Цех 2'); insert into department(id, code) values (3, 'Цех 3'); insert into department(id, code) values (4, 'Цех 4'); create table housing ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into housing(id, code) values (0, 'Корпус 0'); insert into housing(id, code) values (1, 'Корпус 1'); insert into housing(id, code) values (2, 'Корпус 2'); insert into housing(id, code) values (3, 'Корпус 3'); insert into housing(id, code) values (4, 'Корпус 4'); insert into housing(id, code) values (5, 'Корпус 5'); insert into housing(id, code) values (6, 'Корпус 6'); insert into housing(id, code) values (7, 'Корпус 7'); insert into housing(id, code) values (8, 'Корпус 8'); insert into housing(id, code) values (9, 'Корпус 9'); insert into housing(id, code) values (10, 'Корпус 10'); insert into housing(id, code) values (11, 'Корпус 11'); create table DepartmentHousing ( department_id bigint not null, housing_id bigint not null ); insert into DepartmentHousing(department_id, housing_id) values (0, 0); insert into DepartmentHousing(department_id, housing_id) values (0, 1); insert into DepartmentHousing(department_id, housing_id) values (1, 2); insert into DepartmentHousing(department_id, housing_id) values (1, 3); insert into DepartmentHousing(department_id, housing_id) values (2, 4); insert into DepartmentHousing(department_id, housing_id) values (2, 5); insert into DepartmentHousing(department_id, housing_id) values (2, 10); insert into DepartmentHousing(department_id, housing_id) values (3, 6); insert into DepartmentHousing(department_id, housing_id) values (3, 7); insert into DepartmentHousing(department_id, housing_id) values (4, 8); insert into DepartmentHousing(department_id, housing_id) values (4, 9); insert into DepartmentHousing(department_id, housing_id) values (4, 11); create table priority ( id BIGINT primary key auto_increment, code VARCHAR(100) ); insert into priority(id, code) values (0, 'Очень срочно'); insert into priority(id, code) values (1, 'Срочно'); insert into priority(id, code) values (2, 'Обычно'); insert into priority(id, code) values (3, 'Нормально'); insert into priority(id, code) values (4, 'Не срочно'); insert into priority(id, code) values (5, 'Очень не срочно'); create table Task ( id BIGINT primary key auto_increment, type_id BIGINT not null, assignee_id BIGINT, dateTo TIMESTAMP, dateFact TIMESTAMP, tstmpCreate TIMESTAMP default CURRENT_TIMESTAMP, author_id BIGINT, header VARCHAR(250), info VARCHAR(2500), status_id BIGINT DEFAULT 0, priority_id BIGINT, parent_id BIGINT, group_id bigint, reaction_id bigint ); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id) values ( 1, 0, 10, PARSEDATETIME('29.11.2020 00:00:00','dd.MM.yyyy hh:mm:ss','en'), null, 0, 'Осмотреть фрезеровальный станок', 'осмотреть фрезеровальный станок 6Т13 на предмет износа', 1, 0, 0); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, parent_id) values ( 2, 0, 100, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 10, 'Создание подзадач для рабочих', 'Будет создано 13 задач', 1, 1); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id) values ( 3, 3, 11, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'Проверить устойчивость детали 355332', 'Проверить устойчивость детали 355332 к устойчивости на температурные и вибрационные воздействия', 1, 1); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, parent_id) values ( 4, 3, 110, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 11, 'Проверить устойчивость детали 355332', 'установка оснастки для температурных испытаний детали 355332 к устойчивости на температурные и вибрационные воздействия', 1, 3); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id) values ( 7, 0, 11, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'Проверить устойчивость детали 234', 'Проверить устойчивость детали 234 к устойчивости на температурные и вибрационные воздействия', 3, 0, 0); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id) values ( 10, 0, 11, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'Проверка детали 3312', 'Проверить устойчивость детали 3312 к устойчивости на температурные и вибрационные воздействия', 3, 0, 0); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id) values ( 8, 0, 11, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'Установить деталь М2-631 в корпус', 'Установить деталь М2-631 в корпус', 2, 0, 0); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id) values ( 9, 0, 11, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'Провести вибрационные испытания в рамках ОКР Зима-К', 'Провести вибрационные испытания в рамках ОКР Зима-К', 4, 0, 0); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id) values ( 11, 0, 13, PARSEDATETIME('29.11.2020 00:00:00','dd.MM.yyyy hh:mm:ss','en'), null, 0, 'Заполнить журнал техники безопасности', 'заполнить журнал ТБ за смену', 3, 0, 0); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id) values ( 12, 3, 13, PARSEDATETIME('29.11.2020 00:00:00','dd.MM.yyyy hh:mm:ss','en'), null, 0, 'Провести обучение сотрудников', 'Провести обучение сотрудников по работе с ПО "Призма"', 3, 0, 0); insert into Task (id, type_id, assignee_id, dateTo, dateFact, author_id, header, info, priority_id, group_id, reaction_id, parent_id) values ( 13, 2, 11, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'Провести обучение сотрудников', 'Собрать сотрудников в конференц-зале сегодня в 15:00 ', 4, 0, 0, 12); create table comment ( id BIGINT primary key auto_increment, task_id bigint not null, author_id bigint not null, content varchar(1500) not null, tstmpCreate timestamp default CURRENT_TIMESTAMP, closing boolean default false ); insert into comment(id, task_id, author_id, content) values (1, 1, 10, 'так точно!'); create table attachment ( id BIGINT primary key auto_increment, task_id bigint, tstmpCreate TIMESTAMP default CURRENT_TIMESTAMP, author_id bigint, name varchar(150), content blob, url varchar(1500), comment_id bigint ); insert into attachment(task_id, author_id, name, content, url) values (1, 10, 'картинка.png', '032348762039847629837603874602', 'https://img5.lalafo.com/i/posters/original/3e/c6/aa50cf11f4b04cbf4790cee7169f.jpeg'); insert into attachment(comment_id, author_id, name, content, url) values (1, 10, 'картинка.png', '032348762039847629837603874602', 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTAQRPJxJzJVjGKhKu77fWr1jL1i5C-tlrudQ&usqp=CAU'); create table userhousing ( id BIGINT primary key auto_increment, user_id BIGINT not null, housing_id BIGINT not null, document_id BIGINT not null ); create table document ( id BIGINT not null, name VARCHAR(250) not null, date DATE not null, author_id bigint, tstmpCreate timestamp default current_timestamp, content blob );
-- Jul 6, 2008 10:30:49 AM EST -- Default comment for updating dictionary UPDATE AD_Column SET Callout='org.eevolution.model.CalloutBOM.getdefaults',Updated=TO_TIMESTAMP('2008-07-06 10:30:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53333 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=30,IsDisplayed='Y' WHERE AD_Field_ID=53474 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=40,IsDisplayed='Y' WHERE AD_Field_ID=53475 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=50,IsDisplayed='Y' WHERE AD_Field_ID=53464 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y' WHERE AD_Field_ID=53476 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=53465 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=53466 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=53467 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=53468 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=53469 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=53470 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=53471 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=140,IsDisplayed='Y' WHERE AD_Field_ID=53472 ; -- Jul 6, 2008 10:44:22 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=53473 ; -- Jul 6, 2008 10:44:59 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET IsSameLine='Y',Updated=TO_TIMESTAMP('2008-07-06 10:44:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=53476 ; -- Jul 6, 2008 10:46:09 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET IsCentrallyMaintained='Y',Updated=TO_TIMESTAMP('2008-07-06 10:46:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=53474 ; -- Jul 6, 2008 10:46:15 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET IsCentrallyMaintained='Y',Updated=TO_TIMESTAMP('2008-07-06 10:46:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=53476 ; -- Jul 6, 2008 10:50:46 AM EST -- Default comment for updating dictionary UPDATE AD_Field SET DisplayLength=22,Updated=TO_TIMESTAMP('2008-07-06 10:50:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=53464 ;
SELECT * FROM pcinnovations.carousel
Create Procedure mERP_sp_InsertRecdTLTypeDetail( @RecdID int, @TLTypeDesc nVarchar(1000), @Active int, @ReportFlag int) As Insert into tbl_mERP_RecdTLTypeDetail(RecdID, TLType_Desc, Active, ReportFlag ) Values (@RecdID, @TLTypeDesc, @Active, @ReportFlag)
/** * Arquivo ddl up */ ---------------------------------------------------- ---- TIME FOLHA DE PAGAMENTO ---------------------------------------------------- ---- Tarefa: 96909 ---------------------------------------------------- -- Insert de valor para a tabela thtipofolha INSERT INTO rhtipofolha VALUES(6, 'Suplementar'); ---------------------------------------------------- ---- Tarefa: Migração Folha Salário ---------------------------------------------------- /** * CRia os dados do ponto */ create table w_migracao_rhfolhapagamento_salario as select distinct r14_anousu, r14_mesusu, r14_instit from gerfsal left join pontofs on r14_regist = r10_regist and r14_anousu = r10_anousu and r14_mesusu = r10_mesusu order by r14_anousu asc, r14_mesusu asc; /** * Cria uma folha de pagamento para cada competencia e "semest" da tabela do ponto */ insert into rhfolhapagamento select nextval('rhfolhapagamento_rh141_sequencial_seq'), 0, r14_anousu, r14_mesusu, r14_anousu, r14_mesusu, r14_instit, 1, false, 'Folha Salário da competência: ' || r14_anousu || '/' || r14_mesusu || ' gerada automaticamente.' from w_migracao_rhfolhapagamento_salario order by r14_anousu asc, r14_mesusu asc; /** * Resgata o sequencial da ultima folha de pagamento de cada competencia */ create table w_ultimafolhadecadacompetencia_salario as select 0 as ultimafolha, rh141_anousu, rh141_mesusu, rh141_instit from rhfolhapagamento where rh141_tipofolha = 1 group by rh141_anousu,rh141_mesusu, rh141_instit; /** * Lança os registros do histórico do ponto */ insert into rhhistoricoponto (rh144_sequencial,rh144_regist,rh144_folhapagamento,rh144_rubrica,rh144_quantidade,rh144_valor) select nextval('rhhistoricoponto_rh144_sequencial_seq'), * from ( select distinct r10_regist, rhfolhapagamento.rh141_sequencial, r10_rubric, r10_quant, r10_valor from pontofs inner join w_ultimafolhadecadacompetencia_salario on w_ultimafolhadecadacompetencia_salario.rh141_anousu = r10_anousu and w_ultimafolhadecadacompetencia_salario.rh141_mesusu = r10_mesusu and w_ultimafolhadecadacompetencia_salario.rh141_instit = r10_instit inner join rhfolhapagamento on w_ultimafolhadecadacompetencia_salario.rh141_mesusu = rhfolhapagamento.rh141_mesusu and w_ultimafolhadecadacompetencia_salario.rh141_anousu = rhfolhapagamento.rh141_anousu and w_ultimafolhadecadacompetencia_salario.rh141_instit = rhfolhapagamento.rh141_instit and w_ultimafolhadecadacompetencia_salario.ultimafolha = 0 and rhfolhapagamento.rh141_tipofolha = 1 order by rh141_sequencial) as x; /** * Lança os registros do histórico do calculo */ insert into rhhistoricocalculo select nextval('rhhistoricocalculo_rh143_sequencial_seq'), r14_regist, rhfolhapagamento.rh141_sequencial, r14_rubric, r14_quant, r14_valor, r14_pd from gerfsal inner join rhfolhapagamento on r14_anousu = rh141_anousu and r14_mesusu = rh141_mesusu and r14_instit = rh141_instit and rh141_tipofolha = 1 order by rh141_sequencial; /** * TRIBUTÁRIO */ ALTER TABLE fiscalprocrec ADD y45_percentual bool default 'f'; -- autolevanta CREATE SEQUENCE autolevanta_y117_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE TABLE autolevanta( y117_sequencial int4 NOT NULL default 0, y117_auto int4 NOT NULL default 0, y117_levanta int4 default 0, CONSTRAINT autolevanta_sequ_pk PRIMARY KEY (y117_sequencial)); ALTER TABLE autolevanta ADD CONSTRAINT autolevanta_levanta_fk FOREIGN KEY (y117_levanta) REFERENCES levanta; ALTER TABLE autolevanta ADD CONSTRAINT autolevanta_auto_fk FOREIGN KEY (y117_auto) REFERENCES auto; CREATE UNIQUE INDEX autolevanta_auto_levanta_in ON autolevanta(y117_auto,y117_levanta); CREATE UNIQUE INDEX autolevanta_sequencial_in ON autolevanta(y117_sequencial); alter table parfiscal add column y32_templateautoinfracao int4; ALTER TABLE parfiscal ADD CONSTRAINT parfiscal_templateautoinfracao_fk FOREIGN KEY (y32_templateautoinfracao) REFERENCES db_documentotemplate; --atualizada sequence da setorlocvalor select setval('iptutabelas_j121_sequencial_seq', (select max(j121_sequencial)+1 from iptutabelas)); insert into iptutabelas values ( nextval('iptutabelas_j121_sequencial_seq'), 3747); select fc_executa_ddl(' CREATE TABLE if not exists cadastro.setorlocvalor( j05_sequencial int4 NOT NULL default 0, j05_setorloc int4 NOT NULL default 0, j05_anousu int4 NOT NULL default 0, j05_valor float8 default 0 )'); /** * FIM TRIBUTÁRIO */ ---------------------------------------------------- ---- TIME C { ---------------------------------------------------- ---------------------------------------------------- ---- Tarefa: 95125 ---------------------------------------------------- alter table periodoescola ADD COLUMN ed17_duracao varchar(5); update periodoescola set ed17_h_fim = replace(ed17_h_fim, ';', ':'); update periodoescola set ed17_h_inicio = replace(ed17_h_inicio, ';', ':'); update periodoescola set ed17_duracao = replace(to_char( (ed17_h_fim::time - ed17_h_inicio::time), 'HH24:MI'), '-', ''); CREATE SEQUENCE horarioescola_ed123_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE TABLE horarioescola( ed123_sequencial int4 NOT NULL default 0, ed123_turnoreferencia int4 NOT NULL default 0, ed123_escola int8 NOT NULL default 0, ed123_horainicio varchar(5) NOT NULL , ed123_horafim varchar(5) , CONSTRAINT horarioescola_sequ_pk PRIMARY KEY (ed123_sequencial)); ALTER TABLE horarioescola ADD CONSTRAINT horarioescola_escola_fk FOREIGN KEY (ed123_escola) REFERENCES escola; CREATE UNIQUE INDEX horarioescola_escola_turnoreferencia_in ON horarioescola(ed123_escola,ed123_turnoreferencia); drop index alunocensotipotransporte_aluno_in; drop index alunocensotipotransporte_censotipotransporte_in; update escolagestorcenso set ed325_email = upper(ed325_email); ---------------------------------------------------- --- Tarefa 92193 ---------------------------------------------------- alter table historicomps alter COLUMN ed62_percentualfrequencia type float8; alter table historicompsfora add column ed99_percentualfrequencia float8; ---------------------------------------------------- ---- } FIM TIME C ---------------------------------------------------- ---------------------------------------------------- ---- TIME FINANCEIRO ---------------------------------------------------- ---- Tarefa: 97055 ---------------------------------------------------- CREATE SEQUENCE processocompralote_pc68_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE SEQUENCE processocompraloteitem_pc69_sequencial_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; CREATE TABLE processocompralote( pc68_sequencial int4 NOT NULL default 0, pc68_nome varchar(100) NOT NULL , pc68_pcproc int8 default 0, CONSTRAINT processocompralote_sequ_pk PRIMARY KEY (pc68_sequencial)); CREATE TABLE processocompraloteitem( pc69_sequencial int4 NOT NULL default 0, pc69_processocompralote int4 NOT NULL , pc69_pcprocitem int8 , CONSTRAINT processocompraloteitem_sequ_pk PRIMARY KEY (pc69_sequencial)); ALTER TABLE processocompralote ADD CONSTRAINT processocompralote_pcproc_fk FOREIGN KEY (pc68_pcproc) REFERENCES pcproc; ALTER TABLE processocompraloteitem ADD CONSTRAINT processocompraloteitem_processocompralote_fk FOREIGN KEY (pc69_processocompralote) REFERENCES processocompralote; ALTER TABLE processocompraloteitem ADD CONSTRAINT processocompraloteitem_pcprocitem_fk FOREIGN KEY (pc69_pcprocitem) REFERENCES pcprocitem; ALTER TABLE pcproc ADD COLUMN pc80_tipoprocesso int4 NOT NULL default 1; CREATE INDEX processocompralote_sequencial_in ON processocompralote(pc68_sequencial); CREATE INDEX processocompraloteitem_sequencial_in ON processocompraloteitem(pc69_sequencial); ---------------------------------------------------- ---- Tarefa: 97148 ---------------------------------------------------- drop index materialtipogrupovinculo_materialtipogrupo_in; alter table materialtipogrupovinculo add column m04_materialestoquegrupo int4; update materialtipogrupovinculo set m04_materialestoquegrupo = (select m65_sequencial from materialestoquegrupo where m65_db_estruturavalor = m04_db_estruturavalor); alter table materialtipogrupovinculo drop column m04_db_estruturavalor, alter column m04_materialestoquegrupo set not null, add constraint materialtipogrupovinculo_materialestoquegrupo_fk foreign key (m04_materialestoquegrupo) references materialestoquegrupo; create unique index materialtipogrupovinculo_materialtipogrupo_in on materialtipogrupovinculo (m04_materialtipogrupo, m04_materialestoquegrupo);
alter table `challenge` add column `invite_image` varchar(1024) null default null;
/*want to understand how many distinct campaigns the company has running, the number of sources they have, and how they are related*/ SELECT COUNT (DISTINCT utm_campaign) FROM pageVistsData; SELECT COUNT (DISTINCT utm_source) FROM pageVistsData; SELECT DISTINCT utm_campaign, utm_source FROM pageVistsData ORDER BY utm_source; /* want to find what pages are on the wesbiste */ SELECT DISTINCT page_name FROM pageVistsData; /*want to find how many first touches each campaign is responsible for in order to see which is most effective */ WITH first_touch AS ( SELECT user_id, MIN(timestamp) as first_touch_at FROM pageVistsData GROUP BY user_id ), ft_attr AS ( SELECT ft.user_id, ft.first_touch_at, pv.utm_source, pv.utm_campaign FROM first_touch ft JOIN pageVistsData pv ON ft.user_id = pv.user_id AND ft.first_touch_at = pv.timestamp ) SELECT ft_attr.utm_source, ft_attr.utm_campaign, COUNT(*) FROM ft_attr GROUP BY 1, 2 ORDER BY 3 DESC; /*want to find out how many last touched each campaign is responsible in order to see which was most effective */ WITH last_touch AS ( SELECT user_id, MAX(timestamp) as last_touch_at FROM pageVistsData GROUP BY user_id ), lt_attr AS ( SELECT lt.user_id, lt.last_touch_at, pv.utm_source, pv.utm_campaign FROM last_touch lt JOIN pageVistsData pv ON lt.user_id = pv.user_id AND lt.last_touch_at = pv.timestamp ) SELECT lt_attr.utm_source, lt_attr.utm_campaign, COUNT(*) FROM lt_attr GROUP BY 1, 2 ORDER BY 3 DESC; /*want to know how many visitors make a purchase */ SELECT DISTINCT page_name, COUNT (page_name) FROM pageVistsData GROUP BY page_name ORDER BY page_name DESC; /*how many last touches on the purchase page is each campaign responsible for */ SELECT utm_campaign, COUNT (DISTINCT user_id) AS '#_of_touches' FROM pageVistsData WHERE page_name = '4 - purchase' GROUP BY utm_campaign ORDER BY #_of_touches DESC; /*the company can now look at the top campaigns and where the most amount of user are going. This can be used to understand where to allocate funds
-- -- Requêtes pour la création d'un base de données : `Librairie` -- -- Total = 6 tables -- -------------------------------------------------------- -- -- Structure de la table `Abonnes` -- CREATE TABLE `Abonnes` ( `numSecu` varchar(15) NOT NULL PRIMARY KEY, `nom` varchar(50) DEFAULT NULL, `prenom` varchar(50) DEFAULT NULL, `dateNaissance` date NOT NULL, `dateInscription` date NOT NULL, `identifiant` varchar(50) DEFAULT NULL, `mdp` varchar(50) DEFAULT NULL, `listeNoire` tinyint(1) NOT NULL ); -- -------------------------------------------------------- -- -- Structure de la table `Bibliothecaires` -- CREATE TABLE `Bibliothecaires` ( `numSecu` varchar(15) NOT NULL PRIMARY KEY, `nom` varchar(50) NOT NULL, `prenom` varchar(50) NOT NULL, `identifiant` varchar(50) NOT NULL, `mdp` varchar(50) NOT NULL ); -- -------------------------------------------------------- -- -- Structure de la table `DVD` -- CREATE TABLE `DVD` ( `EAN` varchar(13) NOT NULL PRIMARY KEY, `titre` varchar(300) NOT NULL, `realisateur` varchar(300) NOT NULL, `resume` varchar(300) NOT NULL, `langue` varchar(50) NOT NULL, `principauxActeurs` varchar(300) NOT NULL, `datePublication` date NOT NULL, `motCles` varchar(300) NOT NULL, `nombre` int(100) NOT NULL, `duree` int NOT NULL, `etat` tinyint(1) NOT NULL ); -- -------------------------------------------------------- -- -- Structure de la table `Emprunts` -- CREATE TABLE `Emprunts` ( -- id permet de numéroter les emprunts et d'en faire une clé unique `id` integer PRIMARY KEY AUTOINCREMENT, -- EAN Foireign key pour véirfier que EAN existe bien `EAN` varchar(13) NOT NULL, -- Pour savoir qui emprunte le livre, sinon on ne sait pas `numSecu` varchar(15) NOT NULL, `dateRetourTheorique` date NOT NULL, `dateRetour` date, `dateEmprunt` date NOT NULL, CONSTRAINT fk_numsecu FOREIGN KEY (numSecu) REFERENCES Abonnes(numSecu) ); -- -------------------------------------------------------- -- -- Structure de la table `Livres` -- CREATE TABLE `Livres` ( `EAN` varchar(13) NOT NULL PRIMARY KEY, `titre` varchar(300) NOT NULL, `auteur` varchar(300) NOT NULL, `datePublication` date(100) NOT NULL, `resume` varchar(300) NOT NULL, `langue` varchar(300) NOT NULL, `motCles` varchar(300) NOT NULL, `nombre` int(100) NOT NULL, `editeur` varchar(300) NOT NULL, `etat` tinyint(1) NOT NULL ); -- -------------------------------------------------------- -- -- Structure de la table `Reservations` -- CREATE TABLE `Reservations` ( -- idem que Emprunts `id` integer PRIMARY KEY AUTOINCREMENT, `numSecu` varchar(15) NOT NULL, `EAN` varchar(13) NOT NULL, `dateReserv` date NOT NULL, CONSTRAINT fk_numsecu FOREIGN KEY (numSecu) REFERENCES Abonnes(numSecu) ); ---------------------------------------------------------- -- insertion de valeurs tests ------------------------------------------------------------ -- table Abonnes ------------------------------------------------------------ insert into Abonnes values('099887766655544','Dupont','Agathe','15/06/2012','02/12/2019','monChat','miaou',0); ------------------------------------------------------------ -- table Bibliothecaires ------------------------------------------------------------ insert into Bibliothecaires values('122334455566677','Thecaire1','Biblio1','IDBiblio1','mdpBiblio1'); ------------------------------------------------------------ -- table DVD ------------------------------------------------------------ insert into DVD values('1234567890123','Titanic','James Cameron','Je taime mais coule toujours','anglais','Leonardo DiCaprio,Kate Winslet','07/01/1998','flotte,amour',4,254,0); ------------------------------------------------------------ -- table Livres ------------------------------------------------------------ insert into Livres values('0987654321098','La bdd pour les nuls','Raphalen','02/12/2020','Comment ça marche les requetes','Pas la notre','cours',15,'La fac',0); ------------------------------------------------------------ -- table Emprunts ------------------------------------------------------------ -- on ne met pas l'id, il s'incrémente tout seul insert into Emprunts(EAN,numSecu,dateRetourTheorique,dateRetour,dateEmprunt) values('1234567890123','099887766655544','14/01/2021','','16/11/2020'); ------------------------------------------------------------ -- table Reservations ------------------------------------------------------------ -- pas de réservations pour le moment
--Autor: Diego Salas --Resumen: Crea un tipo de dato definido por el usuario de tipo -- varray numerico de 20 espacios maximo. --Fecha creacion: 20/08/2013 --Fecha modificacion:29/01/2014 --================================================= create or replace type lista is varray(20) of number; /
--ALTER VIEW BG_SHIPPED_BUT_NOT_INVOICED AS SELECT DISTINCT TOP (100) PERCENT MAX(CONVERT(varchar, CAST(RTRIM(OEORDHDR_SQL.shipping_dt) AS datetime), 101)) AS [Order Shipping Date], MAX(CONVERT(varchar, CAST(RTRIM(SH.ship_dt) AS datetime), 101)) AS [Ship Date], OEORDHDR_SQL.ord_no AS [Order], AR.cus_name AS [Cus Name], RTRIM(OEORDHDR_SQL.cus_alt_adr_cd) AS [Store #], OEORDHDR_SQL.cus_no AS [Customer #], OEORDLIN_SQL.loc AS [Shipped From], SH.TrackingNo, sh.item_no AS [Shipped Items], SUM(qty) AS [Qty Shipped], (unit_price * SUM(qty)) AS [line total $], MAX(OEORDLIN_SQL.user_def_fld_1) AS [Late Order Comments 1], MAX(OEORDLIN_SQL.user_def_fld_2) AS [Late Order Comments 2], OEORDHDR_SQL.cmt_2 AS [Invoicing Comment] FROM dbo.oeordhdr_sql AS OEORDHDR_SQL JOIN dbo.oeordlin_sql AS OEORDLIN_SQL ON OEORDHDR_SQL.ord_type = OEORDLIN_SQL.ord_type AND OEORDHDR_SQL.ord_no = OEORDLIN_SQL.ord_no JOIN dbo.wsPikPak AS SH ON SH.Ord_no = OEORDHDR_SQL.ord_no AND SH.line_no = OEORDLIN_SQL.line_no JOIN dbo.arcusfil_sql AS AR ON AR.cus_no = OEORDHDR_SQL.cus_no LEFT OUTER JOIN (SELECT line_no, ord_no, SUM(qty) AS qtysum FROM dbo.wsPikPak AS WPP WHERE shipped = 'Y' GROUP BY ord_no, line_no) AS SHSUM ON SHSUM.line_no = oeordlin_sql.line_no AND SHSUM.ord_no = oeordhdr_sql.ord_no WHERE (OEORDHDR_SQL.ord_type = 'O') AND (NOT (OEORDLIN_SQL.prod_cat IN ('037', '2', '036', '102', '111', '336'))) AND (OEORDLIN_SQL.item_no NOT LIKE '%TEST%') AND (NOT OEORDHDR_SQL.status = 9 AND (ISNUMERIC(OEORDHDR_SQL.status) = 1)) AND (OEORDLIN_SQL.ord_no + OEORDLIN_SQL.item_no IN (SELECT Ord_no + Item_no AS Expr1 FROM dbo.wsPikPak AS pp WHERE (Shipped = 'Y')) ) AND (ship_dt < DATEADD(DAY, - 4, GETDATE()) OR (ship_dt is null AND shipping_dt < DATEADD(day, - 80, GETDATE()))) --AND SHSUM.qtysum = qty_to_ship GROUP BY OEORDHDR_SQL.ord_no, AR.cus_name, OEORDHDR_SQL.cus_alt_adr_cd, OEORDHDR_SQL.cus_no, OEORDLIN_SQL.loc, OEORDHDR_SQL.tot_sls_amt, sh.item_no, SH.TrackingNo, unit_price, OEORDHDR_SQL.cmt_2, qty_to_ship /* UNION ALL SELECT TOP (100) PERCENT MAX(CONVERT(varchar, CAST(RTRIM(OEORDHDR_SQL.shipping_dt) AS datetime), 101)) AS [Order Shipping Date], --'N/A' AS [Ship Date], OEORDHDR_SQL.ord_no AS [Order], AR.cus_name AS [Cus Name], RTRIM(OEORDHDR_SQL.cus_alt_adr_cd) AS [Store #], OEORDHDR_SQL.cus_no AS [Customer #], OEORDLIN_SQL.loc AS [Shipped From], 'N/A', oeordlin_Sql.item_no AS [Items], SUM(oeordlin_sql.qty_to_ship) AS [Qty], (OEORDLIN_SQL.unit_price * OEORDLIN_SQL.qty_to_ship), MAX(OEORDLIN_SQL.user_def_fld_1) AS [Late Order Comments 1], MAX(OEORDLIN_SQL.user_def_fld_2) AS [Late Order Comments 2], OEORDHDR_SQL.cmt_2 AS [Invoicing Comment] FROM dbo.oeordhdr_sql AS OEORDHDR_SQL INNER JOIN dbo.oeordlin_sql AS OEORDLIN_SQL ON OEORDHDR_SQL.ord_type = OEORDLIN_SQL.ord_type AND OEORDHDR_SQL.ord_no = OEORDLIN_SQL.ord_no LEFT OUTER JOIN dbo.arcusfil_sql AS AR ON AR.cus_no = OEORDHDR_SQL.cus_no WHERE (OEORDHDR_SQL.ord_type = 'O') AND (NOT (OEORDLIN_SQL.prod_cat IN ('037', '2', '036', '102', '111', '336'))) AND (OEORDHDR_SQL.status <> 'C') AND (OEORDHDR_SQL.tot_sls_amt > 0) AND (OEORDLIN_SQL.item_no NOT LIKE '%TEST%') AND (OEORDHDR_SQL.status < 9) AND shipping_dt < DATEADD(day, - 90, GETDATE()) GROUP BY OEORDHDR_SQL.ord_no, AR.cus_name, OEORDHDR_SQL.cus_alt_adr_cd, OEORDHDR_SQL.cus_no, OEORDLIN_SQL.loc, OEORDHDR_SQL.tot_sls_amt, oeordlin_sql.item_no, unit_price, qty_to_ship, OEORDHDR_SQL.cmt_2 ORDER BY [Order], [Ship Date], [Order Shipping Date] */
# ************************************************************ # Sequel Pro SQL dump # Version 4541 # # http://www.sequelpro.com/ # https://github.com/sequelpro/sequelpro # # Host: 192.168.0.254 (MySQL 5.6.28-log) # Database: test_gc1 # Generation Time: 2018-11-22 15:25:16 +0000 # ************************************************************ /*!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 */; /*!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 */; # Dump of table tb_county # ------------------------------------------------------------ DROP TABLE IF EXISTS `tb_county`; CREATE TABLE `tb_county` ( `county_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `county_name` varchar(64) NOT NULL DEFAULT '' COMMENT '县', PRIMARY KEY (`county_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; LOCK TABLES `tb_county` WRITE; /*!40000 ALTER TABLE `tb_county` DISABLE KEYS */; INSERT INTO `tb_county` (`county_id`, `county_name`) VALUES (1,'兴平集控'); /*!40000 ALTER TABLE `tb_county` ENABLE KEYS */; UNLOCK TABLES; # Dump of table tb_device # ------------------------------------------------------------ DROP TABLE IF EXISTS `tb_device`; CREATE TABLE `tb_device` ( `device_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `device_pos` int(11) NOT NULL, `device_name` varchar(100) NOT NULL, `V_level` int(11) NOT NULL, `village_id` int(10) unsigned NOT NULL, `county_id` int(10) unsigned NOT NULL, `pos_x` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '行', `pos_y` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '列', PRIMARY KEY (`device_id`), KEY `village_id` (`village_id`), KEY `county_id` (`county_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; LOCK TABLES `tb_device` WRITE; /*!40000 ALTER TABLE `tb_device` DISABLE KEYS */; INSERT INTO `tb_device` (`device_id`, `device_pos`, `device_name`, `V_level`, `village_id`, `county_id`, `pos_x`, `pos_y`) VALUES (1,101,'1号主变PST626A变压器保护装置屏 ',110,1,1,1,6), (2,102,'2号主变PST626A变压器保护装置屏 ',350,1,1,1,3), (3,103,'1246 彬王Ⅰ线PSL621D保护屏',10,1,1,1,8), (4,1,'35kV线路保护测控屏',110,1,1,2,8), (5,1,'远动屏',110,1,1,2,3), (6,1,'数据网接入屏',110,1,1,3,4), (7,1,'1号直流充电屏',110,1,1,4,1), (8,101,'1251 彬监Ⅰ线PSL621C保护屏',110,1,1,1,1); /*!40000 ALTER TABLE `tb_device` ENABLE KEYS */; UNLOCK TABLES; # Dump of table tb_module # ------------------------------------------------------------ DROP TABLE IF EXISTS `tb_module`; CREATE TABLE `tb_module` ( `module_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `module_name` varchar(100) NOT NULL, `module_type` varchar(100) NOT NULL, `module_pos` int(10) unsigned NOT NULL DEFAULT '0', `producer` varchar(100) NOT NULL, `running_date` date NOT NULL, `verify_date` date NOT NULL, `version` int(10) unsigned NOT NULL, `verify_code` int(10) unsigned NOT NULL, `net_address` varchar(100) DEFAULT NULL, `bianbi` varchar(100) DEFAULT NULL, `dingzhidanhao` varchar(100) DEFAULT NULL, `device_id` int(10) unsigned NOT NULL, PRIMARY KEY (`module_id`), KEY `device_id` (`device_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; LOCK TABLES `tb_module` WRITE; /*!40000 ALTER TABLE `tb_module` DISABLE KEYS */; INSERT INTO `tb_module` (`module_id`, `module_name`, `module_type`, `module_pos`, `producer`, `running_date`, `verify_date`, `version`, `verify_code`, `net_address`, `bianbi`, `dingzhidanhao`, `device_id`) VALUES (1,'差动:PST621 ','保护装置1',0,'国电南自','2009-04-13','2017-03-17',11,123,'192.168.0.0','G:200/5','调继字10-323;\n调继字10-324',1), (2,'高后备:PST626A ','保护装置2',0,'国电南自','2009-04-13','2017-03-17',1,2,'192.168.0.0','G:200/5','调继字10-323;\n调继字10-324',1), (3,'中后备:PST626 ','保护装置3',0,'国电南自','2009-04-13','2017-03-17',1,2,'192.168.0.0','G:200/5','调继字10-323;\n调继字10-324',1), (4,'低后备:PST626 ','保护装置3',0,'国电南自','2009-04-13','2017-03-17',1,2,'192.168.0.0','G:200/5','调继字10-323;\n调继字10-324',1), (5,'调压器:GZK-100B','保护装置3',0,'国电南自','2009-04-13','2017-03-17',1,2,'192.168.0.0','G:200/5','调继字10-323;\n调继字10-324',1), (6,'1','1',0,'1','2016-11-11','2016-11-11',1,1,'1',NULL,NULL,1), (7,'123','1',0,'1','2018-11-11','2018-11-11',1,1,'1',NULL,NULL,1); /*!40000 ALTER TABLE `tb_module` ENABLE KEYS */; UNLOCK TABLES; # Dump of table tb_user # ------------------------------------------------------------ DROP TABLE IF EXISTS `tb_user`; CREATE TABLE `tb_user` ( `userid` int(10) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL DEFAULT '', `password` varchar(50) NOT NULL, PRIMARY KEY (`userid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; LOCK TABLES `tb_user` WRITE; /*!40000 ALTER TABLE `tb_user` DISABLE KEYS */; INSERT INTO `tb_user` (`userid`, `username`, `password`) VALUES (2,'test','test123'), (3,'sss','ddd'), (4,'admin','admin'), (5,'admin','admin'), (6,'admin','admin'), (7,'admin','admin'), (8,'admin','admin'), (9,'',''); /*!40000 ALTER TABLE `tb_user` ENABLE KEYS */; UNLOCK TABLES; # Dump of table tb_village # ------------------------------------------------------------ DROP TABLE IF EXISTS `tb_village`; CREATE TABLE `tb_village` ( `village_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `village_name` varchar(50) NOT NULL, `county_id` int(11) NOT NULL, `V_level` int(11) NOT NULL COMMENT '电压等级', PRIMARY KEY (`village_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; LOCK TABLES `tb_village` WRITE; /*!40000 ALTER TABLE `tb_village` DISABLE KEYS */; INSERT INTO `tb_village` (`village_id`, `village_name`, `county_id`, `V_level`) VALUES (1,'西吴变',1,110), (2,'兴平变',1,110), (4,'兴城变',1,110), (5,'丰仪变',1,110), (6,'宋村变',1,110), (7,'南市变',1,35), (8,'晶海开闭所',1,10); /*!40000 ALTER TABLE `tb_village` ENABLE KEYS */; UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_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 */;
 CREATE view [source].dim_order_status as select distinct isnull(state, '[Not Specified]') as state ,isnull(status, '[Not Specified]') as status from dbo.staging_orders where status is not null or state is not null --order by 1,2
# CATALOG use shop_r2; CREATE TABLE if not exists NODES ( `N_ID` BIGINT NOT NULL AUTO_INCREMENT, `N_P0` BIGINT NULL, `N_KIND` char(4) NOT NULL collate utf8_bin, `N_VOID` TINYINT NOT NULL, `N_HIDE` TINYINT not null default 1, `N_URI` VARCHAR(128) NOT NULL, `N_ORDER` INT NOT NULL, PRIMARY KEY (`N_ID`), CONSTRAINT `FK_NODES_N_P0_NODES` FOREIGN KEY (`N_P0`) REFERENCES `NODES` (N_ID) ) ENGINE=InnoDB; CREATE TABLE if not exists NODE_INCAPS ( N_P bigint, N_PLEV int, N_C bigint, N_CLEV int, N_LEV_DIFF int, constraint FK_NODE_INCAPS_N_P_NODES foreign key (N_P) references NODES(N_ID), constraint FK_NODE_INCAPS_N_C_NODES foreign key (N_C) references NODES(N_ID) ) ENGINE=InnoDB; CREATE TABLE if not exists NODE_TREE ( N_ID bigint, N_ROOT bigint, N_ORDER int null, N_VOID tinyint default 0, N_HIDE tinyint default 1, N_URI varchar(255), CNT_ALL_FULL int default null, CNT_ALL int default null, CNT_VIS_FULL int default null, CNT_VIS int default null, primary key (N_ID), constraint FK_NODE_TREE_N_ID_NODES foreign key (N_ID) references NODES(N_ID), constraint FK_NODE_TREE_N_ROOT_NODES foreign key (N_ROOT) references NODES(N_ID) ) ENGINE=InnoDB; /* CREATE TABLE if not exists `flat_tree` ( `lv` INT NOT NULL, `node` BIGINT NOT NULL, `furi` TEXT NOT NULL, `fshow` TINYINT NOT NULL DEFAULT 0, `cnt` INT NOT NULL DEFAULT 0, `cnt_all` INT NOT NULL DEFAULT 0, `order` INT NOT NULL DEFAULT 0, INDEX `ix_furi` (`furi`), CONSTRAINT `fk_flat_tree_node` FOREIGN KEY (`node`) REFERENCES `tree_nodes` (ID) ) ENGINE=MyISAM; */ CREATE TABLE if not exists `BRANDS` ( `B_ID` BIGINT NOT NULL AUTO_INCREMENT, `B_NAME` TEXT NOT NULL, PRIMARY KEY (`B_ID`) ) ENGINE=InnoDB; CREATE TABLE if not exists `P_AVAIL` ( `PV_ID` INT NOT NULL AUTO_INCREMENT, `PV_NAME` TEXT NOT NULL, PRIMARY KEY (`PV_ID`) ) ENGINE=InnoDB; -- SOME CHANGE CREATE TABLE if not exists `PRODUCTS` ( `N_ID` BIGINT NOT NULL, `P_VOID` tinyint not null default 0, `P_URI` varchar(128) NOT NULL, `P_NAME` TEXT NOT NULL, `P_FULLNAME` TEXT NULL, `P_TITLE` TEXT NULL DEFAULT NULL, `P_KEYWORDS` MEDIUMTEXT NOT NULL DEFAULT '', `P_DESCR` MEDIUMTEXT NOT NULL DEFAULT '', `P_CSS` VARCHAR(128) NULL DEFAULT NULL, `P_CODE` VARCHAR(128) NULL DEFAULT NULL, `P_BARCODE` VARCHAR(128) NULL DEFAULT NULL, `B_ID` BIGINT NULL DEFAULT NULL, `P_MEASURE` VARCHAR(128) NOT NULL DEFAULT '', `P_SIZE` VARCHAR(128) NOT NULL DEFAULT '', `P_DESCR_SHORT` LONGTEXT NOT NULL DEFAULT '', `P_DESCR_FULL` LONGTEXT NOT NULL DEFAULT '', `P_DESCR_TECH` LONGTEXT NOT NULL DEFAULT '', `P_PRICE` DOUBLE NULL DEFAULT NULL, `P_PRICE_OLD` DOUBLE NULL DEFAULT NULL, `PV_ID` INT NULL DEFAULT NULL COMMENT 'FK to P_AVAIL -- availability type', `P_AVAIL_COUNT` INT NULL DEFAULT NULL, `IS_NEW` TINYINT NOT NULL DEFAULT 0, `IS_RECOMEND` TINYINT NOT NULL DEFAULT 0, `IS_SPECIAL` TINYINT NOT NULL DEFAULT 0, `D_CREATE` DATETIME NULL DEFAULT NULL, `D_MODIFY` DATETIME NULL DEFAULT NULL, `LOG_ALL` INT NOT NULL, `LOG_TODAY` INT NOT NULL, `LOG_DAY` DATE NOT NULL, `P_ORDER` int NOT NULL, `P_HIDE` tinyint NOT NULL, PRIMARY KEY (`N_ID`), CONSTRAINT `FK_PRODUCTS_N_ID_NODES` FOREIGN KEY (`N_ID`) REFERENCES `NODES` (N_ID), CONSTRAINT `FK_PRODUCTS_B_ID_BRAND` FOREIGN KEY (`B_ID`) REFERENCES `BRANDS` (B_ID), CONSTRAINT `FK_PRODUCTS_PV_ID_P_AVAIL` FOREIGN KEY (`PV_ID`) REFERENCES `P_AVAIL` (PV_ID) ) ENGINE=InnoDB; CREATE TABLE if not exists `CATEGORIES` ( `N_ID` BIGINT NOT NULL, `CAT_NAME` TEXT NOT NULL, `CAT_FULLNAME` TEXT NULL, `CAT_TITLE` TEXT NULL DEFAULT NULL, `CAT_KEYWORDS` MEDIUMTEXT NOT NULL DEFAULT '', `CAT_DESCR` MEDIUMTEXT NOT NULL DEFAULT '', `CAT_CSS` VARCHAR(128) NULL DEFAULT NULL, `TEXT_TOP` LONGTEXT NOT NULL DEFAULT '', `TEXT_BOTT` LONGTEXT NOT NULL DEFAULT '', CONSTRAINT `FK_CATEGORIES_N_ID_NODES` FOREIGN KEY (`N_ID`) REFERENCES `NODES` (N_ID) ) ENGINE=InnoDB; CREATE TABLE if not exists `TAGS` ( `T_ID` BIGINT NOT NULL AUTO_INCREMENT, `T_NAME` VARCHAR (63) NOT NULL, PRIMARY KEY (`T_ID`) ) ENGINE=InnoDB; # PIZDARIKI MAST CREATE TABLE if not exists `PRODUCT_TAGS` ( `N_ID` BIGINT NOT NULL comment 'node id from product' , `T_ID` BIGINT NOT NULL, CONSTRAINT `FK_PRODUCT_TAGS_N_ID_PRODUCTS` FOREIGN KEY (`N_ID`) REFERENCES `PRODUCTS` (N_ID), CONSTRAINT `FK_PRODUCT_TAGS_T_ID_TAGS` FOREIGN KEY (`T_ID`) REFERENCES `TAGS` (T_ID) ) ENGINE=InnoDB; CREATE TABLE if not exists `CRITERIAS` ( `CR_ID` BIGINT NOT NULL AUTO_INCREMENT, `CR_NAME` VARCHAR (63) NOT NULL, `CR_KIND` char (8) NOT NULL collate utf8_bin comment '8 symbol kind example ''apsphere''', PRIMARY KEY (`CR_ID`) ) ENGINE=InnoDB; CREATE TABLE if not exists `PRODUCT_CRETERIAS` ( `CR_ID` BIGINT NOT NULL, `N_ID` BIGINT NOT NULL, CONSTRAINT `FK_PRODUCT_CRETERIAS_P_ID_PRODUCTS` FOREIGN KEY (`N_ID`) REFERENCES `PRODUCTS` (N_ID), CONSTRAINT `FK_PRODUCT_CRETERIAS_CR_ID_CRITERIAS` FOREIGN KEY (`CR_ID`) REFERENCES `CRITERIAS` (CR_ID) ) ENGINE=InnoDB;
USE burgers_db; INSERT INTO burgers(burger_name, devoured) VALUES ("Bacon Cheese Burger", False), ("Mushroom Swiss Burger", False), ("Impossible Burger", True)
COPY Lab1.ChirpUsers FROM stdin USING DELIMITERS '|' NULL AS ''; 101|jSoRP2c7|Sirius|11/1/15|12 Grimauld Pl., London|H|4343.45||0 102|8Rhg2ive|Lavender|08/14/2015|121 West Lane, London|H|76543.5||1 123|q9hy22hh|Cho|9/3/15|Ireland|H|4323646||1 113|00ZN7H5f|Neville|7/4/15|Manchester, England|G|23455|114|1 114|Y8zUI9EZ|Luna|01/22/2015|Devon, England|H|9823.67|113|1 112|xzGSVzlD|Bill|7/4/15|Charing Cross Road, London|G|55564.55||1 115|3WFFG2Im|Draco|07/27/2015|Wiltshire, England|U|32221223.88||1 118|XezJCII2|George|09/18/2015|London|L|3534498.45||1 116|JrMiaa3N|Ginny|06/29/2015|Ottery St Catchpole, Devon|U|194649|125|1 117|GDYBR39p|Fred|01/31/2015|London|L|3444334.78||0 111|fD9QPkov|Albus|02/22/2015|Highlands, Scotland|G|745697.54||0 119|KrZtS0Wq|Peter|09/27/2015|Edinburgh, Scotland|H|5004||0 120|jAtv6Mn9|Petunia|01/16/2015|4 Privet Drive, Surrey|U|9563.77|124|1 124|xL3qpMmW|Vernon|2/6/15|4 Privet Drive, Surrey|U|55838.6|120|1 121|PaxeEHeR|Argus|4/3/15|Highlands, Scotland|L|29043.37||1 122|TaJe9hrc|Seamus|2/2/15|Kenmare, County Kerry|H|54290.7||1 125|l0goXKmb|Harry|04/21/2015|West Country, England|G|325633.5|116|1 126|Gy6x9kid|Tom|3/8/15|London|H|85387800.89||0 127|2qx5K5Q9|Ron|12/1/15|Ottery St Catchpole, Devon|U|74690.43||1 \. COPY Lab1.ChirpPosts FROM stdin USING DELIMITERS '|'; 112|178|Far far away, behind the word mountains,|0|3/5/17 112|23|far from the countries Vokalia|0|3/11/16 112|195|A wonderful serenity has taken possession of|0|04/15/2017 112|143|my entire soul, like these sweet mornings|0|2/2/14 113|188|One morning, when Gregor Samsa woke|0|5/6/17 113|70|he found himself transformed|0|05/13/2016 114|129|The quick, brown fox jumps|0|5/8/16 115|58|Junk MTV quiz graced by fox whelps|1|03/21/2017 116|43|But I must explain to you|0|03/29/2017 118|42|this mistaken idea of denouncing pleasure|0|1/12/17 118|143|Europan lingues es membres del sam familie|0|2/6/16 118|72|Li lingues differe solmen in li grammatica|0|09/21/2016 120|69|Samsa was a travelling salesman|0|10/26/2016 120|71|What's happened to me?|0|01/26/2016 121|61|A very bad quack might jinx|1|4/3/17 121|164|Quick zephyrs blow, vexing daft Jim|1|2/2/16 121|145|Their separate existence is a myth.|0|4/21/16 122|71|an eternity of bliss;|0|01/19/2017 122|175|Watch "Jeopardy!", Alex Trebek's fun TV quiz|0|03/22/2016 123|59|a thousand unknown plants are noticed by me|0|12/1/16 124|49|Ma quande lingues coalesce|0|11/4/17 \. COPY Lab1.ChirpFollowers FROM stdin USING DELIMITERS '|'; 112|119|10/26/2016 112|122|09/21/2016 112|113|05/13/2016 112|116|04/15/2016 113|115|03/29/2017 113|119|03/22/2016 114|126|03/21/2017 115|120|01/26/2016 116|114|01/19/2017 117|126|1/12/17 118|113|5/6/17 119|124|3/5/17 120|121|11/4/17 120|116|4/3/17 121|119|3/11/16 121|116|5/8/16 121|124|2/6/16 122|127|2/2/16 122|117|12/1/16 123|121|2/11/16 124|116|2/2/16 \. COPY Lab1.ChirpReads FROM stdin USING DELIMITERS '|'; 112|178|118|1|5/3/17 112|23|118|3|02/25/2017 112|195|127|1|1/10/17 112|143|120|5|7/4/16 113|188|118|1|05/06/2017 113|70|116|1|01/31/2017 114|129|113|4|05/08/2016 114|129|118|4|05/08/2016 116|43|127|2|03/30/2017 118|42|122|3|1/16/2017 123|59|127|4|12/02/2016 116|43|124|4|03/29/2017 116|43|123|4|03/30/17 115|58|116|4|03/24/2017 124|49|122|1|11/8/17 124|49|127|2|11/9/17 112|178|114|3|5/3/17 \.
-- 1 SELECT STUDENT_NO AS 학번 , STUDENT_NAME AS 이름 , ENTRANCE_DATE AS 입학년도 FROM TB_STUDENT WHERE DEPARTMENT_NO = '002' ORDER BY ENTRANCE_DATE; -- 2 SELECT PROFESSOR_NAME , PROFESSOR_SSN FROM TB_PROFESSOR WHERE LENGTH(PROFESSOR_NAME) != 3; -- 3 SELECT PROFESSOR_NAME , 120 - SUBSTR(PROFESSOR_SSN,1,2) FROM TB_PROFESSOR ORDER BY 120 - SUBSTR(PROFESSOR_SSN,1,2); -- 4 SELECT SUBSTR(PROFESSOR_NAME,2) AS 이름 FROM TB_PROFESSOR; -- 5 SELECT STUDENT_NO , STUDENT_NAME -- 입학년도 112 생년 88 12-88 = -76 + 100 = 24 -- 입학년도 114 생년 95 114- 95 = 19 -- 입학년도 199 생년 68 ,EXTRACT() ,CASE WHEN SUBSTR(EXTRACT(YEAR FROM ENTRANCE_DATE),3,2) - SUBSTR(STUDENT_SSN,1,2) < 0 THEN SUBSTR(EXTRACT(YEAR FROM ENTRANCE_DATE),3,2) - SUBSTR(STUDENT_SSN,1,2) + 100 ELSE SUBSTR(EXTRACT(YEAR FROM ENTRANCE_DATE),3,2) - SUBSTR(STUDENT_SSN,1,2) END FROM TB_STUDENT WHERE 100+SUBSTR(EXTRACT(YEAR FROM ENTRANCE_DATE),3,2) - SUBSTR(STUDENT_SSN,1,2) > ; -- ,SUBSTR(STUDENT_SSN,1,2)- -- 급여가 300만원 이상인 직원이 속한 부서를 고를 때 SELECT DEPT_CODE
-- phpMyAdmin SQL Dump -- version 4.8.3 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jul 31, 2021 at 05:15 PM -- Server version: 10.1.37-MariaDB -- PHP Version: 7.2.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: `crud_db` -- -- -------------------------------------------------------- -- -- Table structure for table `countries` -- CREATE TABLE `countries` ( `id` int(3) NOT NULL, `name` varchar(35) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `countries` -- INSERT INTO `countries` (`id`, `name`) VALUES (1, 'Afghanistan'), (2, 'Albania'), (3, 'Algeria'), (4, 'Angola'), (5, 'Argentina'), (6, 'Armenia'), (7, 'Australia'), (8, 'Austria'), (9, 'Bahrain'), (10, 'Bangladesh'), (11, 'Belarus'), (12, 'Belgium'), (13, 'Bhutan'), (14, 'Bolivia'), (15, 'Bosnia & Herzegovina'), (16, 'Botswana'), (17, 'Brazil'), (18, 'Bulgaria'), (19, 'Cambodia'), (20, 'Cameroon'), (21, 'Canada'), (22, 'Chile'), (23, 'China'), (24, 'Colombia'), (25, 'Costa Rica'), (26, 'Croatia'), (27, 'Cuba'), (28, 'Cyprus'), (29, 'Czech Republic'), (30, 'Denmark'), (31, 'Ecuador'), (32, 'Egypt'), (33, 'Estonia'), (34, 'Ethiopia'), (35, 'Fiji'), (36, 'Finland'), (37, 'France'), (38, 'Germany'), (39, 'Ghana'), (40, 'Greece'), (41, 'Greenland'), (42, 'Guinea'), (43, 'Guyana'), (44, 'Haiti'), (45, 'Honduras'), (46, 'Hong Kong'), (47, 'Hungary'), (48, 'Iceland'), (49, 'India'), (50, 'Indonesia'), (51, 'Iran'), (52, 'Iraq'), (53, 'Ireland'), (54, 'Israel'), (55, 'Italy'), (56, 'Japan'), (57, 'Jersey'), (58, 'Jordan'), (59, 'Kazakhstan'), (60, 'Kenya'), (61, 'Kuwait'), (62, 'Kyrgyzstan'), (63, 'Lebanon'), (64, 'Liberia'), (65, 'Libya'), (66, 'Lithuania'), (67, 'Luxembourg'), (68, 'Macedonia'), (69, 'Madagascar'), (70, 'Malaysia'), (71, 'Maldives'), (72, 'Mali'), (73, 'Mauritius'), (74, 'Mexico'), (75, 'Monaco'), (76, 'Mongolia'), (77, 'Morocco'), (78, 'Namibia'), (79, 'Nepal'), (80, 'Netherlands'), (81, 'New Zealand'), (82, 'Nigeria'), (83, 'North Korea'), (84, 'Norway'), (85, 'Oman'), (86, 'Pakistan'), (87, 'Panama'), (88, 'Papua New Guinea'), (89, 'Paraguay'), (90, 'Peru'), (91, 'Philippines'), (92, 'Poland'), (93, 'Portugal'), (94, 'Qatar'), (95, 'Romania'), (96, 'Russia'), (97, 'Rwanda'), (98, 'Saudi Arabia'), (99, 'Serbia'), (100, 'Singapore'), (101, 'Slovakia'), (102, 'Slovenia'), (103, 'South Africa'), (104, 'South Korea'), (105, 'Spain'), (106, 'Sri Lanka'), (107, 'Sudan'), (108, 'Sweden'), (109, 'Switzerland'), (110, 'Syria'), (111, 'Taiwan'), (112, 'Tajikistan'), (113, 'Tanzania'), (114, 'Thailand'), (115, 'Tunisia'), (116, 'Turkey'), (117, 'Turkmenistan'), (118, 'Uganda'), (119, 'Ukraine'), (120, 'United Arab Emirates'), (121, 'United Kingdom'), (122, 'United States'), (123, 'Uruguay'), (124, 'Uzbekistan'), (125, 'Venezuela'), (126, 'Vietnam'), (127, 'Yemen'), (128, 'Zambia'), (129, 'Zimbabwe'); -- -------------------------------------------------------- -- -- Table structure for table `employees` -- CREATE TABLE `employees` ( `id` int(11) NOT NULL, `name` varchar(100) NOT NULL, `address` varchar(255) NOT NULL, `salary` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `employees` -- INSERT INTO `employees` (`id`, `name`, `address`, `salary`) VALUES (1, 'Roland Mendel', 'C/ Araquil, 67, Madrid', 5000), (2, 'Victoria Ashworth', '35 King George, London', 6500), (3, 'Martin Blank', '25, Rue Lauriston, Paris', 8000), (4, 'prashanth', 'padmanagar', 16000); -- -------------------------------------------------------- -- -- Table structure for table `login_details` -- CREATE TABLE `login_details` ( `id` int(11) NOT NULL, `email` varchar(200) NOT NULL, `name` varchar(200) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `login_details` -- INSERT INTO `login_details` (`id`, `email`, `name`) VALUES (1, 'prashanth.thatikonda234@gmail.com', 'Prashanth Thatikonda'), (2, 'prashanth.thatikonda234@gmail.com', 'Prashanth Thatikonda'), (3, 'prashanth.thatikonda234@gmail.com', 'Prashanth Thatikonda'), (4, 'prashanth.thatikonda234@gmail.com', 'Prashanth Thatikonda'), (5, 'prashanth.thatikonda234@gmail.com', 'Prashanth Thatikonda'), (6, 'prashanth.thatikonda234@gmail.com', 'Prashanth Thatikonda'), (7, 'prashanth.thatikonda234@gmail.com', 'Prashanth Thatikonda'); -- -------------------------------------------------------- -- -- Table structure for table `test` -- CREATE TABLE `test` ( `id` int(11) NOT NULL, `name` varchar(50) DEFAULT NULL, `email` varchar(50) DEFAULT NULL, `mobileno` varchar(50) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `test` -- INSERT INTO `test` (`id`, `name`, `email`, `mobileno`) VALUES (1, 'prashanth', 'prashanth.thatikonda234@gmail.com', '9022040666'), (2, 'omkar', 'omkar@gmail.com', '9876543210'), (3, 'prashanth', 'prashanth@gmail.com', '9022040666'), (4, 'test', 'test@gmail.com', '9022040666'), (5, NULL, NULL, NULL), (6, 'prashanth', 'prashanth@penguincrm.com', '9876543210'), (7, 'sdsd', 'sd', '1234567890'), (8, 'sdjhs', 'sdhk', '1234567890'), (9, 'nnna', 'fhsj@gmail.com', '9099999029'), (10, NULL, NULL, NULL), (11, 'larence', 'larence', '999990900'), (12, 'larence', 'larence', '999990900'), (13, 'dssd', 'sdfsdf', '8989912993'), (14, 'tetethjb', 'sjbhbd', '9029201199'), (15, 'ree', 'has', '8888888999'), (16, 'prashanth', 'prashanth@pee.com', '8892829009'), (17, 'sdbhjb', 'kjsd', '8987654321'), (18, 'sravs', 'sravs', '111111111'), (19, 'sravsssd', 'sravs', '111111111'), (20, 'sds', 'sgdj', '9090289010'), (21, 'sds', 'sgdj', '9090289010'), (22, 'tete', 'sjdbh', 'sdhs'), (23, 'sdh', 'ksd', 'shdj'), (24, 'jhdssdbj', 'jsbd', '9889879890'), (25, 'jhdssdbj', 'jsbd', '9889879890'), (26, 'prashanth', 'prashanth.thatikonda234@gmail.com', '9022224324'); -- -------------------------------------------------------- -- -- Table structure for table `token` -- CREATE TABLE `token` ( `id` int(11) NOT NULL, `access_token` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `token` -- INSERT INTO `token` (`id`, `access_token`) VALUES (2, '{\"access_token\":\"ya29.a0ARrdaM8JH_pP-_MMoMt4hghs8MAPPQdvlqq7cX_W7OdhkigndfHQfu-sZeoEVbL_FaXAozN-ayvxBdWb6Zd2bFBN5-feHuDsDdseOJTI1BKIDSBVU6zMkyVQMcWt0oX5hVxWQ3ptNGMbGYNYKK3dXED9Prnh\",\"token_type\":\"Bearer\",\"refresh_token\":\"1//0gmFIqbgNLjmwCgYIARAAGBASNwF-L9Ir7YSZdPOp3_56ZEWPj6cuuBY7-9BNVMCx_9BiD6c5KPumI9itaYg6a7YDoBEsuz0lng4\",\"expires_in\":3599,\"expires_at\":1627744527}'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` int(11) NOT NULL, `username` varchar(50) NOT NULL, `password` varchar(255) NOT NULL, `created_at` datetime DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `username`, `password`, `created_at`) VALUES (1, 'prashanth', '$2y$10$7Hehs3bOTuwaZjsH.bq0DePbY8v0CK2h/b95ChXbvoOPe0yGkqAGO', '2021-06-22 17:12:38'); -- -- Indexes for dumped tables -- -- -- Indexes for table `countries` -- ALTER TABLE `countries` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`name`); -- -- Indexes for table `employees` -- ALTER TABLE `employees` ADD PRIMARY KEY (`id`); -- -- Indexes for table `login_details` -- ALTER TABLE `login_details` ADD PRIMARY KEY (`id`); -- -- Indexes for table `test` -- ALTER TABLE `test` ADD PRIMARY KEY (`id`); -- -- Indexes for table `token` -- ALTER TABLE `token` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `countries` -- ALTER TABLE `countries` MODIFY `id` int(3) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=130; -- -- AUTO_INCREMENT for table `employees` -- ALTER TABLE `employees` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `login_details` -- ALTER TABLE `login_details` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `test` -- ALTER TABLE `test` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27; -- -- AUTO_INCREMENT for table `token` -- ALTER TABLE `token` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` 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 */;
set linesi 1000 trims on pagesi 1000 ---------------------------------------------------------------------------- -- Step 4: -- The president makes the final decision. ---------------------------------------------------------------------------- DECLARE l_prin_id WF_PROCESS_INSTANCES.ID%TYPE; -- ID of new created process instance l_pati_id_president WF_PARTICIPANTS.ID%TYPE; -- ID of participant president l_acin_id WF_ACTIVITY_INSTANCES.ID%TYPE; -- ID of new created process instance l_worklist_cursor PL_FLOW.generic_curtype; -- a cursor variable l_worklist_record PL_FLOW.worklist_rowtype%ROWTYPE; -- PL_FLOW.worklist_rowtype is dummy cursor for %ROWTYPE l_dummy_int PLS_INTEGER; BEGIN -- At this point, there is a workitem on the worklist of the managers -- The manager is JONES, with pati_id 7566 SELECT id INTO l_pati_id_president FROM wf_participants WHERE description='PRESIDENT'; PL_FLOW.OpenWorkList( pworklist_filter => 'STATE=''NOTRUNNING''', pati_id_in => l_pati_id_president, count_flag => 0, -- should rowcount be returned? pquery_handle => l_worklist_cursor, pcount => l_dummy_int ); -- get the first workitem from this list -- please note that in this example, assumptions are being made about what this worklist -- query will return. In real life, the worklist will be displayed on screen FETCH l_worklist_cursor INTO l_worklist_record; CLOSE l_worklist_cursor; -- Now, tell PL/FLOW that KING starts with this workitem PL_FLOW.ChangeActivityInstanceState( acin_id_in => l_worklist_record.acin_id, state_in => 'RUNNING', pati_id_in => l_pati_id_president ); -- King decides to approve the request. PL_FLOW.AssignProcessInstanceAttribute( prin_id_in => l_worklist_record.prin_id, name_in => 'APPROVED', value_in => 'Y' ); -- Now, complete the same workitem PL_FLOW.ChangeActivityInstanceState( acin_id_in => l_worklist_record.acin_id, state_in => 'COMPLETED', pati_id_in => l_pati_id_president ); END; / Prompt Activity instances after KING completed 'decide on bonus request' SELECT acti_prce_id, acti_id, prin_id, id, state, date_created, date_started, date_ended FROM WF_ACTIVITY_INSTANCES / Prompt Performers after KING completed 'decide on bonus request' SELECT id, pati_id, acin_id, date_created, state, accepted FROM WF_PERFORMERS / -- Now there are two workitems, one for SCOTT, and one for the ACCOUNTING department.
drop table tbl_user if exists; drop table tbl_institute if exists; drop table tbl_funds if exists; drop table tbl_jwtauth if exists; CREATE TABLE tbl_user( usrid varchar(20) NOT NULL, passwd varchar(64) NOT NULL, SALT varchar(16) NOT NULL, PRIMARY KEY (usrid) ); CREATE TABLE tbl_jwtauth( usrid varchar(20) NOT NULL, strtdt varchar(14) NOT NULL, enddt varchar(14) NOT NULL, jwtval varchar(400) NOT NULL, PRIMARY KEY (usrid, enddt) ); CREATE UNIQUE INDEX TBL_JWTAUTH_IDX1 ON tbl_jwtauth(jwtval, enddt); CREATE TABLE tbl_institute( institute_name varchar(20) NOT NULL, institute_code char(3) NOT NULL, ordseq varchar(2) NOT NULL, PRIMARY KEY (institute_code) ); create table tbl_fund( hf_year char(4) NOT NULL, hf_month varchar(2) NOT NULL, institute_code char(3) NOT NULL, hf_amount INTEGER, PRIMARY KEY (hf_year, hf_month, institute_code ) );
INSERT INTO transactions VALUES('2019-10-08T09:00:00Z', '1111', 1, NULL) INSERT INTO transactions VALUES('2019-10-08T09:00:00Z', '2222', 1, 'aaaa-bbbb-cccc-dddd') INSERT INTO transactions VALUES('2019-10-08T09:00:00Z', '2222', 1, NULL) INSERT INTO transactions VALUES('2019-10-08T09:00:00Z', '7777', 1, 'mmmm-nnnn-oooo-pppp') INSERT INTO transactions VALUES('2019-10-09T09:00:00Z', '1111', 1, 'eeee-ffff-gggg-hhhh') INSERT INTO transactions VALUES('2019-10-09T09:00:00Z', '2222', 1, NULL) INSERT INTO transactions VALUES('2019-10-09T09:00:00Z', '2222', 1, 'aaaa-bbbb-cccc-dddd') INSERT INTO transactions VALUES('2019-10-09T09:00:00Z', '7777', 1, 'iiii-jjjj-kkkk-llll')
/* Question 5 */ --5.1 /*Get all the clients whose subscriptions are out of date */ SELECT cid FROM clients EXCEPT SELECT cid FROM subscriptions S WHERE S.enddate > '2018-01-01' LIMIT 50; --5.2 /* Show how much each drug appears in prescription for the female gender*/ SELECT PC.duid, sum(Pc.quantity) FROM prescriptions P, individuals I, prescriptioncontents Pc, drugs D WHERE P.cid = I.cid AND I.gender = 'Female' AND Pc.pid = P.pid AND D.duid=Pc.duid GROUP BY PC.duid ORDER BY PC.duid LIMIT 50; --5.3 /*Projects infos on each drug in order sorted by price and refills (and manufacturer and quantity)*/ SELECT D.duid, D.dname, D.manufacturer, D.price, PC.quantity, PC.refills FROM drugs D, prescriptioncontents PC WHERE PC.refills > 0 AND D.duid = PC.duid ORDER BY D.dname, D.price, PC.refills, D.manufacturer, PC.quantity LIMIT 50; --5.4 /*Shows the average money spent on plans by clients based on gender*/ SELECT I.gender,AVG(P.price::NUMERIC) FROM subscriptions S, individuals I, insuranceplans P WHERE S.planid = P.planid AND I.cid = S.cid GROUP BY I.gender; --5.5 /* Get adult individuals who have been reimbursed more than 20$ */ SELECT DISTINCT(I.birthdate), I.cid, SUM( Re.amount::NUMERIC ) FROM insuranceclaims IC, receipts R, individuals I, reimbursed Re, prescriptions P WHERE IC.rid = R.rid AND Re.icid = IC.icid AND IC.rid = R.rid AND R.pid = P.pid AND P.cid = I.cid AND I.cid IN( SELECT cid FROM individuals WHERE age(current_date, I.birthdate) >= '18 years' ) GROUP BY I.cid HAVING SUM( Re.amount::NUMERIC )> 20 LIMIT 50;
--////////////////////////////////////////////////////// 教委 ////////////////////////////////////////////////////////////////////////////////// select de042,c11,c21 from gz011cz where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000128 group by de042,c11,c21 order by de042; select * from v_gztfdwbm; select * from czcs041 where de011 = 2013 and jsde070 = 4 select * from gz011cz where de011 = 2013 and de007 = '08' and jsdeg124 = 1 and czde701 = 2 and de042 = '014051001' for update -- 未入账人员 select count(1) from gz011cz where de011 = 2013 and de007 = '11' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000128 and n254 <> 0 -- 14112 14101 select count(1) from gz011dw b where b.de011 = 2013 and b.de007 = '11' and b.czde701 = 2 and b.czde103 = 20130000000140 -- 14101 select c9,c10,de042,c11,c35,n254,c268,c21,c35 from gz011cz a where a.de011 = 2013 and a.de007 = '11' and a.jsdeg124 = 1 and a.czde701 = 2 and a.czde103 = 20130000000128 and a.n254 <> 0 and not exists (select 1 from gz011dw b where b.de011 = 2013 and b.de007 = '11' and b.czde701 = 2 and b.czde103 = 20130000000140 and a.c9 = b.c9); update gz_lasttime b set (b.n187, b.n194, b.n170, b.n171, b.n172, b.n181, b.n182, b.n235) = (select a.n187, a.n194, a.n170, a.n171, a.n172, a.n181, a.n182, a.n235 from gz011cz a where a.de011 = 2013 and a.de007 = '11' and a.jsdeg124 = 1 and a.czde701 = 2 and a.czde103 = 20130000000128 and a.c9 = b.c9) where exists (select 1 from gz011cz c where c.de011 = 2013 and c.de007 = '11' and c.jsdeg124 = 1 and c.czde701 = 2 and c.czde103 = 20130000000128 and b.c9 = c.c9); select count(1) from gz011cz where de011 = 2013 and de007 = '11' and jsdeg124= 1 and czde701 = 2 and czde103 = 20130000000128 -- 14112 -- 教委指标匹配 select de042,de194,czde904 from gz200 where de011 = 2013 and de007 = '12' order by de042,de194 --////////////////////////////////////////////////////// 单位 ////////////////////////////////////////////////////////////////////////////////// select de042,c11,c21 from gz011cz where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 1 and czde103 in (20130000000122,20130000000124,20130000000126) group by de042,c11,c21 order by de042; select * from gz011cz where de011 = 2013 and de007 = '08' and jsdeg124 = 1 and czde701 = 1 /*and czde103 = 20130000000122 */and de042 = '033001' update gz011cz set c21 = '00' where de011 = 2013 and de007 = '08' and jsdeg124 = 1 and czde701 = 1 and czde103 = 20130000000122 and de042 = '033001'; select * from czcs041 where de011 = 2013 and de041 like '%管%' and jsde070 = 4 select * from sstranscode where id = '200203' select * from cfg010 where de011 = 2013 select a.JSDE908 , a.DE042 ,a.JSDE910 ,a.DE022 from jscs012 a, czcs018 b where a.DE042 = b.DE042 and a.JSDE910 = b.JSDE910 and a.DE022 = b.DE022 and b.CZDE938 = 'J1' select * from jscs012 select * from czcs018 select * from jscs012 where JSDE908 ike '%%' select * from gz018 where jsde910 like '%YHL%' select jsde910,count(jsde955) from gz018 group by jsde910 create table gz018c20131107 as select * from gz018; select * from czcs041 where de011 =2013 and de041 like '%三聋%' select * from gz220 where de042 = '014167' -- WCL LJ ZXL select nvl(fieldnamel, ' '), nvl(fh, ' '), nvl(kh, ' ' ), nvl(fieldnamer, ' ' ) from bz032 where czde103 = and gsid = igsid order by gsmxid -- 未入账人员 select count(1) from gz011cz where de011 = 2013 and de007 = '11' and jsdeg124 = 1 and czde701 = 1 and czde103 in (20130000000122,20130000000124,20130000000126) and n254 <> 0 -- 18069 select c9,c10,de042,c11,c35,n254 from gz011cz a where a.de011 = 2013 and a.de007 = '11' and a.jsdeg124 = 1 and a.czde701 = 1 and a.czde103 in (20130000000122,20130000000124,20130000000126) and a.n254 <> 0 and not exists (select 1 from gz011dw b where b.de011 = 2013 and b.de007 = '11' and b.czde701 = 1 and b.czde103 = 20130000000140 and a.c9 = b.c9) -- 0000005104 李冬梅 034001 6922.00 select * from gz011cz where de011 = 2013 and de007 = '11' and jsdeg124 = 1 and czde701 = 1 and c9 = '0000006198' select * from xml where transcode = '030517' order by exdate desc select * from (select a.*, a.de181 as BCBX, row_number() over(order by HDDE135, DE001 desc) as rn from v1_gwkqgd a where HDDE120 = 1 and de022 = 110108 and JSDE955 like '104001%') where rn >= 1 and rn <= 50 update gz_lasttime b set (b.n187, b.n194, b.n170, b.n171, b.n172, b.n181, b.n182, b.n235) = (select a.n187, a.n194, a.n170, a.n171, a.n172, a.n181, a.n182, a.n235 from gz011cz a where a.de011 = 2013 and a.de007 = '11' and a.jsdeg124 = 1 and a.czde701 = 1 and a.czde103 = 20130000000122 and a.c9 = b.c9) where exists (select 1 from gz011cz c where c.de011 = 2013 and c.de007 = '11' and c.jsdeg124 = 1 and c.czde701 = 1 and c.czde103 = 20130000000122 and b.c9 = c.c9); select count(1) from gz011cz where de011 = 2013 and de007 = '11' and jsdeg124= 1 and czde701 = 1 and czde103 = 20130000000122 -- 13821 select a.n187, a.n194, a.n170, a.n171, a.n172, a.n181, a.n182, a.n235 from gz011cz a where a.de011 = 2013 and a.de007 = '11' and a.jsdeg124 = 1 and a.czde701 = 1 and a.czde103 = 20130000000122 select a.n187, a.n194, a.n170, a.n171, a.n172, a.n181, a.n182, a.n235 from gz_lasttime a where a.c9 not like 'J%' select * from xml where transcode = '400106' order by exdate desc; select * from gz011dw select * from gz011czw UPDATE GZ011DW SET DE007 = TRIM(TO_CHAR(DE007, '00')) WHERE DE011 = :B3 AND DE007 = TO_NUMBER(:B2) AND JSDEG124 = :B1 AND NVL(C22, '1') = '1' select TO_CHAR(05, 'FM00') from dual; select * from gz011cz where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and select * from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 1 and czde103 in (20130000000130,20130000000131,20130000000133) and c1 = '001001008003G' for update -- 0000144272 --////////////// 2013年12月1批次 金额拍平衡检查 //////////////////////////// -- 18978 -- 116474690.72 select sum(n254) from gz011dw where de011= 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 1 and czde103 in (20130000000130,20130000000131,20130000000133) and c259 = '工资'; -- 117189728.72 select sum(n254) from gz011dww where de011= 2013 and de007 = '12' and jsdeg124 = 1 and czde103 in (20130000000122,20130000000124,20130000000126); -- 715038 select sum(n254) from gz011dww where de011= 2013 and de007 = '12' and jsdeg124 = 1 and czde103 in (20130000000122,20130000000124,20130000000126) and (n196 > 0 or n197 > 0 or n201 > 0 or n203 > 0 or n204 > 0 or n204 > 0); select 117189728.72-715038 from dual; -- 116474690.72 select c10,c31 from gz011cz where de011= 2013 and de007 = '12' and jsdeg124 = 1 and czde103 in (20130000000122,20130000000124,20130000000126) and de042 = '041001' order by substr(c31,7,8) desc -- ///////////////// 下发工资 //////////////////////////////////////// select sum(n254),sum(n252),sum(n253) from gz011cz where de011= 2013 and de007 = '12' and jsdeg124 = 1 and czde103 in (20130000000122,20130000000124,20130000000126); -- 117189728.72 17435044.55 99754684.17 select 117189728.72-(17435044.55+99754684.17) from dual; --死亡人员 select c10,c9 from gz011cz where de011= 2013 and de007 = '12' and jsdeg124 = 1 and czde103 in (20130000000122,20130000000124,20130000000126) and (n196 > 0 or n197 > 0 or n201 > 0 or n203 > 0 or n204 > 0 or n204 > 0); -- 715038 0000148856 select * from gz_lasttime where c9 in (select c9 from gz011cz where de011= 2013 and de007 = '12' and jsdeg124 = 1 and czde103 in (20130000000122,20130000000124,20130000000126) and (n196 > 0 or n197 > 0 or n201 > 0 or n203 > 0 or n204 > 0 or n204 > 0)); -- 0000148856 select * from gz_lasttime where c10 = '尹宏章' for update; select * from gz011cz where de011= 2013 and de007 = '11' and jsdeg124 = 1 and czde103 in (20130000000122,20130000000124,20130000000126) and c10 = '尹宏章' and (n196 > 0 or n197 > 0 or n201 > 0 or n203 > 0 or n204 > 0 or n204 > 0) and c9 = '0000148856' select c9,c10,c11,de007 from gz011czw where c9 = '0000009325' -- c9 改变人员 select * from gz_lasttime where c9 like 'J%'; insert into gz_lasttime(c9,c10,c2,c35,c30,c36,c31,n187,n194,n170,n171,n172,n181,n182,n235,iss,id) select c9,c10,c2,c35,c30,c36,c31,n187,n194,n170,n171,n172,n181,n182,n235,0, rownum+338875 as id from gz011cz a where a.de011= 2013 and a.de007 = '12' and a.jsdeg124 = 1 and a.czde103 = 20130000000128 and a.czde701 = 2 and not exists(select 1 from gz_lasttime b where a.c9 = b.c9) order by id; select * from gz011cz a where a.de011= 2013 and a.de007 = '12' and a.jsdeg124 = 1 and a.czde103 in (20130000000122,20130000000124,20130000000126) and a.czde701 = 1 and not exists(select 1 from gz_lasttime b where a.c9 = b.c9); select de042,c11,c9,c10 from gz011cz b where b.de011= 2013 and b.de007 = '11' and b.jsdeg124 = 1 and b.czde103 in (20130000000122,20130000000124,20130000000126) and b.czde701 = 1 and b.c10 in ( select a.c10 from gz011cz a where a.de011= 2013 and a.de007 = '12' and a.jsdeg124 = 1 and a.czde103 in (20130000000122,20130000000124,20130000000126) and a.czde701 = 1 and not exists(select 1 from gz_lasttime b where a.c9 = b.c9)) order by c10; select de042,c11,c9,c10 from gz011cz a where a.de011= 2013 and a.de007 = '11' and a.jsdeg124 = 1 and a.czde103 in (20130000000122,20130000000124,20130000000126) and a.czde701 = 1 and c10 = '翟鹏'; -- /////////// 人事信息导入 ////////////////////////////////// ---- select * from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 1 and czde103 in (20130000000135,20130000000136,20130000000137) and c1 = '001001008003G' -- c270 select c1,c10, c270 from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 1 and czde103 in (20130000000135,20130000000136,20130000000137) and c270 = '行' for update -- 现有海淀区卫生监督所在职人员谭圆圆(身份证号:371083198606244029)工资关系标识错误, -- 请从后台进行调整,将其从海淀区农村工作委员会标识到其下属单位卫生监督所。 -- 002001 --> 002008 select * from gz011cz a where a.de011= 2013 and a.de007 = '12' and a.jsdeg124 = 1 and a.czde701 = 1 and de042 = '002008' and a.c31 = '371083198606244029'; update gz011cz a set a.de042 = '002008' , a.c1 = '002008' , a.c11 = '北京市海淀区动物卫生监督所' where a.de011= 2013 and a.de007 = '12' and a.jsdeg124 = 1 and a.czde701 = 1 and de042 = '002001' and a.c31 = '371083198606244029'; -- 052004 13581572658 指标无法取出 select distinct de007 from gz011cz where select jsde902 from bz007hd where czde103 = 20130000000124; -- 在职工资表, 离休工资表 退休工资表 select instr('在职工资表', '退休') from dual; insert into gz230(ctime,czde103,DE042,sjid,XMGDZC,SHJG, Jsdeg230) select distinct de042 from gz011cz where de011 = 2013 /*and de007 = '10' and jsdeg124 = 1*/ and czde701 = 1 and czde103 = 20130000000122 and c2 like '20805%' and c1 <> (select jsde902 from jscs001 where dataelement = 'GZLGBJDM'); select * from czcs041 where de011 = 2013 and de042 = '012001' select distinct c2 from gz011cz where de011 = 2013 and czde701 = 1 and czde103 = 20130000000124 and c2 like '20805%'; select * from xml where transcode = '40JC01' order by EXDATE DESC -- //////////////////////////////////// 工资预算执行情况表 ///////////////////////////////////////////////////////////// select distinct c2 from gz011cz where de011 = 2013 and de007 = '12'; select c1,c11,c2,c12,sum(n1) as je from v_bmys_jbzc_gztf where ysnf = 2013 and de042 in ('001001','001002') group by c1,c11,c2,c12 select de042,de084,sum(nvl(yfgz301,0)),sum(nvl(yfgz303,0)) from gz219 where de011 = 2013 and jsde940 = '88' and de042 in ('001001','001002') group by de042,de084; select c1,c2,sum(je) from ( select c1,c2,sum(n254) as je from gz011cz where de011 = 2013 and de007 <= 12 and czde103 in (20130000000122,20130000000124,20130000000126) and c2 like '20805%' group by c1,c2 union all select c1,c2,sum(n254) as je from gz011czw where de011 = 2013 and de007 <= 12 and czde103 in (20130000000122,20130000000124,20130000000126) and c2 like '20805%' group by c1,c2) group by c1,c2 order by c1 select c2 from gz011cz where de007 = '11' select c1,c2,sum(n254) as je from gz011cz where de011 = 2013 and de007 = '11' and czde103 in (20130000000122,20130000000124,20130000000126) and de042 in ('001001','001002') group by c1,c2; select count(1) from gz011cz where de011 = 2013 and de007 = '11' and czde701 = 1 select * from temp_data_hd select * from temp_data_hd_demo -- 274877095 -- 249300784.23 24897091.96 select sum(n1) from v_bmys_jbzc_gztf where ysnf = 2013 and c2 like '20805%' select sum(yfgz) from gz219 where de011 =2013 and de084 like '20805%' select (249300784.23 + 24897091.96)-274877095 from dual; select c1,c2,sum(je) from ( select c1,c2,sum(n254) as je from gz011cz where de011 = 2013 and de007 <= 12 and czde103 in (20130000000122,20130000000124,20130000000126) and de042 = '034001' group by c1,c2 union all select c1,c2,sum(n254) as je from gz011czw where de011 = 2013 and de007 <= 12 and czde103 in (20130000000122,20130000000124,20130000000126) and de042 = '034001' group by c1,c2) group by c1,c2 order by c1 -- 52455587.34 select sum(n1) from v_bmys_jbzc_gztf where ysnf = 2013 and c2 like '20805%' and de042 = '034001' select * from gz219 where de011 =2013 and de084 like '20805%' and de042 = '034001' select (47949768+3697415.18)- 52455587.34 from dual; select * from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 2 and czde103 = 20130000000141 and czde701 = 1; select * from gz011cz a where a.de011 =2013 and a.de007 = '12' and a.jsdeg124 = 1 and a.czde701 = 2 and a.czde103 =20130000000128 /*and a.c21 = '10'*/ and c9 in ( select * from gz011dw b where b.de011 = 2013 and b.de007 = '12' and b.jsdeg124 = 1 and b.czde103 = 20130000000141 ); UPDATE GZ011DW A SET C9 = (SELECT C9 FROM GZ011CZ B WHERE A.C35 = B.C35 AND A.C36 = B.C36 AND B.DE011 = 2013 AND B.DE007 = 12 AND CZDE701 = 2 AND JSDEG124 = 1 AND B.CZDE103 IN (SELECT A.CZDE103 FROM BZ007HD A, BZ007HD_1 B WHERE A.CZDE103 = B.CZDE103 AND A.DE011 = 2013 AND B.HDDE003 = 2 AND B.HDDE004 = CASE WHEN 2 = 1 THEN 41 ELSE 51 END AND CZDE004 = (SELECT DEVALUE FROM JSCS001 WHERE DATAELEMENT = 'GZTFZXTID'))) WHERE DE011 = 2013 AND DE007 = 12 AND JSDEG124 = 1 AND JSDEG232 = 1 AND NVL(C9, '0') = '0'; select * from xml where transcode = '400203' order by exdate desc; SELECT * FROM gz216 WHERE de011 = 2013 AND de007 = 12 AND czde701 = 1 AND jsdeg216 = 1 AND jsdeg232 = 1; select * from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde103 in( 20130000000141,20130000000140) and czde701 = 2; -- 6631 / 20 select * from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000141 and c35 = '034'; select * from gz011cz where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000128 and c35 = '034' and c21 = '10'; update gz011cz set c21 = '70' where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000128 and c35 = '034' and c21 = '10'; delete from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000141 and c35 = '034'; select * from gz216 where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 for update select c1,c9,c10,c35,c36 from gz011cz where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000128 and c1 = '014138' and c10 in ( select c10 from gz011dw where de011 = 2013 and de007 = '12' and jsdeg124 = 1 and czde701 = 2 and czde103 = 20130000000141 and c9 is null);
-- Remove all orders and related records DELETE FROM order_item_addons; DELETE FROM order_items; DELETE FROM shipping_requests; DELETE FROM shipping_tracks; DELETE FROM orders; -- Remove all customers DELETE FROM customers; -- Remove all you_images DELETE FROM you_images; -- Remove all not used product on page. DELETE FROM products WHERE name IN ( 'Dinner Getter', 'Blue Water', 'Lionfish', 'Inshore Shrinker', 'Offshore Striker', 'G-String', 'Cable Kit', 'Black Knife', 'Extra Tip', 'Cable', 'BigGame', 'FinFlashers', "9'ER", 'SuperHero', 'Comfort', 'Signature Glass', 'Barbed Glass', 'Sliptip Glass', 'Flopper Glass' );
-- phpMyAdmin SQL Dump -- version 4.7.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: 29 Okt 2018 pada 04.49 -- Versi Server: 10.1.28-MariaDB -- PHP Version: 7.1.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: `installer` -- CREATE DATABASE IF NOT EXISTS `installer` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; USE `installer`; -- -------------------------------------------------------- -- -- Struktur dari tabel `admin` -- DROP TABLE IF EXISTS `admin`; CREATE TABLE `admin` ( `admin_id` int(15) NOT NULL, `full_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `username` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(35) COLLATE utf8_unicode_ci NOT NULL, `level_user` int(15) NOT NULL, `photo` varchar(100) COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `admin` -- INSERT INTO `admin` (`admin_id`, `full_name`, `username`, `password`, `level_user`, `photo`) VALUES (1, 'Administrator', 'admin', '21232f297a57a5a743894a0e4a801fc3', 1, 'user.png'); -- -------------------------------------------------------- -- -- Struktur dari tabel `bulan` -- DROP TABLE IF EXISTS `bulan`; CREATE TABLE `bulan` ( `bulan_id` int(15) NOT NULL, `bulan_name` varchar(25) COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `bulan` -- INSERT INTO `bulan` (`bulan_id`, `bulan_name`) VALUES (1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'Oktober'), (11, 'November'), (12, 'December'); -- -------------------------------------------------------- -- -- Struktur dari tabel `menu` -- DROP TABLE IF EXISTS `menu`; CREATE TABLE `menu` ( `menu_id` int(15) NOT NULL, `menu_name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `menu_link` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `menu_icon` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `menu_parent` int(15) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `menu` -- INSERT INTO `menu` (`menu_id`, `menu_name`, `menu_link`, `menu_icon`, `menu_parent`) VALUES (1, 'dashboard', 'dashboard', 'fa fa-dashboard', 0), (2, 'master', '', 'fa fa-desktop', 0), (3, 'data mesin', 'mesin', 'fa fa-hand-o-right', 2), (5, 'menu setting', 'menu', 'fa fa-hand-o-right', 2), (6, 'menu user', 'menu/menu_user', 'fa fa-hand-o-right', 2), (7, 'transaction', 'transaction', 'fa fa-star', 0), (8, 'admin', 'user/admin', 'fa fa-hand-o-right', 2), (9, 'summary report', 'report/summary', 'fa fa-folder', 0), (10, 'user', 'user', 'fa fa-hand-o-right', 2); -- -------------------------------------------------------- -- -- Struktur dari tabel `menu_access` -- DROP TABLE IF EXISTS `menu_access`; CREATE TABLE `menu_access` ( `access_id` int(15) NOT NULL, `menu_id` int(15) NOT NULL, `level_user_id` int(15) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `menu_access` -- INSERT INTO `menu_access` (`access_id`, `menu_id`, `level_user_id`) VALUES (1, 1, 1), (2, 2, 1), (3, 3, 1), (5, 5, 1), (6, 6, 1), (7, 7, 1), (8, 8, 1), (9, 9, 1), (10, 7, 2), (11, 9, 2), (12, 1, 2), (13, 10, 1), (14, 10, 2), (16, 2, 2); -- -------------------------------------------------------- -- -- Struktur dari tabel `mesin` -- DROP TABLE IF EXISTS `mesin`; CREATE TABLE `mesin` ( `mesin_id` int(15) NOT NULL, `nama_mesin` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `rupiah` int(15) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `mesin` -- INSERT INTO `mesin` (`mesin_id`, `nama_mesin`, `rupiah`) VALUES (1, 'MP4800', 15000), (2, 'MP1000', 15000); -- -------------------------------------------------------- -- -- Struktur dari tabel `transaction` -- DROP TABLE IF EXISTS `transaction`; CREATE TABLE `transaction` ( `transaction_id` int(15) NOT NULL, `customer` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `mesin_id` int(15) NOT NULL, `sn` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `submit_date` date NOT NULL, `user_id` int(15) DEFAULT NULL, `approved` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `transaction` -- INSERT INTO `transaction` (`transaction_id`, `customer`, `mesin_id`, `sn`, `submit_date`, `user_id`, `approved`) VALUES (15, 'Test', 1, '0101', '2018-10-15', 2, ''), (17, 'Test2', 2, '0102', '2018-10-15', 2, ''), (18, 'dsfs', 1, '215314', '2018-10-02', 2, ''), (19, 'dsfs', 1, '215314', '2018-04-02', 2, 'Approved'), (20, 'Ridho', 1, '1234', '2018-10-25', 3, 'Approved'), (28, 'Ridho', 1, '123', '2018-06-26', 3, 'Approved'), (29, 'Ridho', 1, '123', '2018-10-26', 3, 'Approved'); -- -------------------------------------------------------- -- -- Struktur dari tabel `userinfo` -- DROP TABLE IF EXISTS `userinfo`; CREATE TABLE `userinfo` ( `user_id` int(15) NOT NULL, `full_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(35) COLLATE utf8_unicode_ci NOT NULL, `phone` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `company_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `atas_nama` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `nama_bank` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `no_rek` int(15) NOT NULL, `photo` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `level_user` int(15) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `userinfo` -- INSERT INTO `userinfo` (`user_id`, `full_name`, `email`, `password`, `phone`, `company_name`, `atas_nama`, `nama_bank`, `no_rek`, `photo`, `level_user`) VALUES (2, 'user', 'user@email.com', 'ee11cbb19052e40b07aac0ca060c23ee', '088', 'HIT PB', 'user', 'ABC', 998877, 'user.png', 2), (3, 'Ridho', 'ridho@mail.com', '202cb962ac59075b964b07152d234b70', '123', 'qwe', 'zxc', 'asd', 123, 'Koala.jpg', 2); -- -------------------------------------------------------- -- -- Struktur dari tabel `user_level` -- DROP TABLE IF EXISTS `user_level`; CREATE TABLE `user_level` ( `level_user_id` int(15) NOT NULL, `level_name` varchar(25) COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `user_level` -- INSERT INTO `user_level` (`level_user_id`, `level_name`) VALUES (1, 'administrator'), (2, 'customer'); -- -- Indexes for dumped tables -- -- -- Indexes for table `admin` -- ALTER TABLE `admin` ADD PRIMARY KEY (`admin_id`), ADD KEY `level_user` (`level_user`); -- -- Indexes for table `bulan` -- ALTER TABLE `bulan` ADD PRIMARY KEY (`bulan_id`); -- -- Indexes for table `menu` -- ALTER TABLE `menu` ADD PRIMARY KEY (`menu_id`); -- -- Indexes for table `menu_access` -- ALTER TABLE `menu_access` ADD PRIMARY KEY (`access_id`), ADD KEY `menu_id` (`menu_id`), ADD KEY `level_user_id` (`level_user_id`); -- -- Indexes for table `mesin` -- ALTER TABLE `mesin` ADD PRIMARY KEY (`mesin_id`); -- -- Indexes for table `transaction` -- ALTER TABLE `transaction` ADD PRIMARY KEY (`transaction_id`), ADD KEY `mesin_id` (`mesin_id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `userinfo` -- ALTER TABLE `userinfo` ADD PRIMARY KEY (`user_id`), ADD KEY `level_user` (`level_user`); -- -- Indexes for table `user_level` -- ALTER TABLE `user_level` ADD PRIMARY KEY (`level_user_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `admin` -- ALTER TABLE `admin` MODIFY `admin_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `bulan` -- ALTER TABLE `bulan` MODIFY `bulan_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; -- -- AUTO_INCREMENT for table `menu` -- ALTER TABLE `menu` MODIFY `menu_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT for table `menu_access` -- ALTER TABLE `menu_access` MODIFY `access_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; -- -- AUTO_INCREMENT for table `mesin` -- ALTER TABLE `mesin` MODIFY `mesin_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `transaction` -- ALTER TABLE `transaction` MODIFY `transaction_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30; -- -- AUTO_INCREMENT for table `userinfo` -- ALTER TABLE `userinfo` MODIFY `user_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `user_level` -- ALTER TABLE `user_level` MODIFY `level_user_id` int(15) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables) -- -- -- Ketidakleluasaan untuk tabel `admin` -- ALTER TABLE `admin` ADD CONSTRAINT `admin_ibfk_1` FOREIGN KEY (`level_user`) REFERENCES `user_level` (`level_user_id`); -- -- Ketidakleluasaan untuk tabel `menu_access` -- ALTER TABLE `menu_access` ADD CONSTRAINT `menu_access_ibfk_1` FOREIGN KEY (`level_user_id`) REFERENCES `user_level` (`level_user_id`), ADD CONSTRAINT `menu_access_ibfk_2` FOREIGN KEY (`menu_id`) REFERENCES `menu` (`menu_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Ketidakleluasaan untuk tabel `transaction` -- ALTER TABLE `transaction` ADD CONSTRAINT `transaction_ibfk_1` FOREIGN KEY (`mesin_id`) REFERENCES `mesin` (`mesin_id`), ADD CONSTRAINT `transaction_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `userinfo` (`user_id`); -- -- Ketidakleluasaan untuk tabel `userinfo` -- ALTER TABLE `userinfo` ADD CONSTRAINT `userinfo_ibfk_1` FOREIGN KEY (`level_user`) REFERENCES `user_level` (`level_user_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 */;
-- phpMyAdmin SQL Dump -- version 5.0.1 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Sep 28, 2020 at 05:36 PM -- Server version: 10.4.11-MariaDB -- PHP Version: 7.4.2 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: `foodfresh` -- -- -------------------------------------------------------- -- -- Table structure for table `distributor` -- CREATE TABLE `distributor` ( `id` bigint(20) UNSIGNED NOT NULL, `nama_distributor` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `wa_distributor` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `des_distributor` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `distributor` -- INSERT INTO `distributor` (`id`, `nama_distributor`, `wa_distributor`, `des_distributor`, `created_at`, `updated_at`) VALUES (1, 'distributor 1', '+62895708870305', 'Ikan', NULL, '2020-09-28 04:01:45'), (2, 'Distributor2', '081234512345', 'Sayur dan buah', '2020-09-28 03:21:22', '2020-09-28 03:21:22'); -- -------------------------------------------------------- -- -- Table structure for table `failed_jobs` -- CREATE TABLE `failed_jobs` ( `id` bigint(20) UNSIGNED NOT NULL, `connection` text COLLATE utf8mb4_unicode_ci NOT NULL, `queue` text COLLATE utf8mb4_unicode_ci NOT NULL, `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `failed_at` timestamp NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- -- -- Table structure for table `kategori` -- CREATE TABLE `kategori` ( `id` bigint(20) UNSIGNED NOT NULL, `nama_kategori` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `kategori` -- INSERT INTO `kategori` (`id`, `nama_kategori`, `created_at`, `updated_at`) VALUES (1, 'Fresh Food', NULL, NULL), (2, 'Fish & Meat', NULL, NULL), (3, 'Fruit & Vegetable', NULL, NULL); -- -------------------------------------------------------- -- -- Table structure for table `keranjang` -- CREATE TABLE `keranjang` ( `id` bigint(20) UNSIGNED NOT NULL, `id_konsumen` bigint(20) UNSIGNED NOT NULL, `id_produk` bigint(20) UNSIGNED NOT NULL, `total_produk` double NOT NULL, `total_harga` double NOT NULL, `status_produk` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1', `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `keranjang` -- INSERT INTO `keranjang` (`id`, `id_konsumen`, `id_produk`, `total_produk`, `total_harga`, `status_produk`, `created_at`, `updated_at`) VALUES (6, 1, 3, 1, 20000, '3', '2020-09-28 01:23:59', '2020-09-28 01:30:02'), (7, 1, 2, 1, 111110000, '3', '2020-09-28 01:24:04', '2020-09-28 01:30:02'), (8, 1, 3, 1, 20000, '3', '2020-09-28 01:34:44', '2020-09-28 01:35:12'), (9, 2, 2, 1, 111110000, '3', '2020-09-28 03:22:26', '2020-09-28 03:22:48'); -- -------------------------------------------------------- -- -- Table structure for table `konsumen` -- CREATE TABLE `konsumen` ( `id` bigint(20) UNSIGNED NOT NULL, `id_users` bigint(20) UNSIGNED NOT NULL, `nama_konsumen` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `alamat_konsumen` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `wa_konsumen` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `konsumen` -- INSERT INTO `konsumen` (`id`, `id_users`, `nama_konsumen`, `alamat_konsumen`, `wa_konsumen`, `created_at`, `updated_at`) VALUES (1, 2, 'Afsri', 'Padang', '081267597033', NULL, NULL), (2, 3, 'Afdal', 'Padang', '08127978787878', '2020-09-28 03:22:12', '2020-09-28 03:22:12'); -- -------------------------------------------------------- -- -- Table structure for table `kurir` -- CREATE TABLE `kurir` ( `id` bigint(20) UNSIGNED NOT NULL, `nama_kurir` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `wa_kurir` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `des_kurir` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `kurir` -- INSERT INTO `kurir` (`id`, `nama_kurir`, `wa_kurir`, `des_kurir`, `created_at`, `updated_at`) VALUES (1, 'Ramayana', '0808078080808', 'Kurir1', NULL, NULL); -- -------------------------------------------------------- -- -- Table structure for table `level` -- CREATE TABLE `level` ( `id` bigint(20) UNSIGNED NOT NULL, `nama_level` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `deskripsi_level` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `level` -- INSERT INTO `level` (`id`, `nama_level`, `deskripsi_level`, `created_at`, `updated_at`) VALUES (1, 'admin', 'admin', NULL, NULL), (2, 'konsumen', 'konsumen', NULL, NULL); -- -------------------------------------------------------- -- -- Table structure for table `migrations` -- CREATE TABLE `migrations` ( `id` int(10) UNSIGNED NOT NULL, `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `batch` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `migrations` -- INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1, '2014_10_11_000000_craete_level_table', 1), (2, '2014_10_12_000000_create_users_table', 1), (3, '2014_10_12_100000_create_password_resets_table', 1), (4, '2019_08_19_000000_create_failed_jobs_table', 1), (5, '2020_08_25_051155_create_kategori_table', 1), (6, '2020_08_25_051456_create_distributor_table', 1), (7, '2020_08_25_051742_create_produk_table', 1), (8, '2020_08_25_052127_create_kurir_table', 1), (9, '2020_08_25_052320_create_konsumen_table', 1), (10, '2020_08_25_052524_create_keranjang_table', 1), (11, '2020_08_25_052825_create_pembayaran_table', 1), (12, '2020_08_25_053050_create_pemesanan_table', 1), (13, '2020_09_02_054118_upload_bukti', 1), (14, '2020_09_19_035733_create_pembelian_table', 1), (15, '2020_09_28_041122_create_detail_pembelian_view', 1); -- -------------------------------------------------------- -- -- Table structure for table `password_resets` -- CREATE TABLE `password_resets` ( `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- -- -- Table structure for table `pembayaran` -- CREATE TABLE `pembayaran` ( `id` bigint(20) UNSIGNED NOT NULL, `id_konsumen` bigint(20) UNSIGNED NOT NULL, `total_pembayaran` double NOT NULL, `status_pembayaran` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0', `tgl_pembayaran` date DEFAULT NULL, `bukti_pembayaran` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `pembayaran` -- INSERT INTO `pembayaran` (`id`, `id_konsumen`, `total_pembayaran`, `status_pembayaran`, `tgl_pembayaran`, `bukti_pembayaran`, `created_at`, `updated_at`) VALUES (5, 1, 111130000, '1', '2020-09-29', 'bukti/Afsri/r7eyV3J3orrycP4ksZNLSbSdiC4SWqsrrY0OwT0s.jpeg', '2020-09-28 01:30:02', '2020-09-28 01:35:44'), (6, 1, 20000, '1', '2020-09-28', 'bukti/Afsri/0g8ycqLs9RH56d5jGAGO1sWEvjMzDXXPq2PZMzKF.jpeg', '2020-09-28 01:35:11', '2020-09-28 02:15:17'), (7, 2, 111110000, '1', '2020-09-28', 'bukti/Afdal/mBZ7iIC1RLbHI0ms3kWBMu6fdxa5ir4OxiXjeB8E.png', '2020-09-28 03:22:48', '2020-09-28 03:23:16'); -- -------------------------------------------------------- -- -- Table structure for table `pembelian` -- CREATE TABLE `pembelian` ( `id` bigint(20) UNSIGNED NOT NULL, `id_konsumen` bigint(20) UNSIGNED NOT NULL, `id_keranjang` bigint(20) UNSIGNED NOT NULL, `id_pembayaran` bigint(20) UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `pembelian` -- INSERT INTO `pembelian` (`id`, `id_konsumen`, `id_keranjang`, `id_pembayaran`, `created_at`, `updated_at`) VALUES (1, 1, 6, 5, '2020-09-28 01:30:02', '2020-09-28 01:30:02'), (2, 1, 7, 5, '2020-09-28 01:30:02', '2020-09-28 01:30:02'), (3, 1, 8, 6, '2020-09-28 01:35:11', '2020-09-28 01:35:11'), (4, 2, 9, 7, '2020-09-28 03:22:48', '2020-09-28 03:22:48'); -- -------------------------------------------------------- -- -- Table structure for table `pemesanan` -- CREATE TABLE `pemesanan` ( `id` bigint(20) UNSIGNED NOT NULL, `id_pembayaran` bigint(20) UNSIGNED NOT NULL, `id_kurir` bigint(20) UNSIGNED DEFAULT NULL, `tgl_pemesanan` date DEFAULT NULL, `status_pemesanan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0', `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `pemesanan` -- INSERT INTO `pemesanan` (`id`, `id_pembayaran`, `id_kurir`, `tgl_pemesanan`, `status_pemesanan`, `created_at`, `updated_at`) VALUES (2, 5, 1, '2020-09-28', '0', '2020-09-28 01:35:44', '2020-09-28 02:15:32'), (3, 6, 1, '2020-09-28', '0', '2020-09-28 02:15:17', '2020-09-28 02:15:38'), (4, 7, NULL, '2020-09-28', '0', '2020-09-28 03:23:16', '2020-09-28 03:23:16'); -- -------------------------------------------------------- -- -- Table structure for table `produk` -- CREATE TABLE `produk` ( `id` bigint(20) UNSIGNED NOT NULL, `gambar_produk` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `nama_produk` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `id_kategori` bigint(20) UNSIGNED NOT NULL, `harga_produk` double NOT NULL, `des_produk` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `id_distributor` bigint(20) UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `produk` -- INSERT INTO `produk` (`id`, `gambar_produk`, `nama_produk`, `id_kategori`, `harga_produk`, `des_produk`, `id_distributor`, `created_at`, `updated_at`) VALUES (2, 'produk/ubu6fbK8822tPgrGH8avjJdLYFLfLG0QteMS6amW.jpeg', 'A1', 3, 111110000, '500 gr', 2, '2020-09-28 00:58:26', '2020-09-28 03:24:22'), (3, 'produk/K53C1QFbv8uGKCTuA0p1XWol4yfsbRHbd7gWU5w0.jpeg', 'A2', 2, 20000, '500 gr', 1, '2020-09-28 00:58:47', '2020-09-28 00:58:47'), (4, 'produk/z99X51CP2ubxMuwBJpXGZHwGNBeswPM0LeZOD7Wk.jpeg', 'A3', 1, 20000, '444', 1, '2020-09-28 00:59:05', '2020-09-28 00:59:05'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` bigint(20) UNSIGNED NOT NULL, `id_level` bigint(20) UNSIGNED NOT NULL, `username` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `api_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `email_verified_at` timestamp NULL DEFAULT NULL, `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `id_level`, `username`, `email`, `api_token`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES (1, 1, 'admin', 'admin@admin.com', 'PyICTPYXBGtuMC1tkG5MfsqRfaSjG5zbCMPyVYgJe8igFifloIBi2C3X0gOjyKjQPlmwVuxyCCHtqfGrw27fpP7esVzzHZyHMeP8KWBPHY20LRBUuL6cwHtleT1x21UScyKxR571krWGmdP3qNh3Ex1', NULL, '$2y$10$mwRtwL4aBNfjry5kO5/b6ODFAYCvfBky6FdwWWb0xFiyiDuFs1ysy', NULL, NULL, '2020-09-28 01:41:16'), (2, 2, 'konsumen', 'konsumen@konsumen.com', NULL, NULL, '$2y$10$wdODiGSaRRggRDmNtxsap.B6wUxX6Yaa2tYjd5pAMcmvNO9KK5JHC', NULL, NULL, NULL), (3, 2, 'afdalsaja', 'afdal@afdal.com', NULL, NULL, '$2y$10$plYURFxJCCF2QRZNu9X.1OlT77fdAeBaTGvk6pdLLz7eHc2cfys2W', NULL, '2020-09-28 03:22:12', '2020-09-28 03:22:12'); -- -- Indexes for dumped tables -- -- -- Indexes for table `distributor` -- ALTER TABLE `distributor` ADD PRIMARY KEY (`id`); -- -- Indexes for table `failed_jobs` -- ALTER TABLE `failed_jobs` ADD PRIMARY KEY (`id`); -- -- Indexes for table `kategori` -- ALTER TABLE `kategori` ADD PRIMARY KEY (`id`); -- -- Indexes for table `keranjang` -- ALTER TABLE `keranjang` ADD PRIMARY KEY (`id`), ADD KEY `keranjang_id_konsumen_foreign` (`id_konsumen`), ADD KEY `keranjang_id_produk_foreign` (`id_produk`); -- -- Indexes for table `konsumen` -- ALTER TABLE `konsumen` ADD PRIMARY KEY (`id`), ADD KEY `konsumen_id_users_foreign` (`id_users`); -- -- Indexes for table `kurir` -- ALTER TABLE `kurir` ADD PRIMARY KEY (`id`); -- -- Indexes for table `level` -- ALTER TABLE `level` ADD PRIMARY KEY (`id`); -- -- Indexes for table `migrations` -- ALTER TABLE `migrations` ADD PRIMARY KEY (`id`); -- -- Indexes for table `password_resets` -- ALTER TABLE `password_resets` ADD KEY `password_resets_email_index` (`email`); -- -- Indexes for table `pembayaran` -- ALTER TABLE `pembayaran` ADD PRIMARY KEY (`id`), ADD KEY `pembayaran_id_konsumen_foreign` (`id_konsumen`); -- -- Indexes for table `pembelian` -- ALTER TABLE `pembelian` ADD PRIMARY KEY (`id`), ADD KEY `pembelian_id_konsumen_foreign` (`id_konsumen`), ADD KEY `pembelian_id_keranjang_foreign` (`id_keranjang`), ADD KEY `pembelian_id_pembayaran_foreign` (`id_pembayaran`); -- -- Indexes for table `pemesanan` -- ALTER TABLE `pemesanan` ADD PRIMARY KEY (`id`), ADD KEY `pemesanan_id_pembayaran_foreign` (`id_pembayaran`), ADD KEY `pemesanan_id_kurir_foreign` (`id_kurir`); -- -- Indexes for table `produk` -- ALTER TABLE `produk` ADD PRIMARY KEY (`id`), ADD KEY `produk_id_kategori_foreign` (`id_kategori`), ADD KEY `produk_id_distributor_foreign` (`id_distributor`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `users_email_unique` (`email`), ADD UNIQUE KEY `users_username_unique` (`username`), ADD UNIQUE KEY `users_api_token_unique` (`api_token`), ADD KEY `users_id_level_foreign` (`id_level`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `distributor` -- ALTER TABLE `distributor` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `failed_jobs` -- ALTER TABLE `failed_jobs` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `kategori` -- ALTER TABLE `kategori` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `keranjang` -- ALTER TABLE `keranjang` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- AUTO_INCREMENT for table `konsumen` -- ALTER TABLE `konsumen` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `kurir` -- ALTER TABLE `kurir` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `level` -- ALTER TABLE `level` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `migrations` -- ALTER TABLE `migrations` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; -- -- AUTO_INCREMENT for table `pembayaran` -- ALTER TABLE `pembayaran` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `pembelian` -- ALTER TABLE `pembelian` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `pemesanan` -- ALTER TABLE `pemesanan` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `produk` -- ALTER TABLE `produk` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- Constraints for dumped tables -- -- -- Constraints for table `keranjang` -- ALTER TABLE `keranjang` ADD CONSTRAINT `keranjang_id_konsumen_foreign` FOREIGN KEY (`id_konsumen`) REFERENCES `konsumen` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `keranjang_id_produk_foreign` FOREIGN KEY (`id_produk`) REFERENCES `produk` (`id`) ON DELETE CASCADE; -- -- Constraints for table `konsumen` -- ALTER TABLE `konsumen` ADD CONSTRAINT `konsumen_id_users_foreign` FOREIGN KEY (`id_users`) REFERENCES `users` (`id`) ON DELETE CASCADE; -- -- Constraints for table `pembayaran` -- ALTER TABLE `pembayaran` ADD CONSTRAINT `pembayaran_id_konsumen_foreign` FOREIGN KEY (`id_konsumen`) REFERENCES `konsumen` (`id`) ON DELETE CASCADE; -- -- Constraints for table `pembelian` -- ALTER TABLE `pembelian` ADD CONSTRAINT `pembelian_id_keranjang_foreign` FOREIGN KEY (`id_keranjang`) REFERENCES `keranjang` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `pembelian_id_konsumen_foreign` FOREIGN KEY (`id_konsumen`) REFERENCES `konsumen` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `pembelian_id_pembayaran_foreign` FOREIGN KEY (`id_pembayaran`) REFERENCES `pembayaran` (`id`) ON DELETE CASCADE; -- -- Constraints for table `pemesanan` -- ALTER TABLE `pemesanan` ADD CONSTRAINT `pemesanan_id_kurir_foreign` FOREIGN KEY (`id_kurir`) REFERENCES `kurir` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `pemesanan_id_pembayaran_foreign` FOREIGN KEY (`id_pembayaran`) REFERENCES `pembayaran` (`id`) ON DELETE CASCADE; -- -- Constraints for table `produk` -- ALTER TABLE `produk` ADD CONSTRAINT `produk_id_distributor_foreign` FOREIGN KEY (`id_distributor`) REFERENCES `distributor` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `produk_id_kategori_foreign` FOREIGN KEY (`id_kategori`) REFERENCES `kategori` (`id`) ON DELETE CASCADE; -- -- Constraints for table `users` -- ALTER TABLE `users` ADD CONSTRAINT `users_id_level_foreign` FOREIGN KEY (`id_level`) REFERENCES `level` (`id`) ON DELETE 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 */;
/*Shipments processed in WISYS, already invoiced, join with OH history to gather updated tracking and carrier if available*/ SELECT ltrim(oh.ord_no) AS Ord_No, OH.cus_alt_adr_cd AS [Store], CASE WHEN LEN(cmt_1) = 3 THEN cmt_1 ELSE oh.ship_via_cd END AS [Carrier_Cd], pp.loc AS loc, OH.cmt_3 AS [tracking_no], 'INVOICED' AS [zone], pp.weight AS [Ship_weight], pp.Qty AS Qty, CASE WHEN pp.ship_dt IS NULL THEN inv_dt ELSE CONVERT(varchar(10), pp.ship_dt, 101) END AS [Shipped Dt], pp.item_no, CASE WHEN PP.pallet IS NULL THEN ltrim(PP.Carton_UCC128) ELSE ltrim(pp.Pallet_UCC128) END AS [Pallet/Carton ID], 'Y' AS Shipped FROM oehdrhst_sql OH LEFT OUTER JOIN [001].dbo.wsPikPak pp ON oh.ord_no = pp.ord_no LEFT OUTER JOIN [001].dbo.wsShipment ws ON ws.shipment = pp.shipment LEFT OUTER JOIN [001].dbo.oebolfil_sql BL ON BL.bol_no = ws.bol_no WHERE item_no = 'DVD DUMPKIT1RS' UNION ALL /*Shipments processed in WISYS, not yet invoiced*/ SELECT ltrim(oh.ord_no) AS Ord_No, OH.cus_alt_adr_cd AS [Store], CASE WHEN bl.ship_via_cd IS NULL THEN oh.ship_via_cd ELSE bl.ship_via_cd END AS [Carrier_Cd], pp.loc AS loc, pp.TrackingNo[tracking_no], 'SHIPPED BUT OPEN' AS [zone], pp.weight AS [Ship_weight], pp.Qty AS Qty, CONVERT(varchar(10), pp.ship_dt, 101) AS [Shipped Dt], pp.item_no, CASE WHEN PP.pallet IS NULL THEN ltrim(PP.Carton_UCC128) ELSE ltrim(pp.Pallet_UCC128) END AS [Pallet/Carton ID], pp.shipped FROM oeordhdr_sql OH INNER JOIN [001].dbo.wsPikPak pp ON oh.ord_no = pp.ord_no LEFT OUTER JOIN [001].dbo.wsShipment ws ON ws.shipment = pp.shipment LEFT OUTER JOIN [001].dbo.oebolfil_sql BL ON BL.bol_no = ws.bol_no WHERE item_no = 'DVD DUMPKIT1RS' AND shipped = 'Y'
/*The first schema is here to hold information about humans. IE. the employees and the clients. They're a similar idea so I grouped them together. This second schema hold the information pertaining to events. Where they are, policies, types, etc and a table to hold all the information needed for a whole event. This final schema hold the booked information. Services that are booked and events that are booked. This information is different than the second schema because these are official records rather than options at a buffet to be booked so I grouped them seperately.*/ CREATE DATABASE employeesClients; CREATE DATABASE buildEvents; CREATE DATABASE booked; USE employeesClients; CREATE TABLE employeeRoles ( roleID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, roleName VARCHAR(15) ); INSERT INTO employeeRoles (roleName) VALUES ("Planner"), ("Chef"), ("Cleaner"), ("Security"), ("DJ"); CREATE TABLE employeeDepartments ( departmentID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, departmentName VARCHAR(25) ); INSERT INTO employeeDepartments (departmentName) VALUES ("Cooking"), ("Sales"), ("Planning"), ("Cleaning"), ("Music"); CREATE TABLE employees ( employeeID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, employeeFirstName VARCHAR(10), employeeLastName VARCHAR(20), roleID int, departmentID int, employeeAddress VARCHAR(40), employeeCity VARCHAR(20), employeePostalCode VARCHAR(7), employeePhoneNumber VARCHAR(18), FOREIGN KEY employees_department (departmentID) REFERENCES employeeDepartments(departmentID), FOREIGN KEY employees_role (roleID) REFERENCES employeeRoles(roleID) ); INSERT INTO employees (employeeFirstName, employeeLastName, roleID, departmentID, employeeAddress, employeeCity, employeePostalCode, employeePhoneNumber) VALUES ("Tom", "Clancy", 1, 3, "25 Toronto Street", "Bradford", "L3Z 9Y7", "456 865-1274"), ("Susan", "Brown", 2, 1, "78 Winston Avenue", "Ottawa", "K8T 7Q7", "(879) 429-7266"), ("Victoria", "Wetherfield", 4, 2, "9254 Park Crescent", "Churchill", "L4C 8W1", "(905) 125-4752"), ("Larry", "Colborne", 3, 3, "147 Cunningham Parkway", "Celadon", "M3C 8F4", "(586) 144-3951"), ("Kayla", "Burns", 5, 5, "34 Newbie Drive", "Barrie", "L9N 5F5", "(905) 778-1369"); CREATE TABLE clients ( clientID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, clientFirstName VARCHAR(10), clientLastName VARCHAR(20), clientAddress VARCHAR(40), clientCity VARCHAR(20), clientPostalCode VARCHAR(7), clientPhoneNumber VARCHAR(16) ); INSERT INTO clients (clientFirstName, clientLastName, clientAddress, clientCity, clientPostalCode, clientPhoneNumber) VALUES("Terry", "Silver", "87 Terrace Drive", "Toronto", "M4L C9F", "(416) 128-1269"), ("Ronald","Clear", "12358 Valhalla Drive", "King", "G6H L7C", "(416) 855-4556"), ("Penelope", "Xing", "125 Happy Avenue", "Barrie", "H6G 0M5", "(785) 698-1238"), ("Hope", "Smith", "854 Barrie Street", "Vaughan", "M5G 0N9", "(554) 524-4458"), ("John", "Martson", "1 King Way", "South Gwillimbury", "L3M 1F3", "(645) 726-7453"); /*----------------------------------------------------------------------*/ USE buildEvents; CREATE TABLE eventTypes ( typeID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, eventType VARCHAR(15), eventPrice double, typeBookable bit ); INSERT INTO eventTypes (eventType, eventPrice, typeBookable) VALUES ("Birthday", 170.99, 0), ("Reception", 499.99, 0), ("Funeral", 0.0, 1), ("Anniversary", 189.99, 0), ("Y2K Party", 0.0, 1); CREATE TABLE eventLocations ( locationID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, city VARCHAR(20) ); INSERT INTO eventLocations (city) VALUES ("Barrie"), ("Bradford"), ("Toronto"), ("Ottawa"), ("Halifax"); CREATE TABLE venues ( venueID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, venueName VARCHAR(40), venueAddress VARCHAR(40), locationID int, venuePostalCode VARCHAR(7), venuePhoneNumber VARCHAR(18), venuePrice double, FOREIGN KEY venues_location (locationID) REFERENCES locations(locationID) ); INSERT INTO venues(venueName, venueAddress, venueCity, venuePostalCode, venuePhoneNumber, venuePrice) VALUES("Barrie Legion", "345 Ashton Street", "Barrie", "L2P 0A1", "(905) 845-9835", 150), ("Eutker Hall","8542 Matilda Drive","Toronto","M4S 0I3","(416) 158-4369", 300), ("Hilton Hotel","34 Perfect Street", "Ottawa", "4M7 8W1","(588) 924-6462", 80), ("Lacquered Vineyard","62 Coastal Avenue","Halifax","V2G 9J5","(634) 915-8235", 350), ("Halifax Town Hall","9 Centre Street"," Halifax","D3B 0H5","(634) 871-3985", 250); CREATE TABLE policies ( policyID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, locationID int, typeID int, policyName VARCHAR(30), policyDescription VARCHAR(200), FOREIGN KEY policies_locations (locationID) REFERENCES eventLocations(locationID), FOREIGN KEY policies_eventTypes (typeID) REFERENCES eventTypes(typeID) ); INSERT INTO policies (locationID, typeID, policyName, policyDescription) VALUES (1, 1, "No Drinking", "No drinking on the premises or to be snuck in. If found, perpetrator will be escorted off property"), (2, 2, "No Noise Past 2AM", "Due to noise laws in the neighbourhood, no loud parties and music past 2AM. Such parties must end by 1:30."), (2, 4, "Included Cleanup", "Cleanup will be performed by Events-R-Us rather than left to the client."), (4, 1, "Free Setup and Takedown", "A special bundle package offer for event takedown and cleanup to be completed by Events-R-Us."), (5, 1, "No Children", "A childfree party option for those who don't want to care for someone's crying child while their parents dance their cares away."); CREATE TABLE eventServices( servicesID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, serviceName VARCHAR(15), servicePrice double, employeeID int, FOREIGN KEY eventServices_employee (employeeID) REFERENCES employeesclients.employees(employeeID) ); INSERT INTO eventServices(serviceName, servicePrice, employeeID) VALUES ("Cleaning", 50.00, 4), ("Party Planner", 200, 1), ("Cooking", 50, 2), ("Music", 100, 5), ("Security", 200, 3); CREATE TABLE eventData ( dataID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, eventName VARCHAR(60), clientID int, typeID int, locationID int, venueID int, policyID int, FOREIGN KEY eventData_clients(clientID) REFERENCES employeesClients.clients(clientID), FOREIGN KEY eventData_eventsTypes(typeID) REFERENCES eventTypes(typeID), FOREIGN KEY eventData_locations(locationID) REFERENCES eventLocations(locationID), FOREIGN KEY eventData_venues(venueID) REFERENCES venues(venueID), FOREIGN KEY eventData_policies(policyID) REFERENCES policies(policyID) ); INSERT INTO eventData(eventName, clientID, typeID, locationID, venueID, policyID) VALUES("Steven's Birthday", 2, 1, 3, 2, 5), ("Grandma's Anniversary", 3, 4, 1, 1, 4), ("Claire's Birthday", 1, 1, 1, 3, 3), ("Tom's Welcome Back Reception", 4, 2, 4, 5, 4), ("Precious Daughter's Wedding Reception", 2, 2, 3, 3, 2); /*----------------------------------------------------------------------*/ USE booked; CREATE TABLE eventsBooked( eventsBookedID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, dataID int, FOREIGN KEY eventsBooked_eventData(dataID) REFERENCES buildEvents.eventData(dataID) ); INSERT INTO eventsBooked (dataID) VALUES (1), (2), (3), (4), (5); CREATE TABLE servicesBooked( bookedServiceID int PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, servicesID int, eventsBookedID int, FOREIGN KEY servicesBooked_services(servicesID) REFERENCES buildEvents.eventServices(servicesID), FOREIGN KEY servicesBooked_eventsBooked(eventsBookedID) REFERENCES eventsBooked(eventsBookedID) ); INSERT INTO servicesBooked(servicesID, eventsBookedID) VALUES(2, 1), (3, 2), (4, 4), (5, 1), (4, 2);
-- Select "Creating database and Tables"; source schema.sql Select "Changing Engine to MyISAM"; Source change_to_myisam.sql Select "Inserting Base Data "; Source basedata.sql Select "Changing Engine to InnoDB"; Source change_to_innodb.sql Select "Adding Constraint"; Source constraint.sql
-- 130p CREATE TABLE USERS( ID VARCHAR2(8) PRIMARY KEY, PASSWORD VARCHAR2(8), NAME VARCHAR2(20), ROLE VARCHAR2(5) ); select * from users; truncate table users; insert into users values('test', 'test123', '관리자', 'Admin'); commit; select * from users; insert into users (id, password, name, role) values ('test','test123','관리자','Admin'); truncate table users; commit;
CREATE TABLE IF NOT EXISTS `ride` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `comment` text NOT NULL, `track` text CHARACTER SET latin1 NOT NULL, `length` double NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `user` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(25) CHARACTER SET latin1 NOT NULL, `email` varchar(25) CHARACTER SET latin1 NOT NULL, `password` varchar(50) CHARACTER SET latin1 NOT NULL, `ip` varchar(25) CHARACTER SET latin1 NOT NULL, `lastvisit` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `default_lat` float(10,6) NOT NULL, `default_lng` float(10,6) NOT NULL, `default_zoom` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`), UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
DELIMITER $$ USE ticketstore$$ /* *Author - Neloy Das *Created on 24/07/2016 */ DROP PROCEDURE IF EXISTS ticketstore.insertScreening$$ CREATE PROCEDURE ticketstore.insertScreening ( IN in_imdbid VARCHAR(50), IN in_title VARCHAR(500), IN in_moviedate VARCHAR(50), IN in_ticketprice DOUBLE, OUT POUT_Ret_Cd INT, OUT POUT_Err_Msg VARCHAR(500) ) BEGIN DECLARE _x INT; /* DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; DECLARE cur_seats CURSOR FOR SELECT imdbid, moviedate FROM seats WHERE imdbid = in_imdbid && moviedate = in_moviedate ORDER BY moviedate DESC, imdbid DESC; */ /* Start of input validation check. */ IF in_imdbid IS NULL OR LENGTH(in_imdbid) = 0 THEN SET POUT_Ret_Cd := 1; SET POUT_Err_Msg := 'ImdbID should not be null.'; ELSE IF in_moviedate IS NULL OR LENGTH(in_moviedate) = 0 THEN SET POUT_Ret_Cd := 1; SET POUT_Err_Msg := 'Movie date should not be null.'; END IF; END IF; /* End of input validation check. */ /* OPEN cur_seats; FETCH cur_seats INTO id, movie_date; */ SET _x = 1; IF (SELECT EXISTS(SELECT * FROM ticketstore.seats WHERE imdbid = in_imdbid AND moviedate = in_moviedate)) THEN SET POUT_Ret_Cd := 1; SET POUT_Err_Msg := 'Data already exists for this screening and time combination.'; ELSE INSERT INTO ticketstore.screening VALUES (in_imdbid, in_title, in_moviedate, in_ticketprice, 50); WHILE _x <= 50 DO INSERT INTO ticketstore.seats VALUES (in_imdbid, in_moviedate, _x, 'NA'); /*--CONCAT(in_imdbid, in_moviedate, '-', _x) */ SET _x = _x + 1; END WHILE; SET POUT_Ret_Cd := 0; SET POUT_Err_Msg := 'Data inserted in both screening and seats table.'; END IF; END $$ DELIMITER ;
create table session( key char(16) not null, data bytea, expiry integer not null, primary key(key) ); grant all privileges on table "session" to gha_admin;
SET DATABASE TO Goliath; ALTER TABLE IF EXISTS Feed ADD COLUMN link STRING; UPDATE Feed SET link = url;
CREATE procedure spr_list_PaymentDetail(@PaymentID integer) as select PaymentDetail.OriginalID, "Document ID" = PaymentDetail.OriginalID, "Date" = PaymentDetail.DocumentDate, "Type" = case DocumentType when 1 then 'Purchase Return' when 2 then 'Debit Note' when 3 then 'Payments' when 4 then 'Purchase' when 5 then 'Credit Note' When 6 then 'Claims Note' end, "Document Reference"=PaymentDetail.DocumentReference, "Document Value" = PaymentDetail.DocumentValue, "Adj Amount" = case DocumentType when 1 then '-' when 2 then '-' when 3 then '-' when 4 then '+' when 5 then '+' When 6 then '-' end + cast(PaymentDetail.AdjustedAmount as nvarchar) from PaymentDetail where PaymentID = @PaymentID
DELIMITER $$ drop function if exists calc_tweet_prio; create function calc_tweet_prio( p_favoriteCount int, p_retweetCount int, p_followerCount int ) returns float begin /* Errechnet die Priorität für einen Tweet anhand dessen Retweets, Likes und Anzahl Follower Implementiert die Formel zur Priorisieren von Tweets Rückgabe: Prio als float */ declare l_prio float default 0; if p_followerCount is not null then set l_prio = round((((ifnull(p_favoriteCount,0) / 2) + ifnull(p_retweetCount,0)) / (sqrt(ifnull(p_followerCount,1))+100)), 2); end if; return l_prio; end;$$ DELIMITER $$ drop function if exists get_general_prio; create function get_general_prio( p_tweetId bigint ) returns float begin /* Errechnet die Priorität für einen Tweet anhand dessen TweetId Rückgabe: Prio als float */ declare l_prio float default 0; select calc_tweet_prio(t.favoriteCount, t.retweetCount, a.followerCount) into l_prio from tweets t, tweetAuthors a where t.authorId = a.authorId and t.tweetId = p_tweetId; return l_prio; end;$$
# A table for mapping variations to variation_sets CREATE TABLE IF NOT EXISTS variation_set_variation ( variation_id int(10) unsigned NOT NULL, variation_set_id int(10) unsigned NOT NULL, PRIMARY KEY (variation_id,variation_set_id), KEY variation_set_idx (variation_set_id,variation_id) ); # A table containing variation_set information CREATE TABLE IF NOT EXISTS variation_set ( variation_set_id int(10) unsigned NOT NULL AUTO_INCREMENT, name VARCHAR(255), description TEXT, PRIMARY KEY (variation_set_id), KEY name_idx (name) ); # A table containing relashionship between variation sets CREATE TABLE IF NOT EXISTS variation_set_structure ( variation_set_super int(10) unsigned NOT NULL, variation_set_sub int(10) unsigned NOT NULL, PRIMARY KEY (variation_set_super,variation_set_sub), KEY sub_idx (variation_set_sub,variation_set_super) ); # patch identifier INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL,'patch', 'patch_56_57_e.sql|variation set tables');