text stringlengths 6 9.38M |
|---|
--测试用户
INSERT INTO t_ec_EcUser (id, name, companyName, companyAddress) VALUES ('100047', 'tom', '沪上纺织精品', '宛平南路600号');
INSERT INTO T_ec_EcUser (id, name) VALUES ('100048', 'mary');
INSERT INTO T_ec_EcUser (id, name) VALUES ('100049', 'sam');
--测试面料分类
INSERT INTO T_ec_fabricCategory (id, name, isValid) VALUES ('1a000727-880b-4504-b237-34d5ac11945a', '染色类', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('749206dc-a3a5-442f-8149-f35bc4f0f747', '蜡染', '1a000727-880b-4504-b237-34d5ac11945a', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('e6320adf-2516-4a77-a077-67339fb95cb9', '涂染', '1a000727-880b-4504-b237-34d5ac11945a', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('57cb6f6b-ed5e-408c-8263-470aaa4daff7', '刮染', '1a000727-880b-4504-b237-34d5ac11945a', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('156722f3-f625-467e-8f03-fdfeb426c42a', '染色+印花', '1a000727-880b-4504-b237-34d5ac11945a', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('210ab9aa-775c-4060-a385-4eafdad2d2c0', '常规染色', '1a000727-880b-4504-b237-34d5ac11945a', 0);
INSERT INTO T_ec_fabricCategory (id, name, isValid) VALUES ('697b90ec-578c-41f5-a9c9-547c1d7bfb40', '色织类', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('63806d98-82f9-48e8-8193-8a555faa41cb', '条纹', '697b90ec-578c-41f5-a9c9-547c1d7bfb40', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('c83c8893-0cbc-4d91-bd0e-3820427c029a', '格子', '697b90ec-578c-41f5-a9c9-547c1d7bfb40', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('6245914e-58b0-4f4d-999d-2aabbc42f313', '斜纹', '697b90ec-578c-41f5-a9c9-547c1d7bfb40', 0);
INSERT INTO T_ec_fabricCategory (id, name, parent_id, isValid) VALUES ('8694a785-b596-4d4b-853a-50fca6a5518a', '乱纹', '697b90ec-578c-41f5-a9c9-547c1d7bfb40', 0);
--辅料分类测试数据
INSERT INTO T_ec_MaterialCategory (id, name, isValid) VALUES ('c2da322a-cfc7-469f-bf82-8aa1653713dc', '衬料', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('d8190677-1e8a-4772-a623-b6036680979f', '棉衬', 'c2da322a-cfc7-469f-bf82-8aa1653713dc', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('3aec3ca2-fb2e-487d-b7ef-f08dcf5933a7', '麻衬', 'c2da322a-cfc7-469f-bf82-8aa1653713dc', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('51002fd0-2a5b-4f40-bc57-629a2ed41641', '马尾衬', 'c2da322a-cfc7-469f-bf82-8aa1653713dc', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('35c54c95-6e51-4dd0-ac75-d1c2f433a9c7', '树脂衬', 'c2da322a-cfc7-469f-bf82-8aa1653713dc', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('68c8f824-5a0c-4933-9866-0c3cfd460742', '涤纶衬', 'c2da322a-cfc7-469f-bf82-8aa1653713dc', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('039e4ed9-5ee5-4602-8183-02bbc82eb3b3', '粘合衬/热熔衬', 'c2da322a-cfc7-469f-bf82-8aa1653713dc', 0);
INSERT INTO T_ec_MaterialCategory (id, name, isValid) VALUES ('7e9ea339-cdbe-46bc-8c71-ad18154c140b', '里料', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('372ae361-9974-41b4-9880-fc39705196d8', '细布', '7e9ea339-cdbe-46bc-8c71-ad18154c140b', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('d0ed9985-8492-4511-89e7-0e43b8a4d5de', '市布', '7e9ea339-cdbe-46bc-8c71-ad18154c140b', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('091ad72b-55a7-4d51-be1d-c41de5668a80', '绒布', '7e9ea339-cdbe-46bc-8c71-ad18154c140b', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('c1fea49e-4072-47fe-a314-3ee6f1b6e01e', '小纺', '7e9ea339-cdbe-46bc-8c71-ad18154c140b', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('d02c08f8-8886-4843-a699-bad201c7354b', '软缎', '7e9ea339-cdbe-46bc-8c71-ad18154c140b', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('ebb0839b-69d7-430c-9d37-a6ccc9b6f52f', '羽纱', '7e9ea339-cdbe-46bc-8c71-ad18154c140b', 0);
INSERT INTO T_ec_MaterialCategory (id, name, parent_id, isValid) VALUES ('7020a1b2-06b8-4eb4-9a3d-fe73fffcc0f8', '锦纶', '7e9ea339-cdbe-46bc-8c71-ad18154c140b', 0);
--测试item
INSERT INTO T_ec_Item (id, customId, name, createdBy, createdTime, state)
VALUES ('1', '123', '极品面料', '100047', '2013-1-1 14:12:15', '出售中');
INSERT INTO T_ec_Item (id, customId, name, createdBy, createdTime, state)
VALUES ('2', '234', '测试辅料1', '100047', '2013-1-1 14:13:15', '出售中');
INSERT INTO T_ec_Item (id, customId, name, createdBy, createdTime, state)
VALUES ('3', '345', '测试辅料2', '100047', '2013-1-1 14:14:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('4', 'item4', '789', '100047', '2013-1-1 14:15:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('5', 'item5', '901', '100047', '2013-1-1 14:16:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('6', 'item6', '134', '100047', '2013-1-1 14:17:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('7', 'item7', '789', '100047', '2013-1-1 14:15:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('8', 'item8', '901', '100047', '2013-1-1 14:16:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('9', 'item9', '134', '100047', '2013-1-1 14:17:15', '出售中');
--测试用2号用户发布的商品
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('10', 'favourItem10', '134', '100048', '2013-1-1 14:17:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('11', 'favourItem11', '134', '100048', '2013-1-1 14:17:16', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('12', 'favourItem12', '134', '100048', '2013-1-1 14:17:17', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('13', 'favourItem13', '134', '100048', '2013-1-1 14:17:18', '出售中');
--测试用3号用户发布的商品
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('14', 'favourItem14', '134', '100049', '2013-1-1 14:17:15', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('15', 'favourItem15', '134', '100049', '2013-1-1 14:17:16', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('16', 'favourItem16', '134', '100049', '2013-1-1 14:17:17', '出售中');
INSERT INTO T_ec_item (id, name, customId, createdBy, createdTime, state)
VALUES ('17', 'favourItem17', '134', '100049', '2013-1-1 14:17:18', '出售中');
--测试面料成分
INSERT INTO T_ec_FabricSource (id, name) VALUES ('1', '天然纤维');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('2', '棉', '1');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('3', '木棉', '1');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('4', '羊毛', '1');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('5', '兔毛', '1');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('6', '真丝', '1');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('7', '绢丝', '1');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('8', '秘鲁棉', '1');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('9', '有机棉', '1');
INSERT INTO T_ec_FabricSource (id, name) VALUES ('10', '化学纤维');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('11', '涤纶', '10');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('12', '氨纶', '10');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('13', '腈纶', '10');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('14', '锦纶', '10');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('15', '丙纶', '10');
INSERT INTO T_ec_FabricSource (id, name, parent_id) VALUES ('16', '维纶', '10');
--测试面料
INSERT INTO T_ec_Fabric (id, category_id, source_id, detailSource_id, first_category_id) VALUES
('1', '749206dc-a3a5-442f-8149-f35bc4f0f747', '1', '3', '1a000727-880b-4504-b237-34d5ac11945a');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('2', '749206dc-a3a5-442f-8149-f35bc4f0f747');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('3', '749206dc-a3a5-442f-8149-f35bc4f0f747');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('4', 'e6320adf-2516-4a77-a077-67339fb95cb9');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('5', '57cb6f6b-ed5e-408c-8263-470aaa4daff7');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('10', '57cb6f6b-ed5e-408c-8263-470aaa4daff7');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('11', '57cb6f6b-ed5e-408c-8263-470aaa4daff7');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('12', '57cb6f6b-ed5e-408c-8263-470aaa4daff7');
INSERT INTO T_ec_Fabric (id, category_id) VALUES ('13', '57cb6f6b-ed5e-408c-8263-470aaa4daff7');
--测试辅料
INSERT INTO T_ec_Material (id, category_id, firstCategory_id, materialType, materialMeasureType)
VALUES ('6', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc', '现货', '米1');
INSERT INTO T_ec_Material (id, category_id, firstCategory_id) VALUES ('7', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc');
INSERT INTO T_ec_Material (id, category_id, firstCategory_id) VALUES ('8', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc');
INSERT INTO T_ec_Material (id, category_id, firstCategory_id) VALUES ('9', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc');
INSERT INTO T_ec_Material (id, category_id, firstCategory_id) VALUES ('14', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc');
INSERT INTO T_ec_Material (id, category_id, firstCategory_id) VALUES ('15', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc');
INSERT INTO T_ec_Material (id, category_id, firstCategory_id) VALUES ('16', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc');
INSERT INTO T_ec_Material (id, category_id, firstCategory_id) VALUES ('17', 'd8190677-1e8a-4772-a623-b6036680979f', 'c2da322a-cfc7-469f-bf82-8aa1653713dc');
--测试辅料供货方式
INSERT INTO t_ec_materialProvideType (material_id, id, name) VALUES ('6', '1', '现货');
--测试辅料适用范围
INSERT INTO t_ec_materialScope (material_id, id, name) VALUES ('6', '1', 'type1');
--测试面料主要使用方式
INSERT INTO t_ec_fabric_mainUse (fabric_id, id, name, orderNum) VALUES ('1', '1', '男装', 1);
INSERT INTO t_ec_fabric_mainUse (fabric_id, id, name, orderNum) VALUES ('1', '2', '女装', 1);
--
INSERT INTO T_ec_item_seasonType (fabric_id, id, type) VALUES ('1', '1', '春季');
INSERT INTO T_ec_item_seasonType (fabric_id, id, type) VALUES ('1', '2', '夏季');
--测试面料图片位置
INSERT INTO T_ec_CultureImage (item_id, location, orderNum)
VALUES ('1', '/resources/pic/logo.jpg', 1);
INSERT INTO T_ec_CultureImage (item_id, location, orderNum)
VALUES ('1', '/resources/pic/logo.jpg', 2);
INSERT INTO T_ec_CultureImage (item_id, location, orderNum)
VALUES ('1', '/resources/pic/logo.jpg', 3);
INSERT INTO T_ec_CultureImage (item_id, location, orderNum)
VALUES ('1', '/resources/pic/logo.jpg', 4);
--测试面料价格
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('1', 5, 20);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('1', 10, 15);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('1', 20, 10);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('2', 30, 40);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('2', 40, 35);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('3', 30, 40);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('3', 50, 70);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('4', 40, 35);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('5', 30, 40);
INSERT INTO T_ec_fabric_range (fabric_id, unit_from, price) VALUES ('5', 40, 35);
--测试辅料价格
INSERT INTO T_ec_material_range (material_id, unit_from, price) VALUES ('6', 5, 20);
INSERT INTO T_ec_material_range (material_id, unit_from, price) VALUES ('6', 10, 15);
INSERT INTO T_ec_material_range (material_id, unit_from, price) VALUES ('6', 20, 10);
--评价测试数据
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('1', '2', '100047', '2014-5-19 12:23:34', '好评', '11', 3, 4, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('2', '2', '100047', '2014-5-19 12:23:34', '中评', '22', 4, 5, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('3', '2', '100047', '2014-5-19 12:23:34', '差评', '33', 5, 5, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('4', '2', '100047', '2014-5-19 12:23:34', '好评', '44', 4, 3, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('5', '2', '100047', '2014-5-19 12:23:34', '中评', '55', 2, 2, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('6', '2', '100047', '2014-5-19 12:23:34', '差评', '66', 3, 5, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('7', '1', '100047', '2014-5-19 12:23:34', '好评', '11', 3, 4, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('8', '1', '100047', '2014-5-19 12:23:34', '中评', '22', 4, 5, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('9', '1', '100047', '2014-5-19 12:23:34', '差评', '33', 5, 5, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('10', '1', '100047', '2014-5-19 12:23:34', '好评', '44', 4, 3, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('11', '1', '100047', '2014-5-19 12:23:34', '中评', '55', 2, 2, 5);
INSERT INTO T_ec_Comment (id, item_id, user_id, createdTime, type, content, attitude, satisfied, deliverySpeed)
VALUES ('12', '1', '100047', '2014-5-19 12:23:34', '差评', '66', 3, 5, 5);
INSERT INTO T_ec_orderItem (id, orderNo, buyer_id, seller_id, createdTime, status, receiveTime)
VALUES ('o1', 'eeee1', '100047', '100048', '2014-5-22 12:23:33', 'FINISH', '2014-6-22 12:23:33');
INSERT INTO T_ec_orderItem (id, orderNo, buyer_id, seller_id, createdTime, status, receiveTime)
VALUES ('o2', 'eeee2', '100047', '100048', '2014-5-22 12:23:33', 'FINISH', '2014-6-22 12:23:33');
INSERT INTO T_ec_OrderLine (id, sum, quantity, orderItem_id, item_id, price)
VALUES ('011', '111', '1', 'o1', '2', 3.23);
INSERT INTO T_ec_OrderLine (id, sum, quantity, orderItem_id, item_id, price)
VALUES ('012', '112', '2', 'o1', '6', 232.23);
INSERT INTO T_ec_OrderLine (id, sum, quantity, orderItem_id, item_id, price)
VALUES ('022', '111', '1', 'o2', '4', 232.32);
--测试收货地址
INSERT INTO T_ec_address (id, user_id, state, city, zipCode, street, receiverName, mobile, zipPhone, phone, childPhone, createdTime, updatedTime)
VALUES ('1', '100047', '上海', '上海', '203323', '浦东新区浦电路370号', 'Charles', '1862229323', '021', '23839434', '2343', '2014-05-28',
'2014-05-28');
INSERT INTO T_ec_address (id, user_id, state, city, zipCode, street, receiverName, mobile, zipPhone, phone, childPhone, createdTime, updatedTime)
VALUES ('2', '100047', '上海', '上海', '203323', '浦东新区浦电路370号', 'Sam', '1862229342', '021', '23839434', '2222', '2014-04-28',
'2014-04-28');
UPDATE T_ec_EcUser
SET defaultAddress_id = '1'
WHERE id = '100047';
--求购单测试
INSERT INTO t_ec_demandorder (id, address_id, demandType, user_id, title, createdTime, validDateTo)
VALUES ('1', '1', '服务', '100047', 'demandOrder', '2014-6-12 12:00:12', '2014-6-30 12:00:12');
--测试调样单
--关注的商品
INSERT INTO t_ec_favouriteItems (user_id, item_id, createdTime) VALUES ('100047', '2', '2014-4-4 12:12:12');
INSERT INTO t_ec_favouriteItems (user_id, item_id, createdTime) VALUES ('100047', '3', '2014-4-5 12:12:12');
INSERT INTO t_ec_favouriteItems (user_id, item_id, createdTime) VALUES ('100047', '4', '2014-4-6 12:12:12');
--测试店铺
INSERT INTO t_ec_shop (id, user_id) VALUES ('1', '100048');
INSERT INTO t_ec_shop (id, user_id) VALUES ('2', '100049');
--测试收藏的店铺
INSERT INTO t_ec_favouriteShops (shop_id, user_id, createdTime) VALUES ('1', '1', '2014-4-6 12:12:12');
INSERT INTO t_ec_favouriteShops (shop_id, user_id, createdTime) VALUES ('2', '1', '2014-4-5 12:12:12');
--测试广告栏位
INSERT INTO T_ec_ad_position (id, positionNo, name, description, isValid)
VALUES ('wewew', 'ewewewewe', 'wewwewe', 'dsadasdsadsda', 0);
--测试广告栏位
INSERT INTO T_ec_ad (id, position_id, title, link, coverPath, isValid)
VALUES ('asdsadasd', 'wewew', 'fsdfsdfsdfsd', 'asdsadsadsadsa', 'xcvxcvxcvxvcxv', 0);
--卖家评价数据
INSERT INTO T_ec_sellerComment (id, item_id, user_id, type, content, createdTime, order_id)
VALUES ('1', '1', '100047', '好评', '11', '2014-6-4 12:23:00', 'o1');
INSERT INTO T_ec_sellerComment (id, item_id, user_id, type, content, createdTime, order_id)
VALUES ('2', '1', '100047', '好评', '22', '2014-6-4 12:24:00', 'o2');
INSERT INTO T_ec_sellerComment (id, item_id, user_id, type, content, createdTime)
VALUES ('7', '1', '100047', '中评', '77', '2014-6-4 12:29:00');
INSERT INTO T_ec_sellerComment (id, item_id, user_id, type, content, createdTime)
VALUES ('8', '1', '100047', '中评', '88', '2014-6-4 12:23:01');
INSERT INTO T_ec_sellerComment (id, item_id, user_id, type, content, createdTime)
VALUES ('9', '1', '100047', '中评', '99', '2014-6-4 12:23:02');
INSERT INTO T_ec_sellerComment (id, item_id, user_id, type, content, createdTime)
VALUES ('10', '1', '100047', '好评', '99', '2014-6-4 12:23:03');
INSERT INTO T_ec_sellerComment (id, item_id, user_id, type, content, createdTime)
VALUES ('11', '1', '100047', '好评', '99', '2014-6-4 12:23:04');
--用户常用辅料分类
INSERT INTO T_ec_user_PreferMaterialCategory (user_id, category_id) VALUES ('100047', 'd8190677-1e8a-4772-a623-b6036680979f');
INSERT INTO T_ec_user_PreferMaterialCategory (user_id, category_id) VALUES ('100047', '3aec3ca2-fb2e-487d-b7ef-f08dcf5933a7');
INSERT INTO T_ec_user_PreferMaterialCategory (user_id, category_id) VALUES ('100047', '51002fd0-2a5b-4f40-bc57-629a2ed41641');
INSERT INTO T_ec_user_PreferMaterialCategory (user_id, category_id) VALUES ('100047', '68c8f824-5a0c-4933-9866-0c3cfd460742');
--用户常用面料分类
INSERT INTO T_ec_user_PreferFabricCategory (user_id, category_id) VALUES ('100047', '63806d98-82f9-48e8-8193-8a555faa41cb');
INSERT INTO T_ec_user_PreferFabricCategory (user_id, category_id) VALUES ('100047', 'c83c8893-0cbc-4d91-bd0e-3820427c029a');
INSERT INTO T_ec_user_PreferFabricCategory (user_id, category_id) VALUES ('100047', '8694a785-b596-4d4b-853a-50fca6a5518a');
INSERT INTO T_ec_user_PreferFabricCategory (user_id, category_id) VALUES ('100047', '156722f3-f625-467e-8f03-fdfeb426c42a');
--店铺动态评分
INSERT INTO T_ec_dimension_rate (user_id, attitude, deliverySpeed, satisfied)
VALUES ('100048', 3, 4, 5);
--买家信用累计
INSERT INTO T_ec_sellerCredit (user_id, type, weekCount, oneMonthCount, sixMonthBeforeCount, sixMonthCount, total)
VALUES ('100047', '好评', 1, 3, 5, 7, 20);
INSERT INTO T_ec_sellerCredit (user_id, type, weekCount, oneMonthCount, sixMonthBeforeCount, sixMonthCount, total)
VALUES ('100047', '中评', 1, 3, 5, 7, 20);
INSERT INTO T_ec_sellerCredit (user_id, type, weekCount, oneMonthCount, sixMonthBeforeCount, sixMonthCount, total)
VALUES ('100047', '差评', 1, 3, 5, 7, 20);
--综合评分
INSERT INTO T_ec_Composite_Score (user_id, score)
VALUES ('100048', '5');
--站内信
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('1','aaaa1','aaaaaaaaaaaaaa1','100047','100048',0,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('2','aaaa1','aaaaaaaaaaaaaa2','100047','100048',0,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('3','aaaa1','aaaaaaaaaaaaaa3','100048','100047',0,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('4','aaaa1','aaaaaaaaaaaaaa4','100048','100047',2,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('5','aaaa5','aaaaaaaaaaaaaa5','100048','100049',2,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('6','aaaa6','aaaaaaaaaaaaaa6','100049','100048',2,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('7','aaaa7','aaaaaaaaaaaaaa7','100047','100049',2,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('8','aaaa8','aaaaaaaaaaaaaa8','100047','100049',2,1);
insert into T_ec_insideLetter(id,title,content,sender_id,receiver_id,letterStatus,letterType)
values ('9','aaaa9','aaaaaaaaaaaaaa9','100049','100047',2,1); |
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 04, 2020 at 03:48 AM
-- Server version: 10.1.38-MariaDB
-- PHP Version: 7.3.4
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: `lsapp`
--
-- --------------------------------------------------------
--
-- 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 `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(191) 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_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_resets_table', 1),
(3, '2019_08_19_000000_create_failed_jobs_table', 1),
(4, '2020_02_22_122314_create_posts_table', 1),
(5, '2020_02_24_050441_add_user_id_to_posts', 2),
(6, '2020_02_25_235940_add_cover_image_to_posts', 3);
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(191) 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 `posts`
--
CREATE TABLE `posts` (
`id` bigint(20) UNSIGNED NOT NULL,
`title` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`body` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`user_id` int(11) NOT NULL,
`cover_image` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `posts`
--
INSERT INTO `posts` (`id`, `title`, `body`, `created_at`, `updated_at`, `user_id`, `cover_image`) VALUES
(2, 'Post Two', '<p>This is my second post</p>', '2020-02-23 00:57:03', '2020-02-24 23:42:17', 1, ''),
(3, 'Post Three', '<p>This is actually my third post</p>', '2020-02-23 18:35:25', '2020-02-24 03:31:53', 1, ''),
(4, 'Post Four', '<p><strong>This is my fouth Post</strong></p>', '2020-02-24 06:07:58', '2020-02-24 06:07:58', 1, ''),
(5, 'Fifth Post', '<p>My Post no. 5</p>', '2020-02-24 23:18:12', '2020-02-24 23:18:12', 4, ''),
(8, 'Post Six', '<p>This is post 6</p>', '2020-02-26 00:20:36', '2020-02-26 22:35:59', 1, 'flash_1582756559.jpg'),
(9, 'Post Seven', '<p>fgsdghdxhdghdf</p>', '2020-02-26 22:42:02', '2020-02-26 22:42:02', 1, 'noimage.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(191) 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`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
(1, 'Arnold Anyor', 'anoldanyor@gmail.com', NULL, '$2y$10$mwS8D8naNx4F0zOYdrhQeODxn3kSWnJ29mw65bY7dB2Xk1wrrw1Oe', NULL, '2020-02-24 04:25:13', '2020-02-24 04:25:13'),
(2, 'john', 'anold@gmail.com', NULL, '$2y$10$/RlgLzRPDFOnRrf1aLg8OujafB8/fretIgv4D5lMQMPmRp6u02QnG', NULL, '2020-02-24 04:52:27', '2020-02-24 04:52:27'),
(3, 'john', 'anold@ymail.com', NULL, '$2y$10$YA9mL.820pLzOSJIa7PUeu.JMJsu3Y2CwUo8y7iredkpB5x10Xxdq', NULL, '2020-02-24 04:56:46', '2020-02-24 04:56:46'),
(4, 'john Doe', 'this@this.com', NULL, '$2y$10$Ucu4kelfftlaXDAQbaZKAuW5PfOAqomRPmRMTGUewmg6o11adcUBu', NULL, '2020-02-24 23:17:28', '2020-02-24 23:17:28');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
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 `posts`
--
ALTER TABLE `posts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `posts`
--
ALTER TABLE `posts`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
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 */;
|
ALTER TABLE orders
ADD printed NUMBER(1) DEFAULT 0;
ALTER TABLE orders
ADD CHECK (printed=0 OR printed=1);
|
CREATE TABLE aktivitetBilde
(
bildeId INT NOT NULL AUTO_INCREMENT,
bildeNavn varchar (50),
bilde blob NOT NULL,
PRIMARY KEY (bildeId)
)
ENGINE=InnoDB;
CREATE TABLE aktivitetFarge
(
fargeId INT NOT NULL AUTO_INCREMENT,
fargeNavn varchar (20),
PRIMARY KEY (fargeId)
)
ENGINE=InnoDB;
CREATE TABLE aktivitet
(
id INT NOT NULL AUTO_INCREMENT,
bildeId INT NOT NULL,
fargeId INT NOT NULL,
aktivitetNavn varchar(50),
beskrivelse text,
dato date,
tid time,
alarm time,
PRIMARY KEY (id),
FOREIGN KEY (bildeId) REFERENCES aktivitetBilde(bildeId),
FOREIGN KEY (fargeId) REFERENCES aktivitetFarge(fargeId)
)
ENGINE=InnoDB; |
USE bottega-university;
INSERT INTO
students(first_name, last_name, email)
VALUES
('Gerhard', 'Kuhn', 'g.kuhn@mailgen.biz'),
('Vivien', 'Watsica', 'vivienwatsica@mailgen.pro'),
('Florida', 'Bode', 'fb@mailgen.pro'),
('April', 'Collins', 'a.c1007@mailgen.club'),
('Eugenia', 'Nader', 'eugenia.n20@mailgen.pw'); |
/*
** Question: https://leetcode.com/problems/market-analysis-ii/
*/
-- method 1, MS SQL (doesn't work for Oracle), Postgres
SELECT
u.user_id AS seller_id,
CASE WHEN u.favorite_brand = t1.item_brand THEN 'yes' ELSE 'no' END AS '2nd_item_fav_brand'
FROM
Users u
LEFT OUTER JOIN
(
SELECT o.seller_id, i.item_brand,
RANK() OVER (PARTITION BY o.seller_id ORDER BY o.order_date) AS pos
FROM Orders o
INNER JOIN Items i
ON o.item_id = i.item_id
) t1 -- Orders with ordering of each sale per seller
ON u.user_id = t1.seller_id AND t1.pos = 2
|
drop table items;
create table items (
i_id int,
i_name varchar2(40),
i_level varchar2(40),
i_price int,
primary key(i_id)
);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(1, '잉걸불 칼', '시작', 350);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(2, '핏빌칼날', '시작', 350);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(3, '암흑의인장', '시작', 350);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(4, '도란의반지', '시작', 400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(5, '여신의 눈물', '시작', 400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(6, '영혼의 낫', '시작', 400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(7, '주문도둑의 검', '시작', 400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(8, '강철 어깨 보호대', '시작', 400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(9, '고대유물 방패', '시작', 400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(10, '도란의 방패', '시작', 450);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(11, '도란의 검', '시작', 450);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(12, '수확의 낫', '시작', 450);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(13, '원기 회복의 구슬', '기본', 150);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(14, '요정의 부적', '기본', 125);
INSERT INTO items(i_id, i_name, i_level, i_price) VALUES
(15, '천 갑옷', '기본', 300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(16, '단검', '기본', 300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(17, '사파이어 수정', '기본', 350);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(18, '롱소드', '기본', 350);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(19, '루비 수정', '기본', 400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(20, '증폭의 고서', '기본', 435);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(21, '마법무효화의 망토', '기본', 450);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(22, '민첩성의 망토', '기본', 600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(23, '초시계', '기본', 650);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(24, '방출의 마법봉', '기본', 850);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(25, '곡괭이', '기본', 875);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(26, '쓸데없이 큰 지팡이', '기본', 1250);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(27, 'B.F. 대검', '기본', 1300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(28, '바미의 불씨', '서사', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(29, '사라진 양피지', '서사', 1300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(30, '흡수의 시선', '서사', 1300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(31, '절정의 화살', '서사', 1300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(32, '강철가시 채찍', '서사', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(33, '수정 팔 보호구', '서사', 650);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(34, '광휘의 검', '서사', 700);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(35, '키리히아이스의 파편', '서사', 700);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(36, '쇠사슬 조끼', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(37, '비상의 월갑', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(38, '점화석', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(39, '덤불조끼', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(40, '금지된 우상', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(41, '처형인의 대검', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(42, '망각의 구', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(43, '분노의 칼', '서사', 800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(44, '에테르 환영', '서사', 850);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(45, '거인의 허리띠', '서사', 900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(46, '흡혈의 낫', '서사', 900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(47, '음전자 망토', '서사', 900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(48, '얼음 방패', '서사', 900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(49, '악마의 마법서', '서사', 900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(50, '추적자의 팔목 보호대', '서사', 1000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(51, '밴들유리 거울', '서사', 950);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(52, '곡궁', '서사', 1000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(53, '파수꾼의 갑옷', '서사', 1000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(54, '열정의 검', '서사', 1050);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(55, '마법공학 교류 발전기', '서사', 1050);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(56, '탐식의 망치', '서사', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(57, '온기가 필요한 자의 도끼', '서사', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(58, '콜필드의 전투 망치', '서사', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(59, '톱날 단검', '서사', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(60, '감시하는 와드석', '서사', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(61, '티아맷', '서사', 1200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(62, '신록의 장벽', '서사', 1000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(63, '망령의 두건', '서사', 1250);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(64, '역병의 보석', '서사', 1250);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(65, '수은 장식띠', '서사', 1300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(66, '주문 포식자', '서사', 1300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(67, '최후의 속삭임', '서사', 1450);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(68, '군단의 방패', '서사', 1500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(69, '그림자 검', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(70, '독사의 송곳니', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(71, '밤의 끝자락', '전설', 2900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(72, '요우무의 유령검', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(73, '핏빛 칼날', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(74, '세릴다의 원한', '전설', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(75, '화공 펑크 사슬검', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(76, '수호 천사', '전설', 2800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(77, '맬모셔스의 아귀', '전설', 2800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(78, '선체분쇄기', '전설', 2800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(79, '마나무네', '전설', 2900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(80, '은빛 여명', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(81, '스테락의 도전', '전설', 3100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(82, '마법사의 최후', '전설', 3100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(83, '죽음의 무도', '전설', 3100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(84, '칠흑의 양날 도끼', '전설', 3100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(85, '몰락한 왕의 검', '전설', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(86, '굶주린 히드라', '전설', 3300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(87, '거대한 히드라', '전설', 3300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(88, '메자이의 영혼약탈자', '전설', 1600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(89, '모렐로노미콘', '전설', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(90, '밴시의 장막', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(91, '존야의 모래시계', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(92, '공허의 지팡이', '전설', 2700);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(93, '대천사의 지팡이', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(94, '리치베인', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(95, '내셔의 이빨', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(96, '라일라이의 수정홀', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(97, '지평선의 초점', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(98, '우주의 추진력', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(99, '악마의 포옹', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(100, '라바돈의 죽음모자', '전설', 3600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(101, '필멸자의 운명', '전설', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(102, '고속 연사포', '전설', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(103, '유령 무희', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(104, '루난의 허리케인', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(105, '폭풍갈퀴', '전설', 2700);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(106, '구인수의 격노검', '전설', 2600);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(107, '정수 약탈자', '전설', 2800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(108, '도미닉 경의 인사', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(109, '헤르메스의 시미터', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(110, '징수의 총', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(111, '무한의 대검', '전설', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(112, '피바라기', '전설', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(113, '나보리 신속검', '전설', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(114, '구원', '전설', 2300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(115, '기사의 맹세', '전설', 2300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(116, '미카엘의 축복', '전설', 2300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(117, '불타는 향로', '전설', 2300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(118, '경계의 와드석', '전설', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(119, '흐르는 물의 지팡이', '전설', 2300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(120, '화학공학 부패기', '전설', 2300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(121, '지크의 융합', '전설', 2400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(122, '얼어붙은 심장', '전설', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(123, '심연의 가면', '전설', 2700);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(124, '가시 갑옷', '전설', 2700);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(125, '란두인의 예언', '전설', 2700);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(126, '정령의 형상', '전설', 2900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(127, '망자의 갑옷', '전설', 2900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(128, '대자연의 힘', '전설', 2900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(129, '워모그의 갑옷', '전설', 3000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(130, '가고일의 돌갑옷', '전설', 3300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(131, '돌풍', '신화', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(132, '크라켄 학살자', '신화', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(133, '불멸의 철갑궁', '신화', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(134, '서리불꽃 건틀릿', '신화', 2800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(135, '터보 화공 탱크', '신화', 2800);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(136, '태양불꽃 방패', '신화', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(137, '드락사르의 황혼검', '신화', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(138, '월식', '신화', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(139, '자객의 발톱', '신화', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(140, '리안드리의 고뇌', '신화', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(141, '루덴의 폭풍', '신화', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(142, '만년서리', '신화', 3400);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(143, '마법공학 로켓 벨트', '신화', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(144, '균열 생성기', '신화', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(145, '밤의 수확자', '신화', 3200);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(146, '선혈 포식자', '신화', 3300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(147, '발걸음 분쇄기', '신화', 3300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(148, '신성한 파괴자', '신화', 3300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(149, '삼위일체', '신화', 3333);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(150, '슈렐리아의 군가', '신화', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(151, '강철의 솔라리 펜던트', '신화', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(152, '제국의 명령', '신화', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(153, '월석 재생기', '신화', 2500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(154, '체력 물약', '소모품', 50);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(155, '충전형 물약', '소모품', 150);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(156, '부패 물약', '소모품', 500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(157, '와드 토템', '소모품', 0);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(158, '예언자의 렌즈', '소모품', 0);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(159, '망원형 개조', '소모품', 0);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(160, '마법의 영약', '소모품', 500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(161, '분노의 영약', '소모품', 500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(162, '강철의 영약', '소모품', 500);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(163, '제어와드', '소모품', 75);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(164, '장화', '장화', 300);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(165, '신속의 장화', '장화', 900);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(166, '명석함의 아이오니아 장화', '장화', 950);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(167, '기동력의 장화', '장화', 1000);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(168, '광전사의 군화', '장화', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(169, '마법사의 신발', '장화', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(170, '판금 장화', '장화', 1100);
INSERT INTO items (i_id, i_name, i_level, i_price) VALUES
(171, '헤르메스의 발걸음', '장화', 1100);
commit;
|
Create Procedure mERP_SP_rsisfirstofmonth (@DateFrom datetime,@DateTo datetime)
AS
BEGIN
Set dateformat dmy
Create Table #tmpDates(AllDate Datetime);
WITH T(date)
AS
(
SELECT @DateFrom
UNION ALL
SELECT DateAdd(day,1,T.date) FROM T WHERE T.date < @DateTo
)
insert into #tmpDates(AllDate)
SELECT date FROM T OPTION (MAXRECURSION 32767);
if exists(select'x' from #tmpDates where Alldate = dbo.stripdatefromtime((DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,Alldate)+1,0)))))
Select 1
else
Select 0
Drop Table #tmpDates
END
|
alter table BlogsEntry add urlTitle varchar(150) null;
create table BlogsStatsUser (
statsUserId bigint not null primary key,
groupId bigint,
companyId bigint,
userId bigint,
entryCount integer,
lastPostDate datetime null,
ratingsTotalEntries integer,
ratingsTotalScore double,
ratingsAverageScore double
);
alter table BlogsStatsUser add ratingsTotalEntries integer;
alter table BlogsStatsUser add ratingsTotalScore double;
alter table BlogsStatsUser add ratingsAverageScore double;
delete from MBStatsUser where groupId = 0;
|
-- LABORATORY WORK 3
-- BY Kharytonchyk_Oleksandr
/*1. Написати PL/SQL код, що додає замовників, щоб сумарна кількість усіх замовників була 10. Ключі замовників test1….testn.
Решта значень обов’язкових полів відповідає полям замовника з ключем 1000000001.
10 балів*/
SET SERVEROUTPUT ON;
SET AUTOPRINT ON;
DECLARE
v_VEND_ID Vendors.VEND_ID%TYPE;
v_vend_countaty NUMBER := 10;
BEGIN
DBMS_OUTPUT.ENABLE;
FOR i IN 1..v_vend_countaty LOOP
DMBS_OUT.PUT_LINE();
END LOOP;
END;
/*2. Написати PL/SQL код, що по вказаному ключу замовника виводить у консоль його ім'я та визначає його статус.
Якщо він має більше 3 замовлень - статус = "yes"
Якщо він має не менше 3 замовлень - статус = "no"
Якщо він немає замовлення - статус = "unknown*/
DECLARE
v_cust_status = '';
BEGIN
DBMS_OUTPUT.ENABLE;
v_customer_id := '1000000003';
IF (ORDERITEMS.ORDER_ITEM <= 3) THEN
v_cust_status := 'yes';
ELSIF (ORDERITEMS.ORDER_ITEM > 3) THEN
v_cust_status := 'no';
ELSE
v_cust_status := 'unknown';
END IF;
DMBS_OUT.PUT_LINE( TRIM(CUSTOMERS.CUST_NAME) || v_cust_status);
END;
/*3. Створити представлення та використати його у двох запитах:
3.1. Скільки замовлень має кожен з покупців, що проживає в Австрії.
3.2. Як звуть постачальника з Германії, що продає свої товари більше ніж у 3 різних замовленнях.
6 балів.*/
CREATE VIEW CUSTOMERS_VENDORS AS
SELECT *
FROM CUSTOMERS JOIN ORDERS
ON CUSTOMERS.CUST_ID = ORDERS.CUST_ID
JOIN ORDERITEMS
ON ORDERS.ORDER_NUM = ORDERITEMS.ORDER_NUM
JOIN PRODUCTS
ON PRODUCTS.PROD_ID = ORDERITEMS.PROD_ID
JOIN VENDORS
ON VENDORS.VEND_ID = PRODUCTS.VEND_ID;
SELECT CUST_ID,
COUNT(ORDER_ITEM)
FROM CUSTOMERS_VENDORS
WHERE CUST_COUNTRY = 'Austria'
GROUP BY CUST_ID;
SELECT VEND_NAME
FROM CUSTOMERS_VENDORS
WHERE (CUST_COUNTRY = 'Germany');
|
CREATE Procedure sp_acc_get_CurrentARVID (@Position Int,@CurARVID int = 0)
As
If @Position = 1 /* Last ARV ID */
Begin
Select Top 1 DocumentID From ARVAbstract
Order By DocumentID Desc
End
Else if @Position = 2 /* Previous ARV ID */
Begin
Select Top 1 DocumentID From ARVAbstract Where DocumentID < @CurARVID
Order By DocumentID Desc
End
Else if @Position = 3 /* Next ARV ID */
Begin
Select Top 1 DocumentID From ARVAbstract Where DocumentID > @CurARVID
Order By DocumentID
End
|
/* Создание таблицы отчетов доступных действиям */
CREATE TABLE /*PREFIX*/ACTION_REPORTS
(
ACTION_ID VARCHAR(32) NOT NULL,
REPORT_ID VARCHAR(32) NOT NULL,
PRIORITY INTEGER NOT NULL,
PRIMARY KEY (ACTION_ID,REPORT_ID),
FOREIGN KEY (ACTION_ID) REFERENCES /*PREFIX*/ACTIONS (ACTION_ID),
FOREIGN KEY (REPORT_ID) REFERENCES /*PREFIX*/REPORTS (REPORT_ID)
)
--
/* Создание просмотра таблицы отчетов доступных действиям */
CREATE VIEW /*PREFIX*/S_ACTION_REPORTS
AS
SELECT AR.*,
A.NAME AS ACTION_NAME,
I.NAME AS REPORT_NAME,
R.REPORT_TYPE
FROM /*PREFIX*/ACTION_REPORTS AR
JOIN /*PREFIX*/ACTIONS A ON A.ACTION_ID=AR.ACTION_ID
JOIN /*PREFIX*/REPORTS R ON R.REPORT_ID=AR.REPORT_ID
JOIN /*PREFIX*/INTERFACES I ON I.INTERFACE_ID=R.REPORT_ID
--
/* Создание процедуры добавления отчета действию */
CREATE PROCEDURE /*PREFIX*/I_ACTION_REPORT
@ACTION_ID VARCHAR(32),
@REPORT_ID VARCHAR(32),
@PRIORITY INTEGER
AS
BEGIN
INSERT INTO /*PREFIX*/ACTION_REPORTS (ACTION_ID,REPORT_ID,PRIORITY)
VALUES (@ACTION_ID,@REPORT_ID,@PRIORITY);
END;
--
/* Создание процедуры изменения отчета у действия */
CREATE PROCEDURE /*PREFIX*/U_ACTION_REPORT
@ACTION_ID VARCHAR(32),
@REPORT_ID VARCHAR(32),
@PRIORITY INTEGER,
@OLD_ACTION_ID VARCHAR(32),
@OLD_REPORT_ID VARCHAR(32)
AS
BEGIN
UPDATE /*PREFIX*/ACTION_REPORTS
SET ACTION_ID=@ACTION_ID,
REPORT_ID=@REPORT_ID,
PRIORITY=@PRIORITY
WHERE ACTION_ID=@OLD_ACTION_ID
AND REPORT_ID=@OLD_REPORT_ID;
END;
--
/* Создание процедуры удаления отчета у действия */
CREATE PROCEDURE /*PREFIX*/D_ACTION_REPORT
@OLD_ACTION_ID VARCHAR(32),
@OLD_REPORT_ID VARCHAR(32)
AS
BEGIN
DELETE FROM /*PREFIX*/ACTION_REPORTS
WHERE ACTION_ID=@OLD_ACTION_ID
AND REPORT_ID=@OLD_REPORT_ID;
END;
-- |
select * from route_trip |
Create Procedure mERP_sp_Delete_UploadRptXMLTrackerData
As
Begin
Delete from tbl_merp_UploadReportXMLTracker Where ReportDocId in (
Select ReportDocID from tbl_merp_UploadReportTracker Where IsNull(AckStatus,0) & 132 = 132 And IsNull(Status,0) & 128 = 128)
End
|
create or replace type table_varchar2_col as table of
type_varchar2_col
/
|
DROP TABLE IF EXISTS `api`;
|
/*
Select for retriving flexfield information for specific modules or tables
Credit to:
******* http://sanjaimisra.blogspot.com/2010/04/flexfield-list.html ******
*/
SELECT
fa.application_short_name "Application"
, fdft.title "Flex Field Title"
, fdf.descriptive_flexfield_name "Flex Field Name"
, fdf.application_table_name "Table"
, fdf.freeze_flex_definition_flag "Freeze"
, fdf.protected_flag "Protected"
, fdf.context_column_name "Context Column"
, fdft.form_context_prompt "Form Context Prompt"
, fdf.default_context_field_name "Default Context Field"
, fdf.context_required_flag "Required"
, fdf.context_user_override_flag "Display Flag"
, ffvs.flex_value_set_name "Conext Value Set"
FROM applsys.fnd_descriptive_flexs fdf
, applsys.fnd_descriptive_flexs_tl fdft
, applsys.fnd_application fa
, applsys.fnd_flex_value_sets ffvs
WHERE fdf.application_id = fdft.application_id
AND fdf.descriptive_flexfield_name = fdft.descriptive_flexfield_name
AND fa.application_id = fdf.application_id
AND fdf.context_override_value_set_id = ffvs.flex_value_set_id (+)
AND fdft.title not like '$SRS$%'
AND fdft.language = 'US' -- remove if another language is being used
/* Use if to get information about specific module Flexfields */
--AND fa.application_short_name in ('AR', 'SQLAP', 'PO', 'SQLGL', 'PA')
/* Use if need to find lookup values for a specific table */
--AND fdf.application_table_name = 'FND_LOOKUP_VALUES'
ORDER BY 1,2
|
select extract(year from tijdstip) as found
from dagdeel
group by found |
/* Esta es la base de datos definitiva,
pero en el futuro pueden haber cambios en la base de datos*/
/* comandos para la creacion del usuario de la base de datos del proyecto*/
/* Nota: si en la API, en el application.properties esta el
spring.jpa.hibernate.ddl-auto=update , si es igual a update, nos generara
de manera automatica las tablas de la base de datos */
/* base de datos utilizada en el proyecto Angular-Java redsocial-angular-app*/
CREATE SCHEMA `bd_red_social_3` ; /*Crear base de datos del proyecto de la red social*/
create table usuario(
id_usu int auto_increment,
nombre_usu varchar(60) not null unique key,
fecha_alta datetime not null,
pais varchar(100),
ciudad varchar(100),
region varchar(100),
email varchar(100),
nombre varchar(100),
apellidos varchar(200),
fecha_nacimiento date not null,
telefono varchar(20),
email_entrada varchar(100) not null unique key,
contrasenya varchar(100) not null,
perfil_privado bool default false,
aceptada_pol_priva bool default false,
es_administrador bool default false,
usuario_activo bool default true,
usuario_baneado bool default false,
fecha_fin_baneo datetime,
estado varchar(200),
num_visitas bigint default 0,
fecha_ultimo_login datetime,
foto_perfil varchar(100),
foto_portada varchar(100),
primary key(id_usu)
);
/*Tabla amigos usuarios*/
create table amigos_usu(
id_solicitante int,
id_receptor int,
fecha_enviada datetime not null,
solicitud_aceptada bool default null,
primary key(id_solicitante, id_receptor),
foreign key(id_solicitante) references usuario(id_usu),
foreign key(id_receptor) references usuario(id_usu)
);
/*Tabla fotos*/
create table fotos(
id_foto int auto_increment,
id_usu int not null,
foto_string varchar(100) not null,
fecha_subida_fot datetime not null,
primary key (id_foto),
foreign key(id_usu) references usuario(id_usu)
);
/*Tabla videos*/
create table videos(
id_video int auto_increment,
id_usu int,
video_string varchar(100) not null,
fecha_subida_vid datetime not null,
primary key (id_video),
foreign key(id_usu) references usuario(id_usu)
);
/*Tabla entradas*/
create table entradas(
id_entrada int auto_increment,
id_usu int,
titulo_entrada varchar(200) not null,
texto_entrada varchar(500),
fecha_creacion_ent datetime not null,
primary key(id_entrada),
foreign key(id_usu) references usuario(id_usu)
);
/*Tabla publicaciones*/
create table publicacion(
id_publicacion int auto_increment,
id_usu int,
titulo_publicacion varchar(200) not null,
texto_publicacion varchar(500),
fecha_creacion_pub datetime not null,
pub_es_privada bool default false,
primary key(id_publicacion),
foreign key(id_usu) references usuario(id_usu)
);
/*Tabla comentarios*/
create table comentario(
id_comentario int auto_increment,
id_usuario int not null,
id_publicacion int not null,
texto_comentario varchar(500) not null,
fecha_creacion_com datetime not null,
primary key(id_comentario),
foreign key(id_usuario) references usuario(id_usu),
foreign key(id_publicacion) references publicacion(id_publicacion)
);
/* modificacion de blob para las tablas fotos y videos*/
/*tablas fotos y videos*/
alter table fotos add column foto_blob blob;
alter table videos add column video_blob blob;
/* Inserts de prueba ----------------------------------------------------- */
/* usuario admin de prueba*/
INSERT INTO `bd_red_social_3`.`usuario` (`id_usu`, `nombre_usu`, `fecha_alta`, `email`, `fecha_nacimiento`, `email_entrada`, `contrasenya`, `es_administrador`) VALUES ('1', 'admin', '2020-04-30 17:26:00', 'soporteADM@gmail.com', '1994-04-30', 'soporteADM@gmail.com', '123456789', '0');
UPDATE `bd_red_social_3`.`usuario` SET `es_administrador`='1' WHERE `id_usu`='1';
INSERT INTO `bd_red_social_3`.`entradas` (`id_entrada`, `id_usu`, `titulo_entrada`, `texto_entrada`, `fecha_creacion_ent`) VALUES ('1', '1', 'Entrada de prueba 1', 'Entrada 1', '2020-04-30 17:26:00');
INSERT INTO `bd_red_social_3`.`publicacion` (`id_publicacion`, `id_usu`, `titulo_publicacion`, `texto_publicacion`, `fecha_creacion_pub`, `pub_es_privada`) VALUES ('1', '1', 'Publicacion 1', 'Publicacion de prueba', '2020-04-30 17:26:00', '0');
INSERT INTO `bd_red_social_3`.`comentario` (`id_comentario`, `id_usuario`, `id_publicacion`, `texto_comentario`, `fecha_creacion_com`) VALUES ('1', '1', '1', 'Esto es un comentario', '2020-04-30 17:26:00');
/*Ampliacion usuario admin de prueba*/
UPDATE `bd_red_social_3`.`usuario` SET `pais`='España', `ciudad`='Valencia', `region`='CValenciana', `nombre`='adm', `apellidos`='admin', `telefono`='9663015', `estado`='estadoAdmin' WHERE `id_usu`='1';
Update `usuario` SET `fecha_ultimo_login`='2020-04-30 17:26:00' WHERE `id_usu`='1';
/* usuarios de prueba para las selects*/
INSERT INTO `bd_red_social_3`.`usuario` (`id_usu`, `nombre_usu`, `fecha_alta`, `email`, `fecha_nacimiento`, `email_entrada`, `contrasenya`, `es_administrador`) VALUES ('2', 'admin', '2020-04-30 17:26:00', 'soporteADM@gmail.com', '1994-04-30', 'soporteADM@gmail.com', '123456789', '0');
INSERT INTO `bd_red_social_3`.`usuario` (`id_usu`, `nombre_usu`, `fecha_alta`, `email`, `fecha_nacimiento`, `email_entrada`, `contrasenya`, `es_administrador`) VALUES ('3', 'admin', '2020-04-30 17:26:00', 'soporteADM@gmail.com', '1994-04-30', 'soporteADM@gmail.com', '123456789', '0');
/* Datos para crear varios usuarios */
INSERT INTO `usuario` (`id_usu`, `nombre_usu`, `fecha_alta`, `email`, `fecha_nacimiento`, `email_entrada`, `contrasenya`, `es_administrador`) VALUES ('1', 'admin', '2020-04-30 17:26:00', 'soporteADM@gmail.com', '1994-04-30', 'soporteADM@gmail.com', '123456789', '0');
UPDATE `usuario` SET `es_administrador`='1' WHERE `id_usu`='1';
INSERT INTO `entradas` (`id_entrada`, `id_usu`, `titulo_entrada`, `texto_entrada`, `fecha_creacion_ent`) VALUES ('1', '1', 'Entrada de prueba 1', 'Entrada 1', '2020-04-30 17:26:00');
INSERT INTO `publicacion` (`id_publicacion`, `id_usu`, `titulo_publicacion`, `texto_publicacion`, `fecha_creacion_pub`, `pub_es_privada`) VALUES ('1', '1', 'Publicacion 1', 'Publicacion de prueba', '2020-04-30 17:26:00', '0');
INSERT INTO `comentario` (`id_comentario`, `id_usuario`, `id_publicacion`, `texto_comentario`, `fecha_creacion_com`) VALUES ('1', '1', '1', 'Esto es un comentario', '2020-04-30 17:26:00');
INSERT INTO `usuario` (`id_usu`, `nombre_usu`, `fecha_alta`, `email`, `fecha_nacimiento`, `email_entrada`, `contrasenya`, `es_administrador`) VALUES ('2', 'admin2', '2020-04-30 17:26:00', 'soporteADM2@gmail.com', '1994-04-30', 'soporteADM2@gmail.com', '123456789', '0');
INSERT INTO `usuario` (`id_usu`, `nombre_usu`, `fecha_alta`, `email`, `fecha_nacimiento`, `email_entrada`, `contrasenya`, `es_administrador`) VALUES ('3', 'admin3', '2020-04-30 17:26:00', 'soporteADM3@gmail.com', '1994-04-30', 'soporteADM3@gmail.com', '123456789', '0');
UPDATE `usuario` SET `pais`='España', `ciudad`='Valencia', `region`='CValenciana', `nombre`='adm', `apellidos`='admin', `telefono`='9663015', `estado`='estadoAdmin' WHERE `id_usu`='1';
Update `usuario` SET `fecha_ultimo_login`='2020-04-30 17:26:00' WHERE `id_usu`='1';
/*Actualizacion usuario 1*/
UPDATE `bd_red_social_3`.`usuario` SET `pais`='España', `ciudad`='Valencia', `region`='CValenciana', `nombre`='adm', `apellidos`='admin', `telefono`='9663015', `estado`='estadoAdmin' WHERE `id_usu`='1';
Update `usuario` SET `fecha_ultimo_login`='2020-04-30 17:26:00' WHERE `id_usu`='1';
/* datos de prueba para comprobar (Nota: crear mas usuarios antes)*/
/* amigos usu (amistades entre usuarios)*/
INSERT INTO `bd_red_social_3`.`amigos_usu` (`id_solicitante`, `id_receptor`, `fecha_enviada`) VALUES ('1', '5', '2020-04-30 17:26:00');
INSERT INTO `bd_red_social_3`.`amigos_usu` (`id_solicitante`, `id_receptor`, `fecha_enviada`, `solicitud_aceptada`) VALUES ('1', '4', '2020-04-30 17:26:00', '1');
INSERT INTO `bd_red_social_3`.`amigos_usu` (`id_solicitante`, `id_receptor`, `fecha_enviada`, `solicitud_aceptada`) VALUES ('2', '4', '2020-04-30 17:26:00', '1');
INSERT INTO `bd_red_social_3`.`amigos_usu` (`id_solicitante`, `id_receptor`, `fecha_enviada`) VALUES ('2', '5', '2020-04-30 17:26:00');
INSERT INTO `bd_red_social_3`.`amigos_usu` (`id_solicitante`, `id_receptor`, `fecha_enviada`, `solicitud_aceptada`) VALUES ('6', '1', '2020-04-30 17:26:00', '1');
INSERT INTO `bd_red_social_3`.`amigos_usu` (`id_solicitante`, `id_receptor`, `fecha_enviada`, `solicitud_aceptada`) VALUES ('4', '1', '2020-04-30 17:26:00', '0');
UPDATE `bd_red_social_3`.`amigos_usu` SET `solicitud_aceptada`='0' WHERE `id_solicitante`='1' and`id_receptor`='5';
UPDATE `bd_red_social_3`.`amigos_usu` SET `solicitud_aceptada`='0' WHERE `id_solicitante`='2' and`id_receptor`='5';
/*entradas*/
INSERT INTO `bd_red_social_3`.`entradas` (`id_entrada`, `id_usu`, `titulo_entrada`, `texto_entrada`, `fecha_creacion_ent`) VALUES ('2', '4', 'Entrada usu 4', 'entrada 4', '2020-04-30 17:26:00');
INSERT INTO `bd_red_social_3`.`entradas` (`id_entrada`, `id_usu`, `titulo_entrada`, `texto_entrada`, `fecha_creacion_ent`) VALUES ('3', '1', 'Entrada de prueba 2', 'entr 2', '2020-04-30 17:26:00');
/*publicaciones*/
INSERT INTO `bd_red_social_3`.`publicacion` (`id_publicacion`, `id_usu`, `titulo_publicacion`, `texto_publicacion`, `fecha_creacion_pub`, `pub_es_privada`) VALUES ('2', '4', 'Publicacion del 4 priv', 'Publicacion del 4 priv', '2020-04-30 17:26:00', '1');
INSERT INTO `bd_red_social_3`.`publicacion` (`id_publicacion`, `id_usu`, `titulo_publicacion`, `texto_publicacion`, `fecha_creacion_pub`, `pub_es_privada`) VALUES ('3', '4', 'Publicacion del 4 pub', 'Publicacion del 4 pub', '2020-04-30 17:26:00', '0');
INSERT INTO `bd_red_social_3`.`publicacion` (`id_publicacion`, `id_usu`, `titulo_publicacion`, `texto_publicacion`, `fecha_creacion_pub`, `pub_es_privada`) VALUES ('4', '5', 'Publicacion del 5 pub', 'Publicacion del 5 pub', '2020-04-30 17:26:00', '0');
INSERT INTO `bd_red_social_3`.`publicacion` (`id_publicacion`, `id_usu`, `titulo_publicacion`, `texto_publicacion`, `fecha_creacion_pub`, `pub_es_privada`) VALUES ('5', '4', 'Publicacion del 4 priv com', 'Publicacion del 4 priv com', '2020-04-30 17:26:00', '1');
INSERT INTO `bd_red_social_3`.`publicacion` (`id_publicacion`, `id_usu`, `titulo_publicacion`, `texto_publicacion`, `fecha_creacion_pub`, `pub_es_privada`) VALUES ('6', '4', 'Publicacion del 4 pub com', 'Publicacion del 4 pub com', '2020-04-30 17:26:00', '0');
/*comentarios*/
INSERT INTO `bd_red_social_3`.`comentario` (`id_comentario`, `id_usuario`, `id_publicacion`, `texto_comentario`, `fecha_creacion_com`) VALUES ('2', '1', '5', 'comm pub privada', '2020-04-30 17:26:00');
INSERT INTO `bd_red_social_3`.`comentario` (`id_comentario`, `id_usuario`, `id_publicacion`, `texto_comentario`, `fecha_creacion_com`) VALUES ('3', '1', '6', 'comm pub publ', '2020-04-30 17:26:00');
INSERT INTO `bd_red_social_3`.`comentario` (`id_comentario`, `id_usuario`, `id_publicacion`, `texto_comentario`, `fecha_creacion_com`) VALUES ('4', '1', '5', 'comm pub privada 2', '2020-04-30 17:26:00');
/* Consulas SQL del proyecto ----------------------------------------------- */
/* --consultas BD red social-- */
/* estas consultas sirven para realizar distintos tipos de busquedas que realizara el programa*/
/* buscar todas las entradas de un usuario */
select e.id_usu, e.id_entrada, e.titulo_entrada, e.texto_entrada, e.fecha_creacion_ent
from entradas e, usuario u
where u.id_usu = e.id_usu
and u.id_usu = 1;
/* buscar amigos del usuario */
select am.id_solicitante, am.id_receptor, am.solicitud_aceptada,
u.id_usu
from amigos_usu am, usuario u
where u.id_usu = am.id_solicitante
and am.solicitud_aceptada = 1 and am.id_solicitante = 1;
select am.id_solicitante, am.id_receptor, am.solicitud_aceptada,
u.id_usu
from amigos_usu am, usuario u
where u.id_usu = am.id_receptor
and am.solicitud_aceptada = 1 and am.id_receptor = 1;
/*En el programa se usara ids para buscar y luego se obtendra los objetos usuario*/
select am.id_solicitante, am.id_receptor, am.solicitud_aceptada from amigos_usu am
where (am.id_receptor = 1 or am.id_solicitante = 1) and am.solicitud_aceptada = 1;
/* buscar nuevos amigos, sin incluir los que ya estan en peticion de amistad*/
/*manera optima*/
select u.id_usu from usuario u where u.id_usu
not in (select amigos_usu.id_receptor from amigos_usu where amigos_usu.id_receptor = 1 or amigos_usu.id_solicitante = 1)
and u.id_usu not in (select am.id_solicitante from amigos_usu am where am.id_receptor = 1 or am.id_solicitante = 1)
order by u.fecha_alta DESC;
/*por programa revisar cuales son aceptadas y cuales no*/
/* Nota: en el programa hay poner la opcion de rechazar o aceptar todas
ademas de la manera individual */
/* peticiones, si son rechazadas son null y se borran
si las peticiones son false se mantienen*/
/* buscar peticiones de amistad en general (sin identificar enviadas recibidas)*/
select am.id_solicitante, am.id_receptor, am.solicitud_aceptada from amigos_usu am
where (am.id_receptor = 1 or am.id_solicitante = 1) and am.solicitud_aceptada = 0;
/* buscar peticiones de amistad realizadas por el usuario*/
select am.id_solicitante, am.id_receptor, am.solicitud_aceptada,
u.id_usu
from amigos_usu am, usuario u
where u.id_usu = am.id_solicitante
and am.id_solicitante = 1
and am.solicitud_aceptada = 0;
/* buscar peticiones recibidas por el usuario*/
select am.id_solicitante, am.id_receptor, am.solicitud_aceptada,
u.id_usu
from amigos_usu am, usuario u
where u.id_usu = am.id_receptor
and am.id_receptor = 1
and am.solicitud_aceptada = 0;
/* buscar fotos del usuario limite de 9 ultimas */
select * from usuario u, fotos f
where u.id_usu = f.id_usu and u.id_usu = 1
order by f.fecha_subida_fot desc limit 9;
/* buscar fotos de un usuario*/
select * from usuario u, fotos f
where u.id_usu = f.id_usu and u.id_usu = 1
order by f.fecha_subida_fot desc;
/* buscar videos del usuario limite de 9 ultimas*/
select * from usuario u, videos v
where u.id_usu = v.id_usu and u.id_usu = 1
order by v.fecha_subida_vid desc limit 9;
/* buscar videos de un usuario*/
select * from usuario u, videos v
where u.id_usu = v.id_usu and u.id_usu = 1
order by v.fecha_subida_vid desc;
/*obtener las publicaciones de un usuario (para el perfil)*/
select publicacion.titulo_publicacion, publicacion.texto_publicacion, publicacion.id_usu
from publicacion where publicacion.id_usu = 4 order by publicacion.fecha_creacion_pub desc;
/*obtener publicaciones para el inicio (publicas, todos usuarios)*/
select publicacion.titulo_publicacion, publicacion.texto_publicacion,
publicacion.id_usu, publicacion.pub_es_privada, publicacion.fecha_creacion_pub
from publicacion where publicacion.pub_es_privada = 0
order by publicacion.fecha_creacion_pub desc;
/* buscar todas las publicaciones ordenadas por
fecha que sean publicas con un limite de 10 ultimas */
select publicacion.titulo_publicacion, publicacion.texto_publicacion,
publicacion.id_usu, publicacion.pub_es_privada, publicacion.fecha_creacion_pub
from publicacion where publicacion.pub_es_privada = 0
order by publicacion.fecha_creacion_pub desc limit 10;
/* buscar publicaciones de los amigos del usuario */
select publicacion.titulo_publicacion, publicacion.texto_publicacion,
publicacion.id_usu, publicacion.pub_es_privada, publicacion.fecha_creacion_pub
from publicacion where publicacion.id_usu = 1 and publicacion.id_usu
in(select am.id_solicitante from amigos_usu am where am.solicitud_aceptada = 1)
or
publicacion.id_usu in(select a.id_receptor from amigos_usu a where a.solicitud_aceptada = 1)
order by publicacion.fecha_creacion_pub desc;
/*
select publicacion.titulo_publicacion, publicacion.texto_publicacion, publicacion.id_usu
from publicacion where publicacion.id_usu = 4;
select publicacion.titulo_publicacion, publicacion.texto_publicacion, publicacion.id_usu
from publicacion where publicacion.id_usu in(select u.id_usu from usuario u, amigos_usu am
where u.id_usu = am.id_receptor or u.id_usu = am.id_solicitante
and am.solicitud_aceptada = 1);
select * from usuario u, amigos_usu am
where u.id_usu = am.id_receptor or u.id_usu = am.id_solicitante
and am.solicitud_aceptada = 1;
*/
/* buscar comentarios de una publicacion */
select * from comentario where comentario.id_publicacion = 5;
/*Seleccionar el ultimo id usuario (seleccionar el maximo)*/
SELECT max(id_usu) FROM bd_red_social_3.usuario; |
CREATE TABLE IF NOT EXISTS `Training_Timestamps` (
`uid` int(10) NOT NULL auto_increment,
`DATE` timestamp NOT NULL default CURRENT_TIMESTAMP,
`username` varchar(32) NOT NULL,
`action` varchar(1) NOT NULL default 'U',
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
UPDATE APX_ASA.WL_SCRIPT_PROCESS_LOAD
SET hostname = LOWER (REGEXP_SUBSTR (hostname, '^[^.]*'));
COMMIT;
UPDATE APX_ASA.TOMCAT_SCRIPT_PROCESS_LOAD
SET hostname = LOWER (REGEXP_SUBSTR (hostname, '^[^.]*'));
COMMIT;
UPDATE APX_ASA.APACHE_SCRIPT_PROCESS_LOAD
SET hostname = LOWER (REGEXP_SUBSTR (hostname, '^[^.]*'));
COMMIT;
UPDATE APX_ASA.SCRIPT_BLACKLIST_LOAD
SET hostname = LOWER (REGEXP_SUBSTR (hostname, '^[^.]*'));
COMMIT;
UPDATE APX_ASA.WL_INFO_OPSWARE_LOAD
SET hostname = LOWER (REGEXP_SUBSTR (hostname, '^[^.]*'));
COMMIT;
UPDATE APX_ASA.INFO_TURKUAZ_LOAD
SET hostname = LOWER (REGEXP_SUBSTR (hostname, '^[^.]*'));
COMMIT;
EXIT;
|
SELECT
city
FROM customers
ORDER BY city desc; |
/*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);
/*----------------------------------------------------*/
/*Queries*/
/*Display event name, location, venue and price for all events booked with Events-R-Us,
sorted by event data ascending*/
USE buildEvents;
SELECT eventName, venueName, venueCity, SUM(Cost) FROM (
SELECT ed.eventName, v.venueName, v.venueCity, v.venuePrice AS Cost
FROM booked.eventsBooked AS eb
INNER JOIN buildEvents.eventData AS ed
ON eb.dataID = ed.dataID
INNER JOIN buildEvents.venues AS v
ON ed.venueID = v.venueID
UNION ALL
SELECT ed.eventName, v.venueName, v.venueCity, SUM(es.servicePrice) AS Cost
FROM booked.eventsBooked AS eb
INNER JOIN booked.servicesbooked AS sb
ON eb.eventsBookedID = sb.eventsBookedID
INNER JOIN buildEvents.eventServices AS es
ON sb.servicesID = es.servicesID
INNER JOIN buildEvents.eventData AS ed
ON ed.dataID = eb.dataID
INNER JOIN buildEvents.venues AS v
ON ed.venueID = v.venueID
GROUP BY eventName, venueName, venueCity
UNION ALL
SELECT ed.eventName, v.venueName, v.venueCity, SUM(et.eventPrice) AS Cost
FROM booked.eventsbooked AS eb
INNER JOIN buildEvents.eventData AS ed
ON eb.dataID = ed.dataID
INNER JOIN buildEvents.eventTypes AS et
ON ed.typeID = et.typeID
INNER JOIN buildEvents.venues AS v
ON ed.venueID = v.venueID
GROUP BY eventName, venueName, venueCity
) AS results
GROUP BY eventName, venueName, venueCity
;
/*Display all staff information (personal data, department info, employee role) that has
been hired as a service add-on for all Event-R-Us events, sorted by last name then first
name*/
USE employeesClients;
SELECT e.employeeFirstName, e.employeeLastName, e.roleID, e.departmentID, e.employeeAddress, e.employeeCity, e.employeePostalCode, e.employeePhoneNumber
FROM employeesclients.employees AS e
INNER JOIN buildEvents.eventServices AS es
ON e.employeeID = es.employeeID
INNER JOIN booked.servicesBooked AS sb
ON es.servicesID = sb.servicesID
INNER JOIN booked.eventsBooked AS eb
ON sb.eventsBookedID = eb.eventsBookedID
ORDER BY e.employeeLastName, e.employeeFirstName;
/*The average price (including add-ons) for all booked events per unique event type
sorted by highest average value*/
USE booked;
SELECT eventType, AVG(Cost) FROM (
SELECT dataID, eventType, SUM(Cost) AS Cost FROM (
SELECT ed.dataID, et.eventType, v.venuePrice AS Cost
FROM booked.eventsBooked AS eb
INNER JOIN buildEvents.eventData AS ed
ON eb.dataID = ed.dataID
INNER JOIN buildEvents.venues AS v
ON ed.venueID = v.venueID
INNER JOIN buildEvents.eventTypes AS et
ON ed.typeID = et.typeID
UNION ALL
SELECT ed.dataID, et.eventType, SUM(es.servicePrice) AS Cost
FROM booked.eventsBooked AS eb
INNER JOIN booked.servicesbooked AS sb
ON eb.eventsBookedID = sb.eventsBookedID
INNER JOIN buildEvents.eventServices AS es
ON sb.servicesID = es.servicesID
INNER JOIN buildEvents.eventData AS ed
ON ed.dataID = eb.dataID
INNER JOIN buildEvents.venues AS v
ON ed.venueID = v.venueID
INNER JOIN buildEvents.eventTypes AS et
ON ed.typeID = et.typeID
GROUP BY dataID, eventType
UNION ALL
SELECT ed.dataID, et.eventType, SUM(et.eventPrice) AS Cost
FROM booked.eventsbooked AS eb
INNER JOIN buildEvents.eventData AS ed
ON eb.dataID = ed.dataID
INNER JOIN buildEvents.eventTypes AS et
ON ed.typeID = et.typeID
INNER JOIN buildEvents.venues AS v
ON ed.venueID = v.venueID
GROUP BY dataID, eventType
) AS results
GROUP BY dataID, eventType
) AS avgResults
GROUP BY eventType
ORDER BY AVG(Cost) desc;
;
|
CREATE DATABASE IF NOT EXISTS `contable` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `contable`;
-- MySQL dump 10.13 Distrib 5.6.17, for Win32 (x86)
--
-- Host: 127.0.0.1 Database: contable
-- ------------------------------------------------------
-- Server version 5.1.73-community
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `maetribub`
--
DROP TABLE IF EXISTS `maetribub`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `maetribub` (
`codigotrib` varchar(6) NOT NULL COMMENT 'Numero del codigo tributario',
`nombre` varchar(40) NOT NULL COMMENT 'Nombre del codigo tributario',
`tope` decimal(9,0) DEFAULT '0' COMMENT 'tope para el codigo tributario',
`nittope` varchar(10) DEFAULT '0' COMMENT 'nit del tope del codigo tributario',
`nomnit` varchar(50) DEFAULT NULL COMMENT 'nombre asignado al nit del tope',
`idcompania` int(11) NOT NULL,
PRIMARY KEY (`codigotrib`),
UNIQUE KEY `codigo_UNIQUE` (`codigotrib`),
KEY `fk_companiatrib_idx` (`idcompania`),
CONSTRAINT `fk_comapaniatrib` FOREIGN KEY (`idcompania`) REFERENCES `compania` (`idcompania`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Codigos Tributarios';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `maetribub`
--
LOCK TABLES `maetribub` WRITE;
/*!40000 ALTER TABLE `maetribub` DISABLE KEYS */;
INSERT INTO `maetribub` VALUES ('100','TRIBUTARIO NUMERO 1',100000000,'1313','TOPE 100',1);
/*!40000 ALTER TABLE `maetribub` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2015-02-04 13:33:03
|
-- version 5.0.6
-- package JotCache
-- category Joomla 3.3
-- copyright (C) 2010-2015 Vladimir Kanich
-- license GNU General Public License version 2 or later
DROP TABLE IF EXISTS `#__jotcache`;
DROP TABLE IF EXISTS `#__jotcache_exclude`;
|
IF OBJECT_ID('ActressMovie') IS NOT NULL DROP TABLE ActressMovie;
IF OBJECT_ID('Movie') IS NOT NULL DROP TABLE Movie;
IF OBJECT_ID('Actress') IS NOT NULL DROP TABLE Actress;
CREATE TABLE Actress (
actressId Integer NOT NULL,
name Char(50) NOT NULL,
agentEmail Char(50) NOT NULL,
CONSTRAINT ActressPk PRIMARY KEY(actressId)
);
CREATE TABLE Movie (
movieId Integer NOT NULL,
title Char(100) NOT NULL,
yearReleased Char(4) NOT NULL,
totalRevenue Float NOT NULL,
CONSTRAINT MoviePk PRIMARY KEY(movieId)
);
CREATE TABLE ActressMovie (
actressId Integer NOT NULL,
movieId Integer NOT NULL,
CONSTRAINT ActressMoviePk PRIMARY KEY(actressId, movieId),
CONSTRAINT ActressFk FOREIGN KEY(actressId) REFERENCES Actress(actressId),
CONSTRAINT MovieFk FOREIGN KEY(movieId) REFERENCES Movie(movieId)
);
INSERT INTO Actress (actressId, name, agentEmail)
VALUES(1, 'Zoe Saldana', 'amara@bigbigtalent.com'),
(2, 'Scarlett Johansson','tallulah@genericagency.com'),
(3, 'Emma Watson', 'cho@leadingtalentagency.com'),
(4, 'Letitia Wright', 'adira@hollywoodtalent.com'),
(5, 'Emma Thompston', 'fatima@uktalentstars.co.uk')
;
INSERT INTO Movie (movieId, title, yearReleased, totalRevenue)
VALUES(101, 'Avatar', 2009, 2787965087),
(102, 'Avengers:Endgame', 2019, 2797800564),
(103, 'Ready Player One', 2018, 579278642),
(104, 'Harry Potter and the Deathly Hallows: Part II', 2011, 1341656673),
(105, 'Beauty and the Beast', 2017, 1263204500)
;
INSERT INTO ActressMovie (actressId,movieId)
VALUES(2, 102),
(4, 103),
(3, 105),
(1, 101),
(4, 102),
(5, 105),
(1, 102),
(3, 104),
(5, 104)
;
SELECT a.actressId, AVG(totalRevenue) AS avgtotalRevenue
FROM Actress AS a INNER JOIN ActressMovie AS am ON a.actressId = am.actressId INNER JOIN Movie AS m ON m.movieId=am.movieId
GROUP BY a.actressId
ORDER BY avgtotalRevenue DESC
|
/*
Navicat MySQL Data Transfer
Source Server : localhost_3306
Source Server Version : 50562
Source Host : localhost:3306
Source Database : xiaouadmin
Target Server Type : MYSQL
Target Server Version : 50562
File Encoding : 65001
Date: 2020-12-28 16:55:56
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for banner
-- ----------------------------
DROP TABLE IF EXISTS `banner`;
CREATE TABLE `banner` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '轮播图id',
`title` varchar(50) NOT NULL COMMENT '轮播图标题',
`img` varchar(255) NOT NULL COMMENT '轮播图图片地址',
`status` tinyint(1) NOT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='轮播图表';
-- ----------------------------
-- Records of banner
-- ----------------------------
INSERT INTO `banner` VALUES ('1', '轮播图1', '/uploads/banner/76744550-b51a-11ea-8f98-3b344c58e56b.jpg', '1');
INSERT INTO `banner` VALUES ('2', '轮播图2', '/uploads/banner/7cf04640-b51a-11ea-8f98-3b344c58e56b.jpg', '1');
INSERT INTO `banner` VALUES ('3', '3', '/uploads/banner/21ebfe00-b51b-11ea-8f98-3b344c58e56b.jpg', '1');
-- ----------------------------
-- Table structure for cart
-- ----------------------------
DROP TABLE IF EXISTS `cart`;
CREATE TABLE `cart` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '购物车主键',
`uid` varchar(50) NOT NULL COMMENT '用户id',
`goodsid` int(11) NOT NULL COMMENT '商品编号',
`num` tinyint(3) NOT NULL COMMENT '数量',
`status` tinyint(1) NOT NULL COMMENT '选中状态',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uid` (`uid`,`goodsid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='购物车表';
-- ----------------------------
-- Records of cart
-- ----------------------------
INSERT INTO `cart` VALUES ('1', '2be08210-70fa-11ea-9c17-a5b3f9b0d2ba', '1', '3', '1');
INSERT INTO `cart` VALUES ('3', '2be08210-70fa-11ea-9c17-a5b3f9b0d2ba', '3', '1', '1');
INSERT INTO `cart` VALUES ('6', '83b04130-7283-11ea-8498-dd0ed7f822e5', '1', '3', '1');
INSERT INTO `cart` VALUES ('7', '83b04130-7283-11ea-8498-dd0ed7f822e5', '3', '1', '1');
INSERT INTO `cart` VALUES ('10', '83b04130-7283-11ea-8498-dd0ed7f822e5', '54', '1', '1');
-- ----------------------------
-- Table structure for category
-- ----------------------------
DROP TABLE IF EXISTS `category`;
CREATE TABLE `category` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '分类编号',
`pid` smallint(5) unsigned NOT NULL COMMENT '上级分类编号',
`catename` varchar(50) NOT NULL COMMENT '分类名称',
`img` varchar(255) NOT NULL COMMENT '分类图片',
`status` tinyint(1) unsigned NOT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='商品分类表';
-- ----------------------------
-- Records of category
-- ----------------------------
INSERT INTO `category` VALUES ('1', '0', '家用电器', '', '1');
INSERT INTO `category` VALUES ('2', '0', '手机通讯', '', '1');
INSERT INTO `category` VALUES ('3', '0', '电脑办公', '', '1');
INSERT INTO `category` VALUES ('4', '0', '家居', '', '1');
INSERT INTO `category` VALUES ('5', '0', '服装', '', '1');
INSERT INTO `category` VALUES ('7', '1', '电视', '/uploads/category/fc3abc50-6c2c-11ea-b86c-579aced212c2.jpg', '1');
INSERT INTO `category` VALUES ('8', '1', '空调', '/uploads/category/354b31f0-6c2d-11ea-b86c-579aced212c2.jpg', '1');
INSERT INTO `category` VALUES ('9', '1', '洗衣机', '/uploads/category/436e9470-6c2d-11ea-b86c-579aced212c2.jpg', '1');
INSERT INTO `category` VALUES ('10', '2', '手机', '/uploads/category/fee7e580-6c2d-11ea-b86c-579aced212c2.png', '1');
INSERT INTO `category` VALUES ('11', '3', '笔记本', '/uploads/category/ddb0b9f0-6de0-11ea-a8e1-0d680bf54839.jpg', '1');
-- ----------------------------
-- Table structure for goods
-- ----------------------------
DROP TABLE IF EXISTS `goods`;
CREATE TABLE `goods` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '商品编号',
`first_cateid` smallint(5) unsigned NOT NULL COMMENT '一级分类编号',
`second_cateid` smallint(6) NOT NULL COMMENT '二级分类编号',
`goodsname` varchar(100) NOT NULL COMMENT '商品名称',
`price` decimal(10,2) NOT NULL COMMENT '商品价格',
`market_price` decimal(10,2) NOT NULL COMMENT '市场价格',
`img` varchar(255) NOT NULL COMMENT '商品图片',
`description` text COMMENT '商品描述',
`specsid` int(11) NOT NULL COMMENT '规格id',
`specsattr` varchar(255) NOT NULL COMMENT '规则属性值',
`isnew` tinyint(1) NOT NULL COMMENT '是否新品1是2不是',
`ishot` tinyint(1) NOT NULL COMMENT '是否热卖1是2不是',
`status` tinyint(1) NOT NULL COMMENT '状态1启用2禁用',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='商品表';
-- ----------------------------
-- Records of goods
-- ----------------------------
INSERT INTO `goods` VALUES ('1', '2', '10', '小米10', '3999.00', '3999.00', '/uploads/fa5c2790-6c48-11ea-b894-9bd516f4e52e.jpg', '<p>11</p><p>22</p><p>33</p>', '3', '白色,黑色', '0', '1', '1');
INSERT INTO `goods` VALUES ('2', '3', '11', '联想小新', '4499.00', '4699.00', '/uploads/2747d670-6de1-11ea-a8e1-0d680bf54839.jpg', '<p><img src=\"https://img30.360buyimg.com/sku/jfs/t1/92075/21/15594/69153/5e7332afE99041ba5/6796969792546bcf.jpg\" style=\"max-width:100%;\"><br></p>', '3', '白色', '1', '0', '1');
INSERT INTO `goods` VALUES ('3', '2', '10', '荣耀9X', '1299.00', '1399.00', '/uploads/d6a0eff0-70be-11ea-91a2-9395060d7390.jpg', '', '3', '白色', '1', '2', '1');
INSERT INTO `goods` VALUES ('4', '2', '10', '华为matep30', '3999.00', '4999.00', '/uploads/fb704ec0-70be-11ea-91a2-9395060d7390.jpg', '', '3', '黑色', '2', '2', '1');
INSERT INTO `goods` VALUES ('5', '3', '11', '华为MateBook', '4299.00', '4597.00', '/uploads/1faae7a0-70bf-11ea-91a2-9395060d7390.jpg', '', '3', '白色', '2', '1', '1');
-- ----------------------------
-- Table structure for member
-- ----------------------------
DROP TABLE IF EXISTS `member`;
CREATE TABLE `member` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` varchar(50) NOT NULL COMMENT '用户编号',
`phone` char(11) NOT NULL COMMENT '手机号',
`nickname` varchar(50) NOT NULL COMMENT '昵称',
`password` char(32) NOT NULL COMMENT '密码',
`randstr` char(5) NOT NULL COMMENT '密码随机串',
`addtime` char(13) NOT NULL COMMENT '注册时间',
`status` tinyint(1) NOT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='会员表';
-- ----------------------------
-- Records of member
-- ----------------------------
INSERT INTO `member` VALUES ('1', '83b04130-7283-11ea-8498-dd0ed7f822e5', '15271093066', 'wuyun', 'a373d6703cdbce2b989e480caecf436d', 'laIA8', '1', '1');
INSERT INTO `member` VALUES ('2', '2be08210-70fa-11ea-9c17-a5b3f9b0d2ba', '18811112222', '小U', '', 'O6ImO', '1585403036849', '1');
INSERT INTO `member` VALUES ('3', '83b04130-7283-11ea-8498-dd0ed7f822e5', '18811113333', '小明', '0589b48e8d3ba87b979c63d77562864b', 'iBGAr', '1585571976387', '1');
-- ----------------------------
-- Table structure for menu
-- ----------------------------
DROP TABLE IF EXISTS `menu`;
CREATE TABLE `menu` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '菜单编号',
`pid` smallint(6) NOT NULL COMMENT '上级菜单编号',
`title` varchar(50) NOT NULL COMMENT '菜单名称',
`icon` varchar(100) NOT NULL COMMENT '菜单图标',
`type` tinyint(1) NOT NULL COMMENT '菜单类型1目录2菜单',
`url` varchar(100) NOT NULL COMMENT '菜单地址',
`status` tinyint(1) NOT NULL COMMENT '菜单状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='后台菜单权限表';
-- ----------------------------
-- Records of menu
-- ----------------------------
INSERT INTO `menu` VALUES ('1', '1', '1', '1', '1', '1', '1');
INSERT INTO `menu` VALUES ('16', '0', '系统设置', 'el-icon-setting', '1', '', '2');
INSERT INTO `menu` VALUES ('17', '16', '角色管理', '', '2', 'role', '1');
INSERT INTO `menu` VALUES ('18', '16', '菜单管理', '', '2', 'menu', '2');
INSERT INTO `menu` VALUES ('26', '0', '商城管理', 'el-icon-goods', '1', '', '2');
INSERT INTO `menu` VALUES ('33', '26', '商品分类', '', '2', 'category', '2');
INSERT INTO `menu` VALUES ('35', '16', '管理员管理', '', '2', 'manger', '1');
INSERT INTO `menu` VALUES ('37', '26', '商品规格', '', '2', 'spec', '1');
INSERT INTO `menu` VALUES ('38', '26', '商品管理', '', '2', 'goodmanag', '1');
INSERT INTO `menu` VALUES ('39', '26', '会员管理', '', '2', 'member', '1');
INSERT INTO `menu` VALUES ('40', '26', '轮播图管理', '', '2', 'banner', '1');
INSERT INTO `menu` VALUES ('41', '26', '秒杀活动', '', '2', 'seckill', '1');
-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '角色编号',
`rolename` varchar(100) NOT NULL COMMENT '角色名称',
`menus` varchar(255) NOT NULL COMMENT '菜单权限 存放的是菜单编号,用逗号隔开',
`status` tinyint(1) NOT NULL COMMENT '角色状态1正常2禁用',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='后台用户角色表';
-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES ('18', 'root', '[16,17,18,35,26,33,37,38,39,40,41]', '1');
INSERT INTO `role` VALUES ('32', 'admin', '[16,17,18,35,26,33,37,38,39,40,41]', '1');
INSERT INTO `role` VALUES ('36', '客服', '[26,33,37,38,39,40,41]', '1');
-- ----------------------------
-- Table structure for seckill
-- ----------------------------
DROP TABLE IF EXISTS `seckill`;
CREATE TABLE `seckill` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '秒杀表id',
`title` varchar(100) NOT NULL COMMENT '活动名称',
`begintime` char(13) NOT NULL COMMENT '秒杀开始时间',
`endtime` char(13) NOT NULL COMMENT '秒杀结束时间',
`first_cateid` smallint(5) NOT NULL COMMENT '商品一级分类编号',
`second_cateid` smallint(5) NOT NULL COMMENT '商品二级分类编号',
`goodsid` int(11) NOT NULL COMMENT '商品编号',
`status` tinyint(1) NOT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='限时秒杀活动表';
-- ----------------------------
-- Records of seckill
-- ----------------------------
INSERT INTO `seckill` VALUES ('2', '满20减10', '1607961600000', '1610380800000', '1', '3', '1', '1');
INSERT INTO `seckill` VALUES ('3', '气息1', '57600000', '3427200000', '1', '3', '1', '1');
-- ----------------------------
-- Table structure for specs
-- ----------------------------
DROP TABLE IF EXISTS `specs`;
CREATE TABLE `specs` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '规格id',
`specsname` varchar(50) NOT NULL COMMENT '规格名称',
`status` tinyint(1) NOT NULL COMMENT '规格状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='商品规格表';
-- ----------------------------
-- Records of specs
-- ----------------------------
INSERT INTO `specs` VALUES ('13', '颜色', '1');
INSERT INTO `specs` VALUES ('14', '尺寸', '1');
INSERT INTO `specs` VALUES ('15', '型号', '1');
INSERT INTO `specs` VALUES ('16', '款式', '1');
INSERT INTO `specs` VALUES ('17', 'hh', '1');
-- ----------------------------
-- Table structure for specs_attr
-- ----------------------------
DROP TABLE IF EXISTS `specs_attr`;
CREATE TABLE `specs_attr` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '规格项编号',
`specsid` int(11) NOT NULL COMMENT '规格的specsid',
`specsval` varchar(50) NOT NULL COMMENT '规格值',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='商品规格明细表';
-- ----------------------------
-- Records of specs_attr
-- ----------------------------
INSERT INTO `specs_attr` VALUES ('24', '13', '红');
INSERT INTO `specs_attr` VALUES ('25', '13', '黄');
INSERT INTO `specs_attr` VALUES ('26', '13', '绿');
INSERT INTO `specs_attr` VALUES ('27', '14', 's');
INSERT INTO `specs_attr` VALUES ('28', '14', 'm');
INSERT INTO `specs_attr` VALUES ('29', '14', 'l');
INSERT INTO `specs_attr` VALUES ('30', '15', '超博');
INSERT INTO `specs_attr` VALUES ('31', '15', '迷你');
INSERT INTO `specs_attr` VALUES ('32', '15', '正常');
INSERT INTO `specs_attr` VALUES ('33', '16', '宽松');
INSERT INTO `specs_attr` VALUES ('34', '16', '紧身');
INSERT INTO `specs_attr` VALUES ('35', '17', 'qwe');
INSERT INTO `specs_attr` VALUES ('36', '17', 'we');
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '住建',
`uid` varchar(50) NOT NULL COMMENT '管理员编号',
`roleid` smallint(5) NOT NULL COMMENT '角色编号',
`username` varchar(30) NOT NULL COMMENT '用户名',
`password` char(32) NOT NULL COMMENT '密码',
`randstr` char(5) NOT NULL COMMENT '随机加密串',
`status` tinyint(1) NOT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uid` (`uid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='后台管理员用户表';
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('13', '29501d30-4282-11eb-8cbe-330e6d309270', '32', 'admin', '5337732e0ab153e09d341e143d102f1d', 'GcDbw', '1');
INSERT INTO `user` VALUES ('16', 'a9434fc0-4369-11eb-b3c8-4df8b7833bb2', '18', 'root', 'bd922fa6d049674f06ab0aadf95fefc3', 'z2RVI', '1');
INSERT INTO `user` VALUES ('18', 'cd3cee10-4745-11eb-88e1-8ba2ec7c3ee8', '36', 'wuyunao', 'e58423af0dd651cbcb5a7c7b852b06d9', 'tP64X', '1');
|
ALTER TABLE CHATBOT_CUSTOM_CONFIG ADD COLUMN FONT_FAMILY VARCHAR(100) DEFAULT 'Arial, Helvetica, sans-serif';
comment on column CHATBOT_CUSTOM_CONFIG.FONT_FAMILY is
'Bot font family';
|
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 10, 2017 at 09:22 AM
-- Server version: 10.1.16-MariaDB
-- PHP Version: 7.0.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `houseofdiamante`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`admin_id` int(25) NOT NULL,
`admin_name` varchar(30) NOT NULL,
`admin_email` varchar(30) NOT NULL,
`telephone` int(25) NOT NULL,
`username` varchar(20) NOT NULL,
`Password` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`admin_id`, `admin_name`, `admin_email`, `telephone`, `username`, `Password`) VALUES
(1, 'Aruna', 'aruna@gmail.com', 646564646, 'aruna', '1234');
-- --------------------------------------------------------
--
-- Table structure for table `articles`
--
CREATE TABLE `articles` (
`id` int(11) NOT NULL,
`title_name` varchar(200) NOT NULL,
`username` varchar(250) NOT NULL,
`image_url` varchar(250) NOT NULL,
`likes` int(11) NOT NULL,
`loves` int(11) NOT NULL,
`hahas` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `articles`
--
INSERT INTO `articles` (`id`, `title_name`, `username`, `image_url`, `likes`, `loves`, `hahas`) VALUES
(1, 'beautiful ring', 'thila', 'img/photohub images/trend1.jpg', 1, 1, 1),
(2, 'eligent earings', 'seo', 'img/photohub images/earing1.jpg', 1, 1, 1),
(3, 'fabulous ring', 'guru', 'img/photohub images/jewel1.jpg', 1, 1, 1),
(4, 'necklaces', 'tharu1991', 'img/photohub images/trend2.jpg', 1, 1, 1),
(5, 'bangels', 'eranga123', 'img/photohub images/jewel2.jpg', 1, 1, 1),
(6, 'beautiful jewel', 'random', 'img/photohub images/trend3.jpg', 1, 0, 0),
(7, 'ring design', 'thila', 'img/photohub images/ring2.jpg', 0, 0, 0);
-- --------------------------------------------------------
--
-- Table structure for table `articles_haha`
--
CREATE TABLE `articles_haha` (
`id` int(11) NOT NULL,
`user` varchar(100) NOT NULL,
`article_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `articles_haha`
--
INSERT INTO `articles_haha` (`id`, `user`, `article_id`) VALUES
(1, 'mythree', 2),
(2, 'mythree', 1),
(3, 'mythree', 3),
(4, 'mythree', 4),
(5, 'mythree', 5),
(6, 'mythree', 7),
(7, 'mythree', 6),
(8, 'thila', 4),
(9, 'thila', 1),
(10, 'thila', 2);
-- --------------------------------------------------------
--
-- Table structure for table `articles_like`
--
CREATE TABLE `articles_like` (
`id` int(11) NOT NULL,
`user` varchar(250) NOT NULL,
`type` varchar(50) NOT NULL,
`article_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `articles_like`
--
INSERT INTO `articles_like` (`id`, `user`, `type`, `article_id`) VALUES
(22, 'mythree', 'like', 1),
(23, 'mythree', 'love', 1),
(24, 'mythree', 'haha', 4),
(26, 'mythree', 'haha', 1),
(27, 'mythree', 'like', 2),
(28, 'mythree', 'love', 2),
(29, 'mythree', 'haha', 2),
(30, 'mythree', 'like', 3),
(31, 'mythree', 'love', 3),
(32, 'mythree', 'haha', 3),
(33, 'mythree', 'like', 4),
(34, 'mythree', 'love', 4),
(35, 'mythree', 'like', 5),
(36, 'mythree', 'love', 5),
(37, 'mythree', 'haha', 5),
(38, 'mythree', 'like', 6);
--
-- Triggers `articles_like`
--
DELIMITER $$
CREATE TRIGGER `trig2` AFTER INSERT ON `articles_like` FOR EACH ROW BEGIN
IF NEW.type = 'like' THEN
UPDATE articles
SET likes = likes+1
WHERE articles.id = NEW.article_id;
END IF;
IF NEW.type = 'love' THEN
UPDATE articles
SET loves = loves+1
WHERE articles.id = NEW.article_id;
END IF;
IF NEW.type = 'haha' THEN
UPDATE articles
SET hahas = hahas+1
WHERE articles.id = NEW.article_id;
END IF;
END
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `articles_likes`
--
CREATE TABLE `articles_likes` (
`id` int(11) NOT NULL,
`user` varchar(20) NOT NULL,
`article_id` int(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `articles_likes`
--
INSERT INTO `articles_likes` (`id`, `user`, `article_id`) VALUES
(13, 'mythree', 3),
(14, 'mythree', 4),
(15, 'mythree', 5),
(47, 'mythree', 1),
(48, 'mythree', 2),
(49, 'mythree', 6),
(50, 'mythree', 7),
(52, 'thila', 1),
(57, 'thila', 5),
(61, 'thila', 6),
(66, 'thila', 2);
-- --------------------------------------------------------
--
-- Table structure for table `articles_love`
--
CREATE TABLE `articles_love` (
`id` int(11) NOT NULL,
`user` varchar(100) NOT NULL,
`article_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `articles_love`
--
INSERT INTO `articles_love` (`id`, `user`, `article_id`) VALUES
(4, 'mythree', 3),
(6, 'mythree', 2),
(7, 'mythree', 4),
(14, 'mythree', 7),
(15, 'mythree', 6),
(16, 'mythree', 1),
(17, 'mythree', 5),
(18, 'thila', 1),
(19, 'thila', 2),
(28, 'thila', 6);
-- --------------------------------------------------------
--
-- Table structure for table `centercut`
--
CREATE TABLE `centercut` (
`id` int(11) NOT NULL,
`cut_name` varchar(250) NOT NULL,
`image_url` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `centercut`
--
INSERT INTO `centercut` (`id`, `cut_name`, `image_url`) VALUES
(1, 'oval', 'img/center cut/oval.png'),
(2, 'heart', 'img/center cut/heart.png'),
(3, 'square', 'img/center cut/square.png');
-- --------------------------------------------------------
--
-- Table structure for table `chat`
--
CREATE TABLE `chat` (
`msg_id` int(11) NOT NULL,
`sender` varchar(100) NOT NULL,
`receiver` varchar(100) NOT NULL,
`message` text NOT NULL,
`updated_date` date NOT NULL,
`updated_time` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `chat`
--
INSERT INTO `chat` (`msg_id`, `sender`, `receiver`, `message`, `updated_date`, `updated_time`) VALUES
(21, 'mythree', 'cjs', 'hello sir,can you help me??', '0000-00-00', '00:00:00'),
(22, 'mythree', 'mallika', 'hello', '0000-00-00', '00:00:00'),
(23, 'mallika', 'mythree', 'yes sir,i can....', '0000-00-00', '00:00:00'),
(24, 'mythree', 'mallika', 'can i have quotation?', '0000-00-00', '00:00:00'),
(25, 'mythree', 'mallika', 'reply me', '0000-00-00', '00:00:00'),
(26, 'mythree', 'mallika', '???', '0000-00-00', '00:00:00'),
(27, 'mallika', 'mythree', 'okay.. for which model send me pic of it', '0000-00-00', '00:00:00'),
(28, 'mythree', 'mallika', 'okkkk sir', '0000-00-00', '00:00:00'),
(29, 'mythree', 'mallika', 'here', '0000-00-00', '00:00:00'),
(30, 'mythree', 'mallika', '>>>>>>', '0000-00-00', '00:00:00'),
(31, 'mythree', 'mallika', '<<<<<<<<<', '0000-00-00', '00:00:00'),
(32, 'mythree', 'mallika', 'gfhfg', '2016-08-30', '03:04:11'),
(33, 'mythree', 'mallika', 'ger', '2016-08-30', '03:05:07'),
(34, 'mythree', 'mallika', 'swwwww', '2016-08-30', '03:58:44'),
(35, 'mythree', 'mallika', 'gj', '2016-09-13', '03:49:08'),
(36, 'thila', 'mallika', 'hi', '2016-09-13', '08:38:10'),
(37, 'thila', 'mallika', 'hello', '2016-09-14', '08:04:41'),
(38, 'thila', 'mallika', 'gh', '2016-09-14', '08:34:53');
-- --------------------------------------------------------
--
-- Table structure for table `customerlogin`
--
CREATE TABLE `customerlogin` (
`id` int(11) NOT NULL,
`username` varchar(20) NOT NULL,
`email` varchar(30) NOT NULL,
`password` varchar(10) NOT NULL,
`image_url` varchar(250) NOT NULL,
`pro_pic` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `customerlogin`
--
INSERT INTO `customerlogin` (`id`, `username`, `email`, `password`, `image_url`, `pro_pic`) VALUES
(1, 'mythree', 'mythree@gmail.com', 'mythree', 'http://placehold.it/50x50', 'img/no_user.jpg'),
(2, 'arunadj', 'arunadilshanjayathilake@yahoo.', '123', 'http://placehold.it/50x50', 'img/no_user.jpg'),
(3, 'thila', 'thila@yahoo.com', 'thila', 'http://placehold.it/50x50', 'img/no_user.jpg'),
(6, 'dad', 'dad@yahoo.com', 'df3939f119', 'http://placehold.it/50x50', 'img/no_user.jpg'),
(7, 'jaya', 'jaya@gmail.com', 'ce9689abde', 'http://placehold.it/50x50', 'img/no_user.jpg'),
(8, 'Tharindu', 'tharindu.ishanka1994@gmail.com', '123', '', 'http://placehold.it/50x50');
-- --------------------------------------------------------
--
-- Table structure for table `dolist`
--
CREATE TABLE `dolist` (
`doId` int(11) NOT NULL,
`task` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `dolist`
--
INSERT INTO `dolist` (`doId`, `task`) VALUES
(1, 'drink coffee'),
(2, 'go go go');
-- --------------------------------------------------------
--
-- Table structure for table `gem`
--
CREATE TABLE `gem` (
`id` int(11) NOT NULL,
`gem_name` varchar(250) NOT NULL,
`model_name` varchar(250) NOT NULL,
`gem_dec` varchar(500) NOT NULL,
`image_url` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `gem`
--
INSERT INTO `gem` (`id`, `gem_name`, `model_name`, `gem_dec`, `image_url`) VALUES
(1, 'Saphire', 'edit_gem_blue', 'Trace amounts of elements such as iron, titanium, chromium, copper, or magnesium can give corundum respectively blue, yellow, purple, orange, or green color. Chromium impurities in corundum yield pink or red tint, the latter being called ruby. Commonly, sapphires are worn in jewelry.', 'img/gem/sapahire.png'),
(4, 'Ruby', 'edit_gem_red', '"A ruby is a pink to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). The red color is caused mainly by the presence of the element chromium. Its name comes from ruber, Latin for red. Other varieties of gem-quality corundum are called sapphires."\r\n', 'img/gem/ruby.png');
-- --------------------------------------------------------
--
-- Table structure for table `metal`
--
CREATE TABLE `metal` (
`id` int(11) NOT NULL,
`metal_name` varchar(250) NOT NULL,
`model_name` varchar(250) NOT NULL,
`image_url` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `metal`
--
INSERT INTO `metal` (`id`, `metal_name`, `model_name`, `image_url`) VALUES
(1, 'gold', 'edit_ring_Gold', 'img/metal/Gold.png'),
(2, 'silver', 'edit_ring_Silver', 'img/metal/silver.jpg'),
(3, 'rose', 'edit_ring_Rose', 'img/metal/rose.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `notification`
--
CREATE TABLE `notification` (
`not_id` int(11) NOT NULL,
`date` date NOT NULL,
`vendor` varchar(15) NOT NULL,
`customer` varchar(15) NOT NULL,
`view` varchar(10) NOT NULL,
`jewel_type` varchar(250) NOT NULL,
`size` decimal(10,0) NOT NULL,
`metal` varchar(255) NOT NULL,
`diamond` varchar(255) NOT NULL,
`price` decimal(10,0) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `notification`
--
INSERT INTO `notification` (`not_id`, `date`, `vendor`, `customer`, `view`, `jewel_type`, `size`, `metal`, `diamond`, `price`) VALUES
(1, '2016-09-07', 'swarnamahal', 'Tharindu', 'yes', '', '25', 'Gold', 'Rose', '35000'),
(2, '2016-09-12', 'Nileka', 'Aruna', 'no', '', '0', '', '', '0'),
(3, '2016-09-14', 'vogue', 'Tharindu', 'yes', '', '0', 'Silver', 'Rose', '1000'),
(4, '2016-09-21', 'manoma', 'Tharindu', 'yes', '', '0', 'silver', 'rose', '1200'),
(5, '2016-09-20', 'mallika', 'Tharindu', 'yes', '', '0', 'gold', 'rose', '0');
-- --------------------------------------------------------
--
-- Table structure for table `product_items`
--
CREATE TABLE `product_items` (
`item_id` int(11) NOT NULL,
`product_name` varchar(100) NOT NULL,
`product_type` varchar(100) NOT NULL,
`product_dec` varchar(250) NOT NULL,
`product_price` varchar(50) NOT NULL,
`image_url` varchar(250) NOT NULL,
`vendor_username` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `product_items`
--
INSERT INTO `product_items` (`item_id`, `product_name`, `product_type`, `product_dec`, `product_price`, `image_url`, `vendor_username`) VALUES
(1, 'white ring', 'ring', 'This is a short description. Lorem ipsum dolor sit amet, consectetur adipiscing elit.', '$64.99', 'img/vendor images/mallika/ring3.jpg', 'mallika'),
(2, 'gold neckles', 'neckles', 'gnxfgjxxnnvbxn', '$64.99', 'img/vendor images/mallika/necklace1.jpg', 'mallika'),
(3, 'silver ring', 'ring', 'sdrawetgdbcvx', '$64.99', 'img/vendor images/neha/ring1.jpg', 'Neha Jewellery'),
(4, 'necklace with<br> pearl', 'neckles', 'good looking', '$30.00', 'img/vendor images/neha/necklace2.jpg', 'Neha Jewellery'),
(5, 'Gold necklace', 'neckles', 'eligent one', '$35.00', 'img/vendor images/cjs/necklace3.jpg', 'cjs'),
(6, 'gold earings', 'earings', 'nice looking', '$20.00', 'img/vendor images/cjs/earing2.jpg', 'cjs'),
(7, 'silver ring with<br> diamond', 'ring', 'eligent and beautiful ring', '$69.00', 'img/vendor images/kendra/ring2.jpg', 'kendra scot'),
(8, 'gold ring with<br> diamond', 'ring', 'nice looking for ladies', '$56.00', 'img/vendor images/kendra/ring4.jpg', 'kendra scot');
-- --------------------------------------------------------
--
-- Table structure for table `quotation`
--
CREATE TABLE `quotation` (
`id` int(11) NOT NULL,
`full_name` varchar(250) NOT NULL,
`mobile_num` varchar(250) NOT NULL,
`email` varchar(250) NOT NULL,
`ring_size` varchar(250) NOT NULL,
`carrot_w` varchar(250) NOT NULL,
`metal` varchar(250) NOT NULL,
`gemstone` varchar(250) NOT NULL,
`center_cut` varchar(250) NOT NULL,
`image_url` varchar(250) NOT NULL,
`vendor` varchar(30) NOT NULL,
`view` varchar(20) NOT NULL DEFAULT 'no',
`item_type` varchar(40) NOT NULL DEFAULT 'ring'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `quotation`
--
INSERT INTO `quotation` (`id`, `full_name`, `mobile_num`, `email`, `ring_size`, `carrot_w`, `metal`, `gemstone`, `center_cut`, `image_url`, `vendor`, `view`, `item_type`) VALUES
(3, 'dfgdf', 'ssdh', 'fdhdf', '14ct', 'Size 5', 'Gold', 'red', 'heart', 'img/ring type/type1.png', 'cjs', 'yes', 'ring'),
(4, 'sgsgg', 'dsg', 'gsd', '14ct', 'Size 5', 'Gold', 'blue', 'oval', 'img/ring type/type1.png', 'mallika', 'no', 'ring');
-- --------------------------------------------------------
--
-- Table structure for table `rating`
--
CREATE TABLE `rating` (
`id` int(11) NOT NULL,
`user` varchar(100) NOT NULL,
`vendor_username` varchar(100) NOT NULL,
`rate` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `rating`
--
INSERT INTO `rating` (`id`, `user`, `vendor_username`, `rate`) VALUES
(1, 'mythree', 'mallika', 3),
(2, 'mythree', 'kendra scot', 4),
(3, '', 'mallika', 4),
(4, 'mythree', 'Neha Jewellery', 3),
(5, 'thila', 'cjs', 4),
(6, '', 'kendra scot', 3),
(7, '', 'cjs', 4);
-- --------------------------------------------------------
--
-- Table structure for table `ringtype`
--
CREATE TABLE `ringtype` (
`id` int(11) NOT NULL,
`type_name` varchar(250) NOT NULL,
`gem_n` varchar(250) NOT NULL,
`image_url` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `ringtype`
--
INSERT INTO `ringtype` (`id`, `type_name`, `gem_n`, `image_url`) VALUES
(1, 'type1', '1', 'img/ring type/type1.png'),
(2, 'type2', '2', 'img/ring type/type2.png');
-- --------------------------------------------------------
--
-- Table structure for table `temp_customerlogin`
--
CREATE TABLE `temp_customerlogin` (
`id` int(11) NOT NULL,
`confirm_code` varchar(50) NOT NULL,
`username` varchar(20) NOT NULL,
`email` varchar(40) NOT NULL,
`password` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `temp_customerlogin`
--
INSERT INTO `temp_customerlogin` (`id`, `confirm_code`, `username`, `email`, `password`) VALUES
(1, '4ee87bf8bc6dde8b0d88373edbb2c73c', 'arunadj', 'arunadilshanjayathilake@yahoo.com', '123'),
(2, 'a28bc4e0ef7e991224f5ce6b16f0797d', 'thila', 'thila@yahoo.com', 'thila'),
(3, '308833b636d84078b97d8ca84c14f116', 'jhbuhb', 'jhbujhb', '92163508c0b18e75db11'),
(4, '08d288990ac012f103ed3be9e5338495', '', '', '');
-- --------------------------------------------------------
--
-- Table structure for table `venderdetail`
--
CREATE TABLE `venderdetail` (
`vId` int(11) NOT NULL,
`vName` int(11) NOT NULL,
`vPassword` int(11) NOT NULL,
`vAddress` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `vendor`
--
CREATE TABLE `vendor` (
`id` int(11) NOT NULL,
`vendor_name` varchar(250) NOT NULL,
`vendor_email` varchar(250) NOT NULL,
`vendor_username` varchar(250) NOT NULL,
`vendor_password` varchar(250) NOT NULL,
`image_url` varchar(250) NOT NULL,
`telephone` int(10) NOT NULL,
`vAddress` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `vendor`
--
INSERT INTO `vendor` (`id`, `vendor_name`, `vendor_email`, `vendor_username`, `vendor_password`, `image_url`, `telephone`, `vAddress`) VALUES
(2, 'mallika', 'ml@gmail.com', 'mallika', 'mala', '', 34225368, 'N0.45/7,Malwatta junction,Uggalboda'),
(3, 'cjs', 'cjs@gmail.com', 'user1', 'cjs', 'img/vendor images/', 7123564, 'N0.34,ef,dcsghf');
-- --------------------------------------------------------
--
-- Table structure for table `vr`
--
CREATE TABLE `vr` (
`image_id` int(11) NOT NULL,
`vendor_name` varchar(25) NOT NULL,
`image` varchar(256) NOT NULL,
`product_type` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `vr`
--
INSERT INTO `vr` (`image_id`, `vendor_name`, `image`, `product_type`) VALUES
(1, 'Kendra Scott', 'img\\vr\\neck1.png', 'Necklace'),
(2, 'Neha jewellary', 'img\\vr\\neck2.png', 'Necklace'),
(3, 'Neha jewellary', 'img\\vr\\neck3.png', 'Necklace'),
(4, 'Kendra Scott', 'img/vr/neck4.png', 'Necklace');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`admin_id`);
--
-- Indexes for table `articles`
--
ALTER TABLE `articles`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `articles_haha`
--
ALTER TABLE `articles_haha`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `articles_like`
--
ALTER TABLE `articles_like`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `articles_likes`
--
ALTER TABLE `articles_likes`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `articles_love`
--
ALTER TABLE `articles_love`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `centercut`
--
ALTER TABLE `centercut`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `chat`
--
ALTER TABLE `chat`
ADD PRIMARY KEY (`msg_id`);
--
-- Indexes for table `customerlogin`
--
ALTER TABLE `customerlogin`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `dolist`
--
ALTER TABLE `dolist`
ADD PRIMARY KEY (`doId`);
--
-- Indexes for table `gem`
--
ALTER TABLE `gem`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `metal`
--
ALTER TABLE `metal`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `notification`
--
ALTER TABLE `notification`
ADD PRIMARY KEY (`not_id`);
--
-- Indexes for table `product_items`
--
ALTER TABLE `product_items`
ADD PRIMARY KEY (`item_id`);
--
-- Indexes for table `quotation`
--
ALTER TABLE `quotation`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `rating`
--
ALTER TABLE `rating`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `ringtype`
--
ALTER TABLE `ringtype`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `temp_customerlogin`
--
ALTER TABLE `temp_customerlogin`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `vendor`
--
ALTER TABLE `vendor`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `vr`
--
ALTER TABLE `vr`
ADD PRIMARY KEY (`image_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `admin_id` int(25) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `articles`
--
ALTER TABLE `articles`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `articles_haha`
--
ALTER TABLE `articles_haha`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `articles_like`
--
ALTER TABLE `articles_like`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=39;
--
-- AUTO_INCREMENT for table `articles_likes`
--
ALTER TABLE `articles_likes`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=67;
--
-- AUTO_INCREMENT for table `articles_love`
--
ALTER TABLE `articles_love`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29;
--
-- AUTO_INCREMENT for table `centercut`
--
ALTER TABLE `centercut`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `chat`
--
ALTER TABLE `chat`
MODIFY `msg_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=39;
--
-- AUTO_INCREMENT for table `customerlogin`
--
ALTER TABLE `customerlogin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `dolist`
--
ALTER TABLE `dolist`
MODIFY `doId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `gem`
--
ALTER TABLE `gem`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `metal`
--
ALTER TABLE `metal`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `notification`
--
ALTER TABLE `notification`
MODIFY `not_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `product_items`
--
ALTER TABLE `product_items`
MODIFY `item_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `quotation`
--
ALTER TABLE `quotation`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `rating`
--
ALTER TABLE `rating`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `ringtype`
--
ALTER TABLE `ringtype`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `temp_customerlogin`
--
ALTER TABLE `temp_customerlogin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `vendor`
--
ALTER TABLE `vendor`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `vr`
--
ALTER TABLE `vr`
MODIFY `image_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
/*!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: Dec 06, 2020 at 10:30 AM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.4.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `uangkas`
--
-- --------------------------------------------------------
--
-- Table structure for table `jurnal`
--
CREATE TABLE `jurnal` (
`ids` int(11) NOT NULL,
`id` int(11) NOT NULL,
`keterangan` varchar(255) DEFAULT NULL,
`tanggal` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
--
-- Dumping data for table `jurnal`
--
INSERT INTO `jurnal` (`ids`, `id`, `keterangan`, `tanggal`) VALUES
(2, 8, 'masuk 1', '2020-12-04'),
(3, 9, 'keluar 1', '2020-12-05'),
(4, 10, 'keluar 2', '2020-12-04'),
(5, 11, 'masuk 2', '2020-12-05'),
(6, 12, 'masuk 3a', '2020-12-07'),
(9, 15, 'keluar 3a', '2020-12-07');
-- --------------------------------------------------------
--
-- Table structure for table `jurnal_detail`
--
CREATE TABLE `jurnal_detail` (
`ids` int(11) NOT NULL,
`id_jurnal` varchar(255) DEFAULT NULL,
`kredit` int(255) DEFAULT NULL,
`debit` int(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
--
-- Dumping data for table `jurnal_detail`
--
INSERT INTO `jurnal_detail` (`ids`, `id_jurnal`, `kredit`, `debit`) VALUES
(2, '2', 0, 150000),
(3, '3', 5000, 0),
(4, '4', 10000, 0),
(5, '5', 0, 250000),
(6, '6', 0, 100000),
(9, '9', 50000, 0);
-- --------------------------------------------------------
--
-- Table structure for table `kas`
--
CREATE TABLE `kas` (
`id` int(11) NOT NULL,
`id_transaksi` varchar(50) NOT NULL,
`keterangan` varchar(50) NOT NULL,
`tanggal` date NOT NULL,
`jumlah` int(11) NOT NULL,
`tipe` enum('masuk','keluar') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `kas`
--
INSERT INTO `kas` (`id`, `id_transaksi`, `keterangan`, `tanggal`, `jumlah`, `tipe`) VALUES
(8, '', 'masuk 1', '2020-12-04', 150000, 'masuk'),
(9, '', 'keluar 1', '2020-12-05', 5000, 'keluar'),
(10, '', 'keluar 2', '2020-12-04', 10000, 'keluar'),
(11, '', 'masuk 2', '2020-12-05', 250000, 'masuk'),
(12, '', 'masuk 3a', '2020-12-07', 100000, 'masuk'),
(15, '', 'keluar 3a', '2020-12-07', 50000, 'keluar');
--
-- Triggers `kas`
--
DELIMITER $$
CREATE TRIGGER `after_kas_insert` AFTER INSERT ON `kas` FOR EACH ROW BEGIN
DECLARE id_jurnal INT;
INSERT INTO jurnal(id, keterangan,tanggal)
VALUES(NEW.id,NEW.keterangan,NEW.tanggal);
select ids INTO id_jurnal
from jurnal where id=NEW.id;
IF NEW.tipe = 'keluar' THEN
INSERT INTO jurnal_detail(id_jurnal, kredit,debit)
VALUES(id_jurnal,NEW.jumlah,0);
ELSE
INSERT INTO jurnal_detail(id_jurnal, kredit,debit)
VALUES(id_jurnal,0,NEW.jumlah);
END IF;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `before_kas_delete` BEFORE DELETE ON `kas` FOR EACH ROW BEGIN
DELETE FROM jurnal_detail where id_jurnal=(select ids from jurnal where id=OLD.id);
DELETE FROM jurnal where id=OLD.id;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `before_kas_update` BEFORE UPDATE ON `kas` FOR EACH ROW BEGIN
IF OLD.tipe = 'keluar' THEN
UPDATE jurnal_detail
SET kredit=NEW.jumlah, debit=0 where id_jurnal=(select ids from jurnal where id=OLD.id);
ELSE
UPDATE jurnal_detail
SET kredit=0, debit=NEW.jumlah where id_jurnal=(select ids from jurnal where id=OLD.id);
END IF;
UPDATE jurnal
SET keterangan=NEW.keterangan ,tanggal= NEW.tanggal
WHERE id=OLD.id;
END
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `keluar`
--
CREATE TABLE `keluar` (
`id` int(11) NOT NULL,
`keterangan` varchar(50) NOT NULL,
`tanggal` date NOT NULL,
`jumlah` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `keluar`
--
INSERT INTO `keluar` (`id`, `keterangan`, `tanggal`, `jumlah`) VALUES
(1, 'Konsumsi', '2020-11-30', 100000),
(2, 'Transportasi', '2020-12-10', 40000),
(4, 'Konsumsi 2', '2020-12-09', 250000),
(5, 'Transportasi 2', '2020-12-12', 60000);
-- --------------------------------------------------------
--
-- Table structure for table `masuk`
--
CREATE TABLE `masuk` (
`id` int(11) NOT NULL,
`keterangan` varchar(50) NOT NULL,
`tanggal` date NOT NULL,
`jumlah` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `masuk`
--
INSERT INTO `masuk` (`id`, `keterangan`, `tanggal`, `jumlah`) VALUES
(1, 'Kas Mingguan 1', '2020-11-29', 130000),
(2, 'Kas Mingguan 2', '2020-12-06', 170000),
(4, 'Sponsor 1', '2020-12-11', 1000000),
(5, 'Donasi', '2020-12-12', 50000),
(6, 'Hadiah', '2020-12-08', 1000000);
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`name` varchar(128) NOT NULL,
`email` varchar(128) NOT NULL,
`image` varchar(128) NOT NULL,
`password` varchar(256) NOT NULL,
`role_id` int(11) NOT NULL,
`is_active` int(1) NOT NULL,
`date_created` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`id`, `name`, `email`, `image`, `password`, `role_id`, `is_active`, `date_created`) VALUES
(8, 'Amjad Aziz', 'a@gmail.com', 'default.png', '$2y$10$YmKf8VPp1WZoD2FH8HEKyOiN1R9LBhxOFWqUn2O33L9ie1e3mHtX6', 1, 1, '0000-00-00');
-- --------------------------------------------------------
--
-- Table structure for table `user_role`
--
CREATE TABLE `user_role` (
`id` int(11) NOT NULL,
`role` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `jurnal`
--
ALTER TABLE `jurnal`
ADD PRIMARY KEY (`ids`) USING BTREE;
--
-- Indexes for table `jurnal_detail`
--
ALTER TABLE `jurnal_detail`
ADD PRIMARY KEY (`ids`) USING BTREE;
--
-- Indexes for table `kas`
--
ALTER TABLE `kas`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `keluar`
--
ALTER TABLE `keluar`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `masuk`
--
ALTER TABLE `masuk`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `user_role`
--
ALTER TABLE `user_role`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `jurnal`
--
ALTER TABLE `jurnal`
MODIFY `ids` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `jurnal_detail`
--
ALTER TABLE `jurnal_detail`
MODIFY `ids` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `kas`
--
ALTER TABLE `kas`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT for table `keluar`
--
ALTER TABLE `keluar`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `masuk`
--
ALTER TABLE `masuk`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `user_role`
--
ALTER TABLE `user_role`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
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 */;
|
/* order by */
SELECT * FROM PRODUCTOS WHERE SECCIÓN = "CERÁMICA" OR SECCIÓN = "DEPORTES" ORDER BY SECCIÓN;
/* seleccionar todos los campos de seccion que sean igual a ceramica o deportes ordenados por seccion */
SELECT * FROM PRODUCTOS WHERE SECCIÓN = "CERÁMICA" OR SECCIÓN = "DEPORTES" ORDER BY SECCIÓN DESC;
/* seleccionar todos los campos de seccion que sean igual a ceramica o deportes ordenados por seccion de mayor a menor*/
SELECT * FROM PRODUCTOS WHERE SECCIÓN = "CERÁMICA" OR SECCIÓN = "DEPORTES" ORDER BY SECCIÓN, PRECIO;
/* seleccionar todos los campos de seccion que sean igual a ceramica o deportes ordenados por seccion y luego por precio */
SELECT * FROM PRODUCTOS WHERE SECCIÓN = "CERÁMICA" OR SECCIÓN = "DEPORTES" ORDER BY SECCIÓN, PRECIO DESC;
/* seleccionar todos los campos de seccion que sean igual a ceramica o deportes ordenados por seccion y luego por precio decendente*/
|
/* Создание таблицы призов билетов */
CREATE TABLE /*PREFIX*/TICKET_PRIZES
(
TICKET_ID VARCHAR(32) NOT NULL,
PRIZE_ID VARCHAR(32) NOT NULL,
PRIORITY INTEGER,
ISSUE_DATE TIMESTAMP,
PRIMARY KEY (TICKET_ID,PRIZE_ID),
FOREIGN KEY (TICKET_ID) REFERENCES /*PREFIX*/TICKETS (TICKET_ID),
FOREIGN KEY (PRIZE_ID) REFERENCES /*PREFIX*/PRIZES (PRIZE_ID)
)
--
/* Создание просмотра таблицы призов билетов */
CREATE VIEW /*PREFIX*/S_TICKET_PRIZES
(
TICKET_ID,
PRIZE_ID,
PRIORITY,
ISSUE_DATE,
TICKET_NUM,
TICKET_SERIES,
PRIZE_NAME
)
AS
SELECT TP.*,
T.NUM AS TICKET_NUM,
T.SERIES AS TICKET_SERIES,
P.NAME AS PRIZE_NAME
FROM /*PREFIX*/TICKET_PRIZES TP
JOIN /*PREFIX*/TICKETS T ON T.TICKET_ID=TP.TICKET_ID
JOIN /*PREFIX*/PRIZES P ON P.PRIZE_ID=TP.PRIZE_ID
--
/* Создание процедуры добавления приза билету */
CREATE PROCEDURE /*PREFIX*/I_TICKET_PRIZE
(
TICKET_ID VARCHAR(32),
PRIZE_ID VARCHAR(32),
PRIORITY INTEGER,
ISSUE_DATE TIMESTAMP
)
AS
BEGIN
INSERT INTO /*PREFIX*/TICKET_PRIZES (TICKET_ID,PRIZE_ID,PRIORITY,ISSUE_DATE)
VALUES (:TICKET_ID,:PRIZE_ID,:PRIORITY,:ISSUE_DATE);
END;
--
/* Создание процедуры изменения приза у билета */
CREATE PROCEDURE /*PREFIX*/U_TICKET_PRIZE
(
TICKET_ID VARCHAR(32),
PRIZE_ID VARCHAR(32),
PRIORITY INTEGER,
ISSUE_DATE TIMESTAMP,
OLD_TICKET_ID VARCHAR(32),
OLD_PRIZE_ID VARCHAR(32)
)
AS
BEGIN
UPDATE /*PREFIX*/TICKET_PRIZES
SET TICKET_ID=:TICKET_ID,
PRIZE_ID=:PRIZE_ID,
PRIORITY=:PRIORITY,
ISSUE_DATE=:ISSUE_DATE
WHERE TICKET_ID=:OLD_TICKET_ID
AND PRIZE_ID=:OLD_PRIZE_ID;
END;
--
/* Создание процедуры удаления приза у билета */
CREATE PROCEDURE /*PREFIX*/D_TICKET_PRIZE
(
OLD_TICKET_ID VARCHAR(32),
OLD_PRIZE_ID VARCHAR(32)
)
AS
BEGIN
DELETE FROM /*PREFIX*/TICKET_PRIZES
WHERE TICKET_ID=:OLD_TICKET_ID
AND PRIZE_ID=:OLD_PRIZE_ID;
END;
--
/* Фиксация изменений */
COMMIT |
CREATE OR REPLACE PROCEDURE U_Curr
as
rt student%ROWTYPE;
CURSOR curr
is
select * FROM
student;
begin
open curr;
LOOP
FETCH curr INTO rt;
EXIT WHEN curr%NOTFOUND;
DBMS_OUTPUT.PUT_LINE ('Student Name ' || rt.NAME);
END LOOP;
IF curr%NOTFOUND THEN
DBMS_OUTPUT.PUT_LINE ('Number of Students is '||curr%ROWCOUNT);
END IF;
end;
call U_Curr(); |
SELECT
per.first_name,
per.last_name,
per.rpga_number,
SUM(IF(sec.section_number=1,ps.prorated_score,0)) sec1,
SUM(IF(sec.section_number=2,ps.prorated_score,0)) sec2,
SUM(IF(sec.section_number=3,ps.prorated_score,0)) sec3,
SUM(IF(sec.section_number=4,ps.prorated_score,0)) sec4,
SUM(IF(sec.section_number=5,ps.prorated_score,0)) sec5,
SUM(IF(sec.section_number=6,ps.prorated_score,0)) sec6,
SUM(IF(sec.section_number=7,ps.prorated_score,0)) sec7,
SUM(IF(sec.section_number=8,ps.prorated_score,0)) sec8,
SUM(IF(sec.section_number=9,ps.prorated_score,0)) sec9,
SUM(IF(sec.section_number=10,ps.prorated_score,0)) sec10,
SUM(IF(sec.section_number=11,ps.prorated_score,0)) sec11,
SUM(IF(sec.section_number=12,ps.prorated_score,0)) sec12,
SUM(IF(sec.section_number=13,ps.prorated_score,0)) sec13,
COUNT(*) num_events,
AVG(ps.prorated_score) avg_score
FROM
person per,
score_packet pack,
person_section ps,
event ev,
section sec
WHERE
ps.person_id = per.id
AND ps.score_packet_id = pack.id
AND pack.event_id = ev.id
AND pack.section_id = sec.id
AND sec.section_number != 0
AND ps.judge = 'CHECKED'
GROUP BY
per.first_name,
per.last_name,
per.rpga_number
HAVING
COUNT(*) > 2
ORDER BY
per.rpga_number
; |
CREATE TABLE
TRANSACTIONS
(
TRANSACTION_ID BIGINT NOT NULL,
DATE DATETIME NOT NULL,
DETAILS NVARCHAR(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
DETAILS_TYPE NVARCHAR(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
LOAN_ID NVARCHAR(20) COLLATE SQL_Latin1_General_CP1_CI_AS,
TURNOVER DECIMAL(16,6),
BALANCE DECIMAL(16,6),
CURRENCY VARCHAR(3) COLLATE SQL_Latin1_General_CP1_CI_AS,
EXCHANGE_RATE DECIMAL(16,6),
PURPOSE NVARCHAR(255) COLLATE SQL_Latin1_General_CP1_CI_AS,
PRIMARY KEY (TRANSACTION_ID),
CONSTRAINT TRANSACTIONS_ix1 UNIQUE (TRANSACTION_ID)
);
CREATE TABLE
INVESTMENT
(
DATE DATETIME NOT NULL,
INVESTMENT DECIMAL(18,6) NOT NULL
); |
-- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 08-08-2014 a las 09:02:23
-- Versión del servidor: 5.6.16
-- Versión de PHP: 5.5.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Base de datos: `proyectodespacho`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `cartaremisora`
--
CREATE TABLE IF NOT EXISTS `cartaremisora` (
`id` varchar(45) NOT NULL,
`idArticulo` varchar(45) DEFAULT NULL,
`idCliente` varchar(45) DEFAULT NULL,
`idUsuario` varchar(45) DEFAULT NULL,
`Direccion` varchar(45) DEFAULT NULL,
`Telefono` int(11) DEFAULT NULL,
`Ciudad` varchar(45) DEFAULT NULL,
`Flete_Pagadero` varchar(45) DEFAULT NULL,
`Numero_Factura` varchar(45) DEFAULT NULL,
`Cantidad_Articulo` int(11) DEFAULT NULL,
`Valor_Unitario_Articulo` int(11) DEFAULT NULL,
`Valor_Total` int(11) DEFAULT NULL,
`Numero_Bultos` varchar(45) DEFAULT NULL,
`Fecha_Creacion` datetime DEFAULT NULL,
`Fecha_Modificacion` datetime DEFAULT NULL,
`descripcion` varchar(10000) DEFAULT NULL,
`consecutivo` int(11) DEFAULT NULL,
`Empresa` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_idArticulo_idx` (`idArticulo`),
KEY `Fk_idCliente_idx` (`idCliente`),
KEY `Fk_idUsuario_idx` (`idUsuario`),
KEY `Fk_ciudad_idx` (`Ciudad`),
KEY `Fk_empresa_idx` (`Empresa`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcado de datos para la tabla `cartaremisora`
--
INSERT INTO `cartaremisora` (`id`, `idArticulo`, `idCliente`, `idUsuario`, `Direccion`, `Telefono`, `Ciudad`, `Flete_Pagadero`, `Numero_Factura`, `Cantidad_Articulo`, `Valor_Unitario_Articulo`, `Valor_Total`, `Numero_Bultos`, `Fecha_Creacion`, `Fecha_Modificacion`, `descripcion`, `consecutivo`, `Empresa`) VALUES
('2249c3c4-6f61-72f6-5462-5ce794eadd55', '22241179-958d-2773-82da-5421a65ee855', 'd4adb4f2-42a5-6cf7-6e47-fd7ce55636f8', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CALLE JUAN DEL CORRAL ENSEGUIDA DE EDATEL', 8256886, '276', 'esp.med', '9-137245', NULL, NULL, 275734, '2', '2014-08-04 14:46:08', '2014-08-04 14:46:08', 'COL ECO LINE D-18 100X190X20 JAC E COLOR-2-137867#', 4, '7'),
('5495fbfc-6fdb-2666-9d54-e0b300e55ab2', '70002661', 'f2aa1c08-4217-cd45-80cf-9fc28ff70e6b', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CRA 21 # 18-37', 8871478, '1090', 'esp.med', '9-138281 9-138385 80761167', NULL, NULL, 2110624, '8', '2014-08-06 12:42:42', '2014-08-06 12:42:42', 'COL SPECIAL LIFE FIRME 140X190X22-4-383180#COL ECO LINE D-26 120X190X20 JAC E-2-198352#PROTECTOR COLCHON BANDA LISA 140x190-4-25900#ALMUHADA ROYAL-8-9700#', 10, '4'),
('59aebab7-7b5a-8f31-b748-5b2fe701392a', 'c294c9c6-94a1-3a71-7422-94ab2e382df2', '2292464d-a1db-1952-f371-71157ecbf950', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CRA 17 # 24-46 APTO 402 ED. FADIA', 2147483647, '175', 'esp.med', '5-17080', NULL, NULL, 602680, '2', '2014-08-06 13:20:05', '2014-08-06 13:20:05', 'COL SENSAF C30 PLUS 140X190X25 JAC-1-344800#COL SENSAF C30 120X190X22 JAC LDOR-1-257880#', 11, 'd34d8457-584e-c298-565b-c492d869df5d'),
('862fefef-8245-68c7-e2cb-cbde1bd81a8d', '10000172', 'b411e16c-e681-6f11-3da5-e6a9a14855f6', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CR 40', 26588771, '1070', '15000', 'ASDAS', NULL, NULL, 30000, '5', '2014-08-05 15:34:09', '2014-08-05 15:37:22', 'TELA ALM MICROVELOUR LFY-2-15000#', 8, '13b19db4-3d97-61a9-498d-41b1c69af8fd'),
('9cf6cffc-1e60-9168-0325-e494a2c1c633', '80003046', '9e56ad65-e92b-fb6b-9ffc-d5135e89ab35', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CRA 50 # 2-143', 2147483647, '452', 'esp.med', '9-138058', NULL, NULL, 839400, '3', '2014-08-04 18:21:24', '2014-08-04 18:21:24', 'LAM EX 120,0x190,0x005,0-24-34975#', 6, '13b19db4-3d97-61a9-498d-41b1c69af8fd'),
('beb52ac3-4787-af80-80c0-6185df6b03ee', '10002247', 'c32ed17b-0c72-047e-987d-db94e2e0ec31', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'cr 48 89-87', 8523641, 'dc22fc44-caeb-b94c-6de0-44012db80584', '15000', 'sdf5545', NULL, NULL, 280000, '2', '2014-07-30 15:02:36', '2014-07-30 15:03:16', 'TELA ALGODON COLORES 132 HILOS COLHONES-5-56000#', 1, '13b19db4-3d97-61a9-498d-41b1c69af8fd'),
('c5c84349-96be-c0eb-48ab-1a3c609d3969', '80006150', 'd845ba3c-9b68-ec31-fa8a-18a7874083b8', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CRA10# 11-54', 8494569, 'ea8b8e08-24f6-cd43-9c8e-4a7be62391e7', 'esp.med', '900137395', NULL, NULL, 375648, '2', '2014-07-30 15:16:53', '2014-08-01 15:14:37', 'LAM SF 100,0x200,0x002,0 RS-48-7826#', 2, '13b19db4-3d97-61a9-498d-41b1c69af8fd'),
('cbafcc08-d197-0f57-94a8-5d2e31257044', '90052719', '5cc108c8-4c68-e554-8a33-c14fd9ab1d5b', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CALLE 11 # 10-63', 8304295, 'a9949734-fa5c-cbc5-b3c1-c83ef19d7f50', 'esp.med', '9-137784', NULL, NULL, 292320, '12', '2014-08-01 15:12:44', '2014-08-01 15:13:58', 'CTA TSE 100X190X10 ALG COLORES SENCILLO-12-24360#', 3, 'c2408ed2-10d7-6477-0a3f-0da546448ab2'),
('d76e2f13-6495-1f3b-781a-a915c51579c6', '08c52e9d-92ba-937c-3200-05af6301f06c', '5556231b-fc18-383a-055c-5f91eb1f21ed', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CALLE 10 # 4-24', 8533023, '883', 'E', '9-138205 9-137939', NULL, NULL, 724500, '2', '2014-08-05 15:31:47', '2014-08-05 15:31:47', 'COL SENSAF C-30 140X190X22 JAC LDOR-2-362250#', 7, '7'),
('de43255a-4a59-dc4f-09c2-cd1d105b04a2', '90054937', '9e56ad65-e92b-fb6b-9ffc-d5135e89ab35', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CRA 50 # 2-143', 2147483647, '452', 'esp.med', '9-138277', NULL, NULL, 202272, '4', '2014-08-06 12:36:06', '2014-08-06 12:36:06', 'CTA SF 100X190X14 ALG COLORES SENCILLO-2-46057#CTA SF 120X180X14 ALG COLORES SENCILLA-2-055079#', 9, '13b19db4-3d97-61a9-498d-41b1c69af8fd'),
('ff04545f-772f-240b-abff-ae40236ead09', '6739a9f8-10b9-93ae-f6c0-d4ee020c6eba', 'f87cf679-04f5-4054-7e99-4f5d40c9c947', '24c79c90-37bb-73ab-bb7e-2d11a031eec6', 'CALLE 20 # 21-47', 8538714, '1090', 'esp.med', '9-138111', NULL, NULL, 1122840, '10', '2014-08-04 17:21:59', '2014-08-04 17:21:59', 'LAM SF 090X190X16 RS-30-37428#', 5, '4');
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `cartaremisora`
--
ALTER TABLE `cartaremisora`
ADD CONSTRAINT `Fk_idArticulo` FOREIGN KEY (`idArticulo`) REFERENCES `articulos` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `Fk_idCliente` FOREIGN KEY (`idCliente`) REFERENCES `cliente` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `Fk_idUsuario` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `Fk_ciudad` FOREIGN KEY (`Ciudad`) REFERENCES `ciudad` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `Fk_empresa` FOREIGN KEY (`Empresa`) REFERENCES `empresa` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
/*!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 */;
|
delete from tags
where
tag = $1 and
value = $2;
|
create table timer_service_users
(
email varchar(100) constraint TIMER_SERVICE_USERS_EMAIL_PK primary key,
password varchar(100) constraint TIMER_SERVICE_USERS_PASSWORD_NN not null,
constraint TIMER_SERVICE_USERS_PASSWORD_MIN_LEN check(len(password) >= 6)
);
create table timer_service_timers
(
id integer identity(1, 1) constraint TIMER_SERVICE_TIMERS_ID_PK primary key,
email varchar(100) constraint TIMER_SERVICE_TIMERS_EMAIL_FK foreign key references timer_service_users(email),
expiry datetime constraint TIMER_SERVICE_TIMERS_EXPIRY_NN not null,
constraint TIMER_SERVICE_TIMERS_EXPIRY_VALIDITY check(expiry > sysdatetime())
);
root
|___ index.html
|___ register.html
|___ Users
|___ index.jsp
|___ addTimer.html
source packages
|___ servlets
|___ Validate.java
|___ CheckTimer.java
|___ AddUser.java
|___ AddTimer.java
|___ Logout.java
|___ filter
|___ UserFilter.java |
-- 设备表,增加集团ID
ALTER TABLE MOTOR_DEVICE ADD COLUMN groupId bigint(20) not null default 0 after id;
-- 设备表,增加其他信息字段
alter table motor_device add column installPosition varchar(100) comment '安装位置' after inventoryOutId;
alter table motor_device add column installTime bigint(20) comment '装机日期' after installPosition;
alter table motor_device add column installAddress varchar(100) comment '装机地点' after installTime;
alter table motor_device add column previousMaintainTime bigint(20) comment '上次保养日期' after installAddress;
alter table motor_device add column nextMaintainTime bigint(20) comment '下次保养日期' after previousMaintainTime;
alter table motor_device add column driverName varchar(20) comment '司机姓名' after nextMaintainTime;
alter table motor_device add column driverMobile varchar(11) comment '司机手机号' after driverName;
alter table motor_device add column driverMobileShort varchar(11) comment '司机手机短号' after driverMobile;
alter table motor_device add column driverLicenseExpire bigint(20) comment '驾照到期' after driverMobileShort;
alter table motor_device add column vin varchar(20) comment '车架号' after driverLicenseExpire;
alter table motor_device add column sn varchar(20) comment 'SN号' after vin;
-- 用户表加邮箱和备注
alter table motor_user add column email varchar(50) comment '邮箱' after selectedDeviceId;
alter table motor_user add column remark varchar(50) comment '备注' after email;
-- 集团用户信息表
CREATE TABLE GROUP_USER_INFO (
id bigint(20) not null auto_increment comment '用户ID',
name varchar(30) not null comment '管理员登录名',
realName varchar(30) comment '真实姓名',
mobile varchar(11) comment '联系电话',
email varchar(30) comment '电子邮箱',
groupId bigint(20) not null default 0 comment '用户所属集团ID,管理员为0',
roleId bigint(20) not null default 0 comment '角色ID, 关联rbac_role表',
pwd varchar(50) not null comment '经sha1加密的密码',
salt varchar(32) not null default '' comment '加密salt',
status char(1) not null default '1' comment '状态,0:无效,1:有效',
createTime bigint(20) not null comment '创建时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='集团用户信息表';
-- 集团信息表
CREATE TABLE GROUP_INFO (
id bigint(20) not null auto_increment comment '集团ID',
name varchar(30) not null comment '集团名称',
fullName varchar(255) comment '全称',
address varchar(255) comment '地址',
lat varchar(10) default null comment '纬度',
lng varchar(10) default null comment '经度',
tel varchar(30) comment '联系电话',
fax varchar(30) comment '传真',
linkman varchar(30) comment '联系人姓名',
linkmanMobile varchar(11) comment '联系人手机号',
status char(1) not null default '1' comment '状态,0:无效,1:有效',
createTime bigint(20) not null comment '创建时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='集团信息表';
-- SIM卡充值记录表
CREATE TABLE SIM_CHARGE_RECORD (
id bigint(20) not null auto_increment comment '充值记录号',
simMobile varchar(15) not null comment 'SIM卡号',
chargeMoney int(4) not null default 0 comment '充值金额',
simExpire bigint(20) comment '充值后套餐到期时间',
createTime bigint(20) not null comment '创建时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SIM卡充值记录表';
-- 集团设备分组
CREATE TABLE DEVICE_GROUP (
id bigint(20) not null auto_increment comment '设备分组ID',
groupId bigint(20) not null default 0 comment '所属集团ID',
name varchar(30) not null comment '分组名称',
code varchar(100) not null comment '分组编码,00为根分组,子分组命名为:0001、000101、00010101',
parentId bigint(20) not null default 0 comment '父分组ID',
sortFactor int(11) not null default 0 comment '排序因子,大->小',
createTime bigint(20) not null comment '创建时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='集团设备分组';
-- 集团设备分组-设备对应关系
CREATE TABLE DEVICE_GROUP_RELATION (
id bigint(20) not null auto_increment comment '对应关系ID',
deviceGroupId bigint(20) not null comment '设备分组ID',
deviceId bigint(20) not null comment '设备ID',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='集团设备分组-设备对应关系';
-- 设备配置表
CREATE TABLE DEVICE_CONFIG (
id bigint(20) not null auto_increment comment '设备配置ID',
deviceId bigint(20) not null comment '设备ID',
redirectConnector char(1) not null default '0' comment '是否转向$host:$port,0否1是',
host varchar(15) comment 'connector主机IP',
port int(11) default 0 comment 'connector TCP服务端口',
simExpire bigint(20) not null default 0 comment 'SIM卡到期时间',
serviceExpire bigint(20) not null default 0 comment '服务到期时间',
micSensitivity int(4) comment 'micphone灵敏度',
reportGPS char(1) comment '0:保留;1:轨迹上报;2:轨迹不上报;3:轨迹上报,但设置位置隐藏标志;',
workMode char(1) comment '0:保留;1:省电工作模式;2:正常工作模式;其他:保留;备注:该参数只对CBB-100G电池版设备有作用,决定了该设备处于哪种工作模式;',
reportIntervalM int(4) comment '运动时GPS上报间隔,单位:秒',
reportIntervalS int(4) comment '静止时GPS上报间隔,单位:秒',
speedLimit int(4) comment '超速阀值,单位:km/h',
speedyDuration int(4) comment '超速持续多久报警,单位:秒',
alarmProcessFrom char(1) not null default '0' comment '报警处理方式,0:中心报警;1:设备报警',
alarmProcessCenter char(3) comment '报警时,中心处理方式,三个字符分别表示电话报警、短信报警和消息推送,如111表示电话+短信+消息推送,100表示仅电话报警',
alarmProcessDevice char(1) comment '报警时,设备处理方式,0:表示电话+短信;1:表示纯短信;2:表示纯电话;3:不报警;默认3',
phoneCallCenter int(4) comment '中心每月最大拔出电话数',
phoneCallDevice int(4) comment '设备每月最大拔出电话数',
smsCenter int(4) comment '中心每月最大发出短信数',
smsDevice int(4) comment '设备每月最大发出短信数',
efEnabled char(1) not null default '1' comment '是否启用设备的电子围栏功能,0否1是',
vehicleNumber varchar(10) comment '车牌号',
masterMobile varchar(11) comment '车主手机号(即报警通知手机号)',
g2ReportTime varchar(255) comment 'CBB100-G2特殊参数:上报时间,格式:HH24:MI,HH24:MI,HH24:MI,HH24:MI',
g2KeepOnline bigint(20) not null default 0 comment 'CBB100-G2特殊参数:保持在线直到此时刻',
updateTime bigint(20) comment '配置更新时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备配置表';
ALTER TABLE DEVICE_CONFIG ADD CONSTRAINT UNIQUE KEY UK_DEVICE(deviceId);
ALTER TABLE DEVICE_CONFIG ADD INDEX IDX_DEVICE(deviceId);
-- 电子围栏表
CREATE TABLE ELECTRONIC_FENCE (
id bigint(20) not null auto_increment comment '电子围栏ID',
groupId bigint(20) not null comment '集团ID',
name varchar(100) not null comment '电子围栏名称',
type char(1) not null default '0' comment '电子围栏类型,0:离开报警;1:进入报警;2:进入离开均报警',
address varchar(255) not null comment '中心点地址',
lat varchar(10) not null comment '中心点纬度',
lng varchar(10) not null comment '中心点经度',
radius int(11) not null default 1000 comment '半径,单位:米',
maxSpeed int(11) not null default 0 comment '最大速度,单位:Km/h,为0时表示不限速',
createTime bigint(20) not null comment '报警创建时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电子围栏表';
-- 电子围栏、设备关系表
CREATE TABLE ELECTRONIC_FENCE_DEVICES (
id bigint(20) not null auto_increment comment '数据ID',
efId bigint(20) not null comment '电子围栏ID',
deviceId bigint(20) not null comment '设备ID',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电子围栏、设备关系表';
ALTER TABLE ELECTRONIC_FENCE_DEVICES ADD INDEX IDX_EF(efId);
ALTER TABLE ELECTRONIC_FENCE_DEVICES ADD INDEX IDX_DEVICE(deviceId);
-- 设备报警记录表
CREATE TABLE DEVICE_ALARM (
id bigint(20) not null auto_increment comment '设备报警ID',
deviceId bigint(20) not null comment '设备ID',
alarm char(1) not null comment '报警编码,1-7依次为:非法位移报警(1)、断电报警(2)、震动报警(3)、超速报警(4)、开门报警(5)、进入电子围栏区域报警(6)、离开电子围栏区域报警(7)',
alarmType char(1) not null default '1' comment '报警类型,0解除报警,1报警',
efId bigint(20) not null default 0 comment '电子围栏ID,当alarm为6或7时有效',
lat varchar(10) not null default '0.00000' comment '报警点纬度',
lng varchar(10) not null default '0.000000' comment '报警点经度',
deviceTime bigint(20) comment '报警发生时间(设备时间)',
createTime bigint(20) not null comment '报警创建时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备报警记录表';
ALTER TABLE DEVICE_ALARM ADD INDEX IDX_DEVICE_TIME(deviceId, deviceTime);
-- 设备在线状态表
CREATE TABLE DEVICE_STATE (
deviceId bigint(20) not null comment '设备ID',
connectorId char(3) not null comment 'connector编号',
state char(1) not null comment '在线1,不在线0',
updateTime bigint(20) not null comment '最后一次更新状态的时间',
primary key (deviceId)
) engine=MEMORY DEFAULT CHARSET=utf8mb4 COMMENT='设备在线状态表';
ALTER TABLE DEVICE_STATE ADD INDEX IDX_ID(deviceId);
ALTER TABLE DEVICE_STATE ADD INDEX IDX_CONNECTOR(connectorId);
-- 设备在线状态表
CREATE TABLE DEVICE_STATISTICS (
id bigint(20) not null auto_increment comment '统计ID',
deviceId bigint(20) not null comment '设备ID',
date char(10) not null comment '统计数据的日期',
distance int(11) not null default 0 comment '当日里程,单位:百米',
time int(11) not null default 0 comment '当时行驶时间,单位:秒',
stop int(11) not null default 0 comment '当日停车次数',
alarmMovement int(11) not null default 0 comment '非法位移报警次数',
alarmPowerOff int(11) not null default 0 comment '断电报警次数',
alarmShock int(11) not null default 0 comment '震动报警次数',
alarmSpeedy int(11) not null default 0 comment '超速报警次数',
alarmDoorOpened int(11) not null default 0 comment '非法开门报警次数',
alarmEnterEF int(11) not null default 0 comment '进入电子围栏报警次数',
alarmLeaveEF int(11) not null default 0 comment '离开电子围栏报警次数',
statTime bigint(20) not null comment '统计时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备统计信息表';
ALTER TABLE DEVICE_STATISTICS ADD INDEX IDX_DEVICE_DATE(date, deviceId);
ALTER TABLE DEVICE_STATISTICS ADD CONSTRAINT UNIQUE UK_DEVICE_DATE(deviceId, date);
-- 设备消息日志表
CREATE TABLE DEVICE_MSG_LOG(
id bigint(20) not null auto_increment comment '日志ID',
deviceId bigint(20) not null comment '设备ID',
connectorId char(3) not null comment 'connector编号',
sessionId varchar(36) not null comment '会话ID',
cmd varchar(10) not null default '0x0000' comment '消息命令字,0x0000表示虚拟命令字disconnect',
hex varchar(400) comment '完整消息的HEX字符串',
logTime bigint(20) not null comment '日志记录时间,服务器时间',
primary key (id)
) engine=MYISAM DEFAULT CHARSET=utf8mb4 COMMENT='设备消息日志表';
ALTER TABLE DEVICE_MSG_LOG ADD INDEX IDX_DEVICE_TIME(deviceId, logTime);
-- 网上充值订单表
CREATE TABLE CHARGE_ORDER (
id bigint(20) not null auto_increment comment '充值订单ID',
orderNo varchar(24) not null comment '充值订单码, 2位支付平台编号+14位时间+8位随机数',
groupId bigint(20) not null comment '充值集团ID',
totalAmount int(11) not null default 0 comment '充值总金额,单位:分',
paymentPlatform int(4) not null comment '支付平台,1-5分别为:支付宝、中国工商银行、中国农业银行、中国银行 、中国建设银行',
paymentState char(1) not null default 0 comment '0:待确认;1:支付成功;2:支付失败;3:订单超时',
paymentPlatformArgs text comment '向支付平台发送的参数, JSON',
createTime bigint(20) not null comment '充值订单创建时间',
confirmTime bigint(20) not null default 0 comment '充值确认时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='网上充值订单表';
ALTER TABLE CHARGE_ORDER ADD CONSTRAINT UNIQUE KEY UK_ORDER_NO(orderNo);
-- 充值订单详细信息表
CREATE TABLE CHARGE_ORDER_DETAIL (
id bigint(20) not null auto_increment comment '数据ID',
chargeOrderId bigint(20) not null comment '充值订单ID',
deviceId bigint(20) not null comment '充入的设备ID',
amount int(11) not null default 0 comment '充值金额',
serviceExpireBefore bigint(20) not null default 0 comment '充值前服务到期时间',
serviceExpireAfter bigint(20) not null default 0 comment '充值后服务到期时间',
primary key (id)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='充值订单详细信息表';
-- 角色和权限数据
--用户所能操作的设备分组
CREATE TABLE `user_devicegroup` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`userId` bigint(20) NOT NULL COMMENT '用户ID',
`deviceGroupId` bigint(20) NOT NULL COMMENT '角色ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户绑定的设备分组表';
-- 服务器列表
CREATE TABLE SERVERS (
id bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
serverNo varchar(20) NOT NULL COMMENT '服务器编号',
ip varchar(15) NOT NULL COMMENT 'IP地址',
port int(11) NOT NULL COMMENT '端口',
fixed int(1) NOT NULL COMMENT '是否限制配置到此服务器的只能在此服务器登录',
name varchar(50) COMMENT '服务器名称',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='服务器列表';
ALTER TABLE SERVERS ADD CONSTRAINT UNIQUE KEY UK_NO(serverNo);
-- 设备服务器映射表
CREATE TABLE DEVICE_SERVER_MAPPING (
id bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
deviceId bigint(20) not null comment '设备ID',
serverId bigint(20) not null default 0 comment '服务器ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备服务器映射表';
ALTER TABLE DEVICE_SERVER_MAPPING ADD CONSTRAINT UNIQUE KEY UK_DEVICE_SERVER(deviceId, serverId); |
insert into sample.row (scratch)
select '1';
while (select count(1)from sample.row) < 500000
begin
insert into sample.row (scratch)
select '1'
from sample.row;
end; |
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Tempo de geração: 29/05/2019 às 13:40
-- Versão do servidor: 10.1.40-MariaDB
-- Versão do PHP: 7.3.5
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 */;
--
-- Banco de dados: `imperpizza`
--
-- --------------------------------------------------------
--
-- Estrutura para tabela `costumrInfo`
--
CREATE TABLE `costumrInfo` (
`client_id` int(4) NOT NULL,
`client_nome` tinytext,
`client_tele` tinytext,
`client_ende` varchar(255) DEFAULT NULL,
`client_email` varchar(60) DEFAULT NULL,
`client_cpf` tinytext
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura para tabela `funcInfo`
--
CREATE TABLE `funcInfo` (
`funci_id` int(4) NOT NULL,
`funci_nome` tinytext,
`funci_email` varchar(50) NOT NULL,
`funci_cpf` varchar(13) NOT NULL,
`funci_ctps` tinytext NOT NULL,
`funci_salb` decimal(4,2) NOT NULL,
`funci_sall` decimal(4,2) NOT NULL,
`funci_refe` tinyint(1) NOT NULL,
`funci_vt` tinyint(1) NOT NULL,
`funci_saud` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura para tabela `geralestoque`
--
CREATE TABLE `geralestoque` (
`ingredient_id` smallint(4) NOT NULL COMMENT 'Id Do Ingrediente',
`ingredient_nome` tinytext NOT NULL COMMENT 'Nome Do Ingrediente',
`ingredient_qtd` decimal(4,4) NOT NULL COMMENT 'Quantidade Em Kilo Do Ingrediente',
`ingredient_update` datetime NOT NULL COMMENT 'Atualização do Ingrediente Em Estoque'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura para tabela `geralpizza`
--
CREATE TABLE `geralpizza` (
`pizza_id` int(4) NOT NULL,
`pizza_nome` tinytext,
`pizza_desc` varchar(255) DEFAULT NULL,
`pizza_tipo` tinytext
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Despejando dados para a tabela `geralpizza`
--
INSERT INTO `geralpizza` (`pizza_id`, `pizza_nome`, `pizza_desc`, `pizza_tipo`) VALUES
(1, 'Calabresa', 'Linguiça Calabresa,Quijo Mussarela,Cebola', 'Salgada');
-- --------------------------------------------------------
--
-- Estrutura para tabela `motoInfo`
--
CREATE TABLE `motoInfo` (
`moto_id` int(4) NOT NULL,
`moto_nome` tinytext NOT NULL,
`moto_km` decimal(4,2) NOT NULL,
`moto_pay` decimal(4,2) NOT NULL,
`moto_disp` tinyint(1) NOT NULL DEFAULT '0',
`moto_cpf` varchar(13) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Índices de tabelas apagadas
--
--
-- Índices de tabela `costumrInfo`
--
ALTER TABLE `costumrInfo`
ADD PRIMARY KEY (`client_id`);
--
-- Índices de tabela `funcInfo`
--
ALTER TABLE `funcInfo`
ADD PRIMARY KEY (`funci_id`);
--
-- Índices de tabela `geralestoque`
--
ALTER TABLE `geralestoque`
ADD PRIMARY KEY (`ingredient_id`);
--
-- Índices de tabela `geralpizza`
--
ALTER TABLE `geralpizza`
ADD PRIMARY KEY (`pizza_id`);
--
-- Índices de tabela `motoInfo`
--
ALTER TABLE `motoInfo`
ADD PRIMARY KEY (`moto_id`);
--
-- AUTO_INCREMENT de tabelas apagadas
--
--
-- AUTO_INCREMENT de tabela `costumrInfo`
--
ALTER TABLE `costumrInfo`
MODIFY `client_id` int(4) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de tabela `funcInfo`
--
ALTER TABLE `funcInfo`
MODIFY `funci_id` int(4) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de tabela `geralestoque`
--
ALTER TABLE `geralestoque`
MODIFY `ingredient_id` smallint(4) NOT NULL AUTO_INCREMENT COMMENT 'Id Do Ingrediente', AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT de tabela `geralpizza`
--
ALTER TABLE `geralpizza`
MODIFY `pizza_id` int(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT de tabela `motoInfo`
--
ALTER TABLE `motoInfo`
MODIFY `moto_id` int(4) NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
-- Queries on Policy Configurations
-- Most of these should be working, but some may still be a work in progress.
-- These are formatted for readability, just fyi.
-- ##################################################
-- Basic Queries
-- Get Policies that Execute @ Ongoing
select policy_id
from policies
where
execution_frequency like "Ongoing";
-- Policies with no Scope
select distinct policies.policy_id, policies.name
from policies
where policies.policy_id not in (
select policy_id from policy_deployment
);
-- Policies that are Disabled
select distinct policies.policy_id, policies.name
from policies
where policies.enabled != "1";
-- Policies with no Category and not created by Jamf Remote
select distinct policies.policy_id, policies.name, policies.use_for_self_service
from policies
where
policies.category_id = "-1"
and policies.created_by = "jss";
-- Policies Scoped to All Users
select distinct policies.policy_id, policies.name
from policies
join policy_deployment
on policy_deployment.policy_id = policies.policy_id
join site_objects
on site_objects.object_id = policies.policy_id
join sites
on sites.site_id = site_objects.site_id
where
policy_deployment.target_type = "106";
-- For every Policy ID, get its Site Name
select policies.policy_id, if(sites.site_name is null, "none", sites.site_name) as Site
from policies
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id;
-- ##################################################
-- Self Service Policies
-- Get Policies are report if they are set for Self Service and if have a Description and Icon and include it's Site
select policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, if(policies.use_for_self_service = "1", "Yes", "No") as "Self Service", if(policies.self_service_description = "", "No", "Yes") as "Has Description", if(policies.self_service_icon_id = "-1", "No", "Yes") as "Has Icon",
from policies
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id;
-- Get Self Service Policies that install a Package (Also get each Package ID and Name)
select policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, policy_packages.package_id as "Package ID" , packages.package_name as "Package Name"
from policies
join policy_packages
on policy_packages.policy_id = policies.policy_id
join packages
on policy_packages.package_id = packages.package_id
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
where
policies.use_for_self_service = 1;
-- ##################################################
-- Policies ran over time period
-- Get Policies that ran within the last 24 hours, get and order by count
select policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, count(*)
from policies
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
join policy_history
on policy_history.policy_id = policies.policy_id
where
policy_history.completed_epoch>unix_timestamp(date_sub(now(), interval 1 day))*1000
group by policy_history.policy_id, sites.site_name
order by Count(*) desc;
-- Get Policies that submitted Inventory within the last 24 hours, get and order by count
select policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, count(*)
from policies
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
join policy_history
on policy_history.policy_id = policies.policy_id
where
policy_history.completed_epoch>unix_timestamp(date_sub(now(), interval 1 day))*1000
and policies.update_inventory = 1
group by policy_history.policy_id, sites.site_name
order by Count(*) desc;
-- Get Policies that have ran witin the last 24 hours, if they perform inventory, have errors, and their Site, and group/count the occurences
select policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, if(policies.update_inventory = "1", "Yes", "No") as "Update Inventory?", logs.error as "Errors", count(*)
from policies
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
join policy_history
on policy_history.policy_id = policies.policy_id
join logs
on logs.log_id = policy_history.log_id
where
policy_history.completed_epoch > unix_timestamp(date_sub(now(), INTERVAL 1 DAY))*1000
group by policies.policy_id, sites.site_name, logs.error
order by count(*) desc;
-- ##################################################
-- Mash up of other queries
-- Get various Policies details of interest, including if they perform inventory, have errors, and their Site, and group/count the occurences
select count(*), policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, if(policies.enabled = "1", "Yes", "No") as "Enabled", if(policies.update_inventory = "1", "Yes", "No") as "Update Inventory?", logs.error as "Errors", if(policies.use_for_self_service = "1", "Yes", "No") as "Self Service", if(policies.self_service_description = "", "No", "Yes") as "Has Description", if(policies.self_service_icon_id = "-1", "No", "Yes") as "Has Icon", if(policies.category_id = "-1" and policies.created_by = "jss", "No", "Yes") as "Has Category", if( policies.policy_id not in ( select policy_id from policy_deployment ), "False", "True") as "Has Scope"
from policies
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
join policy_history
on policy_history.policy_id = policies.policy_id
join logs
on logs.log_id = policy_history.log_id
group by policies.policy_id, sites.site_name, logs.error
order by count(*) desc
-- ##################################################
-- Policies that are configured for Ongoing with any "reoccuring" trigger and installs a Package
-- Get Policies that are configured for Ongoing with any "reoccuring" trigger and installs a Package (Also get each Package ID and Name)
select distinct policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, packages.package_id as "Package ID" , packages.package_name as "Package Name"
from policies
join policy_packages
on policy_packages.policy_id = policies.policy_id
join packages
on policy_packages.package_id = packages.package_id
join policy_deployment
on policy_deployment.policy_id = policies.policy_id
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
where
policies.execution_frequency = "Ongoing"
and (
policies.trigger_event_startup = "1"
or policies.trigger_event_login = "1"
or policies.trigger_event_logout = "1"
or policies.trigger_event_network_state_change = "1"
or policies.trigger_event_checkin = "1"
);
-- Get Policies that are configured for Ongoing with any "reoccuring" trigger and installs a Package which has a Scope that is not a Smart Group (Also get each Package ID and Name)
-- Need to add if scoped to Computer IDs directly
-- This query needs verification
select distinct policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, packages.package_id as "Package ID" , packages.package_name as "Package Name", computer_groups.computer_group_id as "Group ID", computer_groups.computer_group_name as "Group Name"
from policies
join policy_packages
on policy_packages.policy_id = policies.policy_id
join packages
on policy_packages.package_id = packages.package_id
join policy_deployment
on policy_deployment.policy_id = policies.policy_id
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
left join computer_groups
on computer_groups.computer_group_id = policy_deployment.target_id
left join smart_computer_group_criteria
on smart_computer_group_criteria.computer_group_id = computer_groups.computer_group_id
where
policies.execution_frequency = "Ongoing"
and (
policies.trigger_event_startup = "1"
or policies.trigger_event_login = "1"
or policies.trigger_event_logout = "1"
or policies.trigger_event_network_state_change = "1"
or policies.trigger_event_checkin = "1"
)
and (
policy_deployment.target_type = "101"
or policy_deployment.target_type = "7"
and policy_deployment.target_id in (
select computer_group_id
from computer_groups
where computer_groups.is_smart_group != 1
)
);
-- ##################################################
-- Enrollment Policies that install Packages
-- Enrollment Policies installing Packages that are Scoped to All Computers
select distinct policy_packages.policy_id, policies.name, policy_packages.package_id, packages.package_name, sites.site_name
from policies
join policy_packages on policy_packages.policy_id = policies.policy_id
join packages on policy_packages.package_id = packages.package_id
join policy_deployment on policy_deployment.policy_id = policies.policy_id
join site_objects on site_objects.object_id = policies.policy_id
join sites on sites.site_id = site_objects.site_id
where policies.trigger_event_enrollment_complete = "1"
and (
policies.policy_id = policy_deployment.policy_id
and policy_deployment.target_type = "101"
)
and (
policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
);
-- Get Policies that are configured for Enrollment and installs a Package which has a Scope Smart Group that is Not ADE Enrolled Machines
select distinct policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, computer_groups.computer_group_id as "Group ID", computer_groups.computer_group_name as "Group Name"
from policies
join policy_deployment
on policy_deployment.policy_id = policies.policy_id
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
join computer_groups
on computer_groups.computer_group_id = policy_deployment.target_id
join smart_computer_group_criteria
on smart_computer_group_criteria.computer_group_id = computer_groups.computer_group_id
where
policies.trigger_event_enrollment_complete = "1"
AND (
policy_deployment.target_type = "7"
AND policy_deployment.target_id IN (
SELECT computer_group_id
FROM computer_groups
WHERE computer_groups.is_smart_group = 1
)
AND policy_deployment.target_id IN
(
SELECT computer_group_id
FROM smart_computer_group_criteria
WHERE search_field != "Enrollment Method: PreStage enrollment"
)
);
-- Get Policies that are configured for Enrollment and installs a Package which has a Scope Smart Group that is ADE Enrolled Machines
select distinct policies.policy_id as "Policy ID", policies.name as "Policy Name", if(sites.site_name is null, "none", sites.site_name) as Site, computer_groups.computer_group_id as "Group ID", computer_groups.computer_group_name as "Group Name"
from policies
join policy_deployment
on policy_deployment.policy_id = policies.policy_id
left join site_objects
on policies.policy_id = site_objects.object_id
and site_objects.object_type = "3"
left join sites
on sites.site_id = site_objects.site_id
join computer_groups
on computer_groups.computer_group_id = policy_deployment.target_id
join smart_computer_group_criteria
on smart_computer_group_criteria.computer_group_id = computer_groups.computer_group_id
where
policies.trigger_event_enrollment_complete = "1"
AND (
policy_deployment.target_type = "7"
AND policy_deployment.target_id IN (
SELECT computer_group_id
FROM computer_groups
WHERE computer_groups.is_smart_group = 1
)
AND policy_deployment.target_id IN
(
SELECT computer_group_id
FROM smart_computer_group_criteria
WHERE search_field = "Enrollment Method: PreStage enrollment"
)
);
|
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 1);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 2);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 3);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 4);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 5);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 6);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 7);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 8);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 9);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 12);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 13);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 14);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 15);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 16);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 17);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (2, 1);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 18);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 19);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 20);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 21);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 22);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 23);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 24);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 25);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 26);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 27);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 28);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 29);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 30);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 31);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 32);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 33);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 34);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 35);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 36);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 37);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 38);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 39);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 40);
INSERT INTO laravel_ecomerce.permission_role (role_id, permission_id) VALUES (1, 41);
|
-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 30-06-2020 a las 06:03:03
-- Versión del servidor: 10.4.6-MariaDB
-- Versión de PHP: 7.1.31
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: `your_rent`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `properties`
--
CREATE TABLE `properties` (
`id_property` int(11) NOT NULL,
`title` varchar(40) NOT NULL,
`type` varchar(40) NOT NULL,
`addresses` varchar(50) NOT NULL,
`rooms` varchar(20) NOT NULL,
`price` varchar(40) NOT NULL,
`area` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcado de datos para la tabla `properties`
--
INSERT INTO `properties` (`id_property`, `title`, `type`, `addresses`, `rooms`, `price`, `area`) VALUES
(1, 'Casa en la quinta porra', 'house', 'cra 80 # 12-12', '7', '200000', '250'),
(3, 'Apartamento en Reservas del Sur', 'house', 'cra 58 # 77-41', '3', '100000', '123'),
(4, 'Habitación en Medellin', 'room', 'Cra 5 Num 18-48', '1', '250000', '12');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
`lastname` varchar(20) NOT NULL,
`email` varchar(50) NOT NULL,
`type_id` varchar(20) NOT NULL,
`identification` varchar(20) NOT NULL,
`password` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcado de datos para la tabla `users`
--
INSERT INTO `users` (`id`, `name`, `lastname`, `email`, `type_id`, `identification`, `password`) VALUES
(77, 'Yuly', 'Perez', 'yuly@hotmail.com', 'CC', '123457665', 'alejandro$$'),
(78, 'Pedro', 'Arbelaez', 'pearbe@hotmail.com', 'PAS', '123457665', '%alejandro$'),
(79, 'Pedro', 'Arbelaez', 'pearbe@hotmail.com', 'PAS', '', '%alejandro$'),
(80, 'Paola', 'Zuluaga', 'paola@hotmail.com', 'CC', '1036658665555461', '123456#$'),
(81, 'Sergio', 'Muñoz', 'sergio@gmail.com', 'CC', '108835454647', 'sergio%&'),
(82, 'Juan Camilo', 'Quiroz Aristizabal', 'jucaqui@gmail.com', 'CC', '108836464649', 'juanca&&'),
(83, 'Carlos Alberto', 'Rios Olmos', 'calrio@gmail.com', 'CC', '1054323445678', 'carlos%&');
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `properties`
--
ALTER TABLE `properties`
ADD PRIMARY KEY (`id_property`);
--
-- Indices de la tabla `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `properties`
--
ALTER TABLE `properties`
MODIFY `id_property` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT de la tabla `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=84;
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 */;
|
--Criando banco de dados
create database Filmes;
--Acessando banco de dado
use Filmes;
create table Generos
(
idGeneros int primary key identity,
Nome varchar(200) not null
);
create table Filmes
(
idFilme int primary key identity,
Nome varchar(255)not null,
Sinopse varchar(255),
idGeneros int foreign key references Generos(idGeneros)
);
-- Comando DML - Linguagem de manipulação de dados
-- insert, alter , delete e upgrade
-- inser é utilizado para inserir dados em uma tabela
insert into Generos(Nome) values ('Ação')
insert into Generos(Nome) values ('Ficção')
insert into Generos(Nome) values ('Aventura')
insert into Generos(Nome) values ('Comédia')
insert into Generos(Nome) values ('Fantasia')
-- Deletar registro de uma tabela
delete from Generos where idGeneros > 0;
delete from Filmes where idFilme > 0;
-- Atulizar dados de uma tabela
update Generos set Nome = 'Comédia/Drama' where idGeneros = 50;
-- resete identity
DBCC ckeckident('[Filmes]', reseed, 0);
-- Selecionar dados de uma tabela
select idGeneros, nome from Generos;
select * from Generos;
-- Cadastrando filmes
insert into Filmes (Nome, Sinopse , idGeneros , duracao) values
('Alice','Conto infantil', 21, '120 min'),
('Transformers','filme mentiroso', 22, '120 min'),
('kung fu','filme de luta', 23, '120 min'),
('Lucas','Conto animado', 24, '120 min');
select * from Filmes;
--alterando tabelas
alter table Filmes add duracao varchar(255);
-- Inserir a duração
update Filmes set duracao = '120 min' where idFilme = 5;
--Juntando dados de duas tabelas (inner Join)
select Filmes.Nome , Filmes.Sinopse , Generos.Nome as Genero, Filmes.duracao from Filmes -- Tabela 1
inner join Generos -- Tabela 2
on Filmes.idGeneros = Generos.idGeneros;
-- Usando Alias
select f.Nome , f.Sinopse , g.Nome as Genero, f.duracao from Filmes as f -- Tabela 1
inner join Generos as g-- Tabela 2
on f.idGeneros = g.idGeneros; |
-- MySQL Script generated by MySQL Workbench
-- Fri Nov 6 21:33:10 2020
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema reddut
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema reddut
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `reddut` DEFAULT CHARACTER SET utf8 ;
USE `reddut` ;
-- -----------------------------------------------------
-- Table `reddut`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `reddut`.`user` (
`id` VARCHAR(100) NOT NULL,
`username` VARCHAR(45) NOT NULL,
`email` VARCHAR(250) NOT NULL,
`password` VARCHAR(255) NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `iduser_UNIQUE` (`id` ASC) VISIBLE,
UNIQUE INDEX `username_UNIQUE` (`username` ASC) VISIBLE,
UNIQUE INDEX `email_UNIQUE` (`email` ASC) VISIBLE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `reddut`.`subreddut`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `reddut`.`subreddut` (
`id` VARCHAR(100) NOT NULL,
`key` VARCHAR(25) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
UNIQUE INDEX `key_UNIQUE` (`key` ASC) VISIBLE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `reddut`.`post`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `reddut`.`post` (
`id` VARCHAR(100) NOT NULL,
`title` VARCHAR(300) NOT NULL,
`content` TEXT NOT NULL,
`user_id` VARCHAR(100) NOT NULL,
`sub_reddut_id` VARCHAR(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
INDEX `fk_post_user_idx` (`user_id` ASC) VISIBLE,
INDEX `fk_post_sub_reddut1_idx` (`sub_reddut_id` ASC) VISIBLE,
CONSTRAINT `fk_post_user`
FOREIGN KEY (`user_id`)
REFERENCES `reddut`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_post_sub_reddut1`
FOREIGN KEY (`sub_reddut_id`)
REFERENCES `reddut`.`subreddut` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `reddut`.`comment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `reddut`.`comment` (
`id` VARCHAR(100) NOT NULL,
`content` TEXT NOT NULL,
`upvotes` INT NOT NULL,
`downvotes` INT NOT NULL,
`post_id` VARCHAR(100) NOT NULL,
UNIQUE INDEX `idcomment_UNIQUE` (`id` ASC) VISIBLE,
PRIMARY KEY (`id`),
INDEX `fk_comment_post1_idx` (`post_id` ASC) VISIBLE,
CONSTRAINT `fk_comment_post1`
FOREIGN KEY (`post_id`)
REFERENCES `reddut`.`post` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `reddut`.`member`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `reddut`.`member` (
`sub_reddut_id` VARCHAR(100) NOT NULL,
`user_id` VARCHAR(100) NOT NULL,
INDEX `fk_member_user1_idx` (`user_id` ASC) VISIBLE,
PRIMARY KEY (`sub_reddut_id`, `user_id`),
CONSTRAINT `fk_member_sub_reddut1`
FOREIGN KEY (`sub_reddut_id`)
REFERENCES `reddut`.`subreddut` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_member_user1`
FOREIGN KEY (`user_id`)
REFERENCES `reddut`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version 5.6.22-enterprise-commercial-advanced-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
--
-- Create schema secure
--
CREATE DATABASE IF NOT EXISTS secure;
USE secure;
--
-- Definition of table `application_name`
--
DROP TABLE IF EXISTS `application_name`;
CREATE TABLE `application_name` (
`idapplicationname` int(10) unsigned NOT NULL,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`idapplicationname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `application_name`
--
/*!40000 ALTER TABLE `application_name` DISABLE KEYS */;
INSERT INTO `application_name` (`idapplicationname`,`name`) VALUES
(2,'Community_Collaborator'),
(3,'Community_Release');
/*!40000 ALTER TABLE `application_name` ENABLE KEYS */;
--
-- Definition of table `domain`
--
DROP TABLE IF EXISTS `domain`;
CREATE TABLE `domain` (
`iddomain` int(10) unsigned NOT NULL,
`name` varchar(300) NOT NULL,
`url` varchar(350) DEFAULT NULL,
PRIMARY KEY (`iddomain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `domain`
--
/*!40000 ALTER TABLE `domain` DISABLE KEYS */;
/*!40000 ALTER TABLE `domain` ENABLE KEYS */;
--
-- Definition of table `key_temp`
--
DROP TABLE IF EXISTS `key_temp`;
CREATE TABLE `key_temp` (
`idlogin` int(10) unsigned NOT NULL AUTO_INCREMENT,
`key` varchar(255) NOT NULL,
`datecreate` datetime NOT NULL,
PRIMARY KEY (`idlogin`),
CONSTRAINT `FK_key_temp_vs_login` FOREIGN KEY (`idlogin`) REFERENCES `login` (`idlogin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `key_temp`
--
/*!40000 ALTER TABLE `key_temp` DISABLE KEYS */;
/*!40000 ALTER TABLE `key_temp` ENABLE KEYS */;
--
-- Definition of table `language`
--
DROP TABLE IF EXISTS `language`;
CREATE TABLE `language` (
`idlanguage` int(10) unsigned NOT NULL AUTO_INCREMENT,
`culture` char(2) NOT NULL,
PRIMARY KEY (`idlanguage`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `language`
--
/*!40000 ALTER TABLE `language` DISABLE KEYS */;
INSERT INTO `language` (`idlanguage`,`culture`) VALUES
(1,'pt');
/*!40000 ALTER TABLE `language` ENABLE KEYS */;
--
-- Definition of table `log`
--
DROP TABLE IF EXISTS `log`;
CREATE TABLE `log` (
`idlogin` int(10) unsigned NOT NULL AUTO_INCREMENT,
`context` varchar(500) NOT NULL,
`datelog` datetime NOT NULL,
PRIMARY KEY (`idlogin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `log`
--
/*!40000 ALTER TABLE `log` DISABLE KEYS */;
/*!40000 ALTER TABLE `log` ENABLE KEYS */;
--
-- Definition of table `login`
--
DROP TABLE IF EXISTS `login`;
CREATE TABLE `login` (
`idlogin` int(10) unsigned NOT NULL AUTO_INCREMENT,
`password` varchar(25) NOT NULL,
`datecreate` datetime NOT NULL,
`status` int(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`idlogin`)
) ENGINE=InnoDB AUTO_INCREMENT=140 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `login`
--
/*!40000 ALTER TABLE `login` DISABLE KEYS */;
/*!40000 ALTER TABLE `login` ENABLE KEYS */;
--
-- Definition of table `login_phrase`
--
DROP TABLE IF EXISTS `login_phrase`;
CREATE TABLE `login_phrase` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`context` varchar(185) NOT NULL,
`idlanguage` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_login_phrase_vs_language` (`idlanguage`),
CONSTRAINT `FK_login_phrase_vs_language` FOREIGN KEY (`idlanguage`) REFERENCES `language` (`idlanguage`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `login_phrase`
--
/*!40000 ALTER TABLE `login_phrase` DISABLE KEYS */;
INSERT INTO `login_phrase` (`id`,`context`,`idlanguage`) VALUES
(1,'Concedendo Tecnologia!',1),
(2,'O mundo em segundos...!!',1),
(3,'Facilitando o aprendizado!',1);
/*!40000 ALTER TABLE `login_phrase` ENABLE KEYS */;
--
-- Definition of table `mail_message`
--
DROP TABLE IF EXISTS `mail_message`;
CREATE TABLE `mail_message` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`body` text NOT NULL,
`to` varchar(45) NOT NULL,
`from` varchar(45) NOT NULL,
`co` varchar(45) DEFAULT NULL,
`cc` varchar(45) DEFAULT NULL,
`subject` varchar(300) NOT NULL,
`ticket` varchar(10) NOT NULL,
`datefail` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `mail_message`
--
/*!40000 ALTER TABLE `mail_message` DISABLE KEYS */;
/*!40000 ALTER TABLE `mail_message` ENABLE KEYS */;
--
-- Definition of table `permission`
--
DROP TABLE IF EXISTS `permission`;
CREATE TABLE `permission` (
`idpermission` int(10) unsigned NOT NULL AUTO_INCREMENT,
`nickname` varchar(45) NOT NULL,
`status` int(1) unsigned NOT NULL,
PRIMARY KEY (`idpermission`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `permission`
--
/*!40000 ALTER TABLE `permission` DISABLE KEYS */;
INSERT INTO `permission` (`idpermission`,`nickname`,`status`) VALUES
(1,'Administrator',1),
(2,'basic',1),
(3,'secretary',1);
/*!40000 ALTER TABLE `permission` ENABLE KEYS */;
--
-- Definition of table `rel_domain_user`
--
DROP TABLE IF EXISTS `rel_domain_user`;
CREATE TABLE `rel_domain_user` (
`idreldomainuser` int(10) unsigned NOT NULL AUTO_INCREMENT,
`iddomain` int(10) unsigned NOT NULL,
`iduser` int(10) unsigned NOT NULL,
PRIMARY KEY (`idreldomainuser`) USING BTREE,
KEY `FK_rel_domain_user_vs_user` (`iduser`),
KEY `FK_rel_domain_user_vs_domain` (`iddomain`),
CONSTRAINT `FK_rel_domain_user_vs_domain` FOREIGN KEY (`iddomain`) REFERENCES `domain` (`iddomain`),
CONSTRAINT `FK_rel_domain_user_vs_user` FOREIGN KEY (`iduser`) REFERENCES `user` (`iduser`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `rel_domain_user`
--
/*!40000 ALTER TABLE `rel_domain_user` DISABLE KEYS */;
/*!40000 ALTER TABLE `rel_domain_user` ENABLE KEYS */;
--
-- Definition of table `rel_login_history`
--
DROP TABLE IF EXISTS `rel_login_history`;
CREATE TABLE `rel_login_history` (
`idhistory` int(10) unsigned NOT NULL AUTO_INCREMENT,
`idlogin` int(10) unsigned NOT NULL,
`iduser` int(10) unsigned NOT NULL,
`datemodify` datetime NOT NULL,
PRIMARY KEY (`idhistory`),
KEY `FK_rel_login_history_vs_user` (`iduser`),
CONSTRAINT `FK_rel_login_history_vs_user` FOREIGN KEY (`iduser`) REFERENCES `user` (`iduser`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `rel_login_history`
--
/*!40000 ALTER TABLE `rel_login_history` DISABLE KEYS */;
/*!40000 ALTER TABLE `rel_login_history` ENABLE KEYS */;
--
-- Definition of table `rel_login_recovery`
--
DROP TABLE IF EXISTS `rel_login_recovery`;
CREATE TABLE `rel_login_recovery` (
`idloginrecovery` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ticket` varchar(45) NOT NULL,
`iduser` int(10) unsigned NOT NULL,
`datesolicitation` datetime NOT NULL,
PRIMARY KEY (`idloginrecovery`) USING BTREE,
KEY `FK_rel_mail_recovery_vs_user` (`iduser`),
CONSTRAINT `FK_rel_mail_recovery_vs_user` FOREIGN KEY (`iduser`) REFERENCES `user` (`iduser`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `rel_login_recovery`
--
/*!40000 ALTER TABLE `rel_login_recovery` DISABLE KEYS */;
/*!40000 ALTER TABLE `rel_login_recovery` ENABLE KEYS */;
--
-- Definition of table `rel_permission_user`
--
DROP TABLE IF EXISTS `rel_permission_user`;
CREATE TABLE `rel_permission_user` (
`idreluserpermission` int(10) unsigned NOT NULL AUTO_INCREMENT,
`idpermission` int(10) unsigned NOT NULL,
`iduser` int(10) unsigned NOT NULL,
PRIMARY KEY (`idreluserpermission`),
KEY `FK_rel_permission_user_vs_user` (`iduser`),
KEY `FK_rel_permission_user_vs_permission` (`idpermission`),
CONSTRAINT `FK_rel_permission_user_vs_permission` FOREIGN KEY (`idpermission`) REFERENCES `permission` (`idpermission`),
CONSTRAINT `FK_rel_permission_user_vs_user` FOREIGN KEY (`iduser`) REFERENCES `user` (`iduser`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `rel_permission_user`
--
/*!40000 ALTER TABLE `rel_permission_user` DISABLE KEYS */;
/*!40000 ALTER TABLE `rel_permission_user` ENABLE KEYS */;
--
-- Definition of table `rel_user_login`
--
DROP TABLE IF EXISTS `rel_user_login`;
CREATE TABLE `rel_user_login` (
`iduser` int(10) unsigned NOT NULL,
`idlogin` int(10) unsigned DEFAULT NULL,
`ticket` varchar(45) DEFAULT NULL,
PRIMARY KEY (`iduser`) USING BTREE,
KEY `FK_rel_user_login_vs_login` (`idlogin`),
CONSTRAINT `FK_rel_user_login_vs_login` FOREIGN KEY (`idlogin`) REFERENCES `login` (`idlogin`),
CONSTRAINT `FK_rel_user_login_vs_user` FOREIGN KEY (`iduser`) REFERENCES `user` (`iduser`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `rel_user_login`
--
/*!40000 ALTER TABLE `rel_user_login` DISABLE KEYS */;
/*!40000 ALTER TABLE `rel_user_login` ENABLE KEYS */;
--
-- Definition of table `user`
--
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`iduser` int(10) unsigned NOT NULL AUTO_INCREMENT,
`mail` varchar(45) NOT NULL,
`name` varchar(45) NOT NULL,
`status` int(1) unsigned DEFAULT NULL,
PRIMARY KEY (`iduser`,`mail`) USING BTREE,
UNIQUE KEY `iduser_UNIQUE` (`iduser`),
UNIQUE KEY `mail_UNIQUE` (`mail`)
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `user`
--
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
--
-- Definition of trigger `trg_insert_user_ticket`
--
DROP TRIGGER /*!50030 IF EXISTS */ `trg_insert_user_ticket`;
DELIMITER $$
CREATE DEFINER = `root`@`localhost` TRIGGER `trg_insert_user_ticket` AFTER INSERT ON `user` FOR EACH ROW BEGIN
call proc_adm_user_ticket(NEW.iduser);
END $$
DELIMITER ;
--
-- Definition of function `fun_new_ticket`
--
DROP FUNCTION IF EXISTS `fun_new_ticket`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` FUNCTION `fun_new_ticket`() RETURNS varchar(10) CHARSET utf8
BEGIN
DECLARE code VARCHAR(10) ;
SET code = (select concat('GT',REPLACE(RIGHT(NOW(),5),':',''),left(upper( convert( md5( rand() ) using utf8 )),4)));
RETURN code;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_access_login`
--
DROP PROCEDURE IF EXISTS `proc_adm_access_login`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_access_login`(
in ilogin varchar(45),
in ipassword varchar(45),
in iip varchar(45)
)
BEGIN
declare iiduser int;
declare oireturn int;
BEGIN
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION set oireturn = @@error_count;
set iiduser = (select c.iduser from rel_user_login b
inner join user c on(c.iduser = b.iduser)
inner join login a on(a.idlogin = b.idlogin)
where a.password = ipassword
and c.mail = ilogin
and a.status = 1
limit 1);
if iiduser > 0 then
SELECT
a.iduser,
a.mail as login,
a.name,
b.ticket,
CONCAT(e.idpermission, '|', e.nickname,'|', IFNULL(g.name,'...') ,'|', g.iddomain) as permission_nick
FROM secure.user a
INNER JOIN secure.rel_user_login b on(b.iduser = a.iduser)
INNER JOIN secure.login c on(c.idlogin = b.idlogin)
INNER JOIN secure.rel_permission_user d on(d.iduser = a.iduser)
INNER JOIN secure.permission e on(e.idpermission = d.idpermission)
INNER JOIN secure.rel_domain_user f on(f.iduser = a.iduser)
INNER JOIN secure.domain g on(g.iddomain = f.iddomain)
WHERE a.iduser = iiduser ;
End if;
insert into secure.log ( context, datelog )
values (
CONCAT('login: ', ilogin, ' senha:', ipassword, ' ip:', iip ),
now()
);
SET oireturn = -1;
END;
END;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_confirm_mail_send`
--
DROP PROCEDURE IF EXISTS `proc_adm_confirm_mail_send`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_confirm_mail_send`(
in iemail varchar(255))
BEGIN
if exists (select 1 from secure.mail_message where `to` = iemail) then
delete from secure.mail_message where `to` = iemail;
select '0';
End if;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_del_user`
--
DROP PROCEDURE IF EXISTS `proc_adm_del_user`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_del_user`( in iiduser int, out oiretorno int)
BEGIN
declare iidlogin int;
START TRANSACTION;
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION set oiretorno = @@error_count;
delete from secure.rel_permission_user where iduser = iiduser;
delete from secure.rel_user_login where iduser = iiduser;
set iidlogin = (select idlogin from rel_user_login where iduser = iiduser );
delete from secure.login where idlogin = iidlogin;
delete from secure.user where iduser = iiduser;
END;
IF ( oiretorno <> 0 ) then
ROLLBACK;
ELSE
COMMIT;
END IF;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_ins_mail_send`
--
DROP PROCEDURE IF EXISTS `proc_adm_ins_mail_send`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_ins_mail_send`(
in ibody text,
in ito varchar(255),
in ifrom varchar(255),
in ico varchar(255),
in icc varchar(255),
in isubject varchar(300),
in iticket varchar(20)
)
BEGIN
DECLARE ioretorno int;
SET ioretorno = -1;
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION set ioretorno = @@error_count;
if not exists( select 1 from mail_message where ticket = iticket ) then
if exists( select 1 from rel_user_login where ticket = iticket ) then
insert into secure.mail_message (
body,
`to`,
`from`,
co,
cc,
`subject`,
ticket,
datefail )
values (
ibody,
ito,
ifrom,
ico,
icc,
isubject,
iticket,
now()
);
SET ioretorno = 0;
End if;
End if;
End;
select ioretorno;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_login_status`
--
DROP PROCEDURE IF EXISTS `proc_adm_login_status`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_login_status`(
in iidlogin int,
in istatus int)
BEGIN
update login set status = istatus, datecreate = now() where idlogin = iidlogin;
select
idlogin,
'#' as password,
datecreate,
status
from login where idlogin = iidlogin;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_recovery_login`
--
DROP PROCEDURE IF EXISTS `proc_adm_recovery_login`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_recovery_login`(
in ilogin varchar(45)
)
BEGIN
declare idrel int;
declare idrecovery int;
declare vticket varchar(45);
set idrel = (select iduser from `user` where mail = ilogin limit 1);
if idrel > 0 then
SET vticket = CONCAT('R', fun_new_ticket());
if exists(select 1 from rel_login_recovery where iduser = idrel) then
delete from rel_login_recovery where iduser = idrel;
End if;
insert into rel_login_recovery (ticket,iduser,datesolicitation)
values (vticket,idrel,now());
select
a.iduser,
a.mail,
a.name,
b.idloginrecovery,
b.ticket
from `user` a
inner join rel_login_recovery b on(b.iduser = a.iduser)
where a.iduser = idrel
order by b.idloginrecovery desc;
End if;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_redir_domain`
--
DROP PROCEDURE IF EXISTS `proc_adm_redir_domain`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_redir_domain`(
in iduser int,
in iticket varchar(45)
)
BEGIN
IF EXISTS(select 1 from rel_user_login) THEN
select * from rel_user_login;
END IF;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_user_disable`
--
DROP PROCEDURE IF EXISTS `proc_adm_user_disable`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_user_disable`(in iiduser int, out oiretorn int)
BEGIN
set oiretorn = -1;
START TRANSACTION;
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION set oiretorn = @@error_count;
update secure.user set status = 0 where iduser = iiduser;
update secure.login set status = 0 where idlogin in(
select idlogin from secure.rel_user_login where iduser = iiduser
);
delete from secure.rel_user_login where iduser = iiduser;
set oiretorn = 0;
END;
IF ( oiretorn <> 0 ) then
ROLLBACK;
ELSE
COMMIT;
END IF;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_user_domain`
--
DROP PROCEDURE IF EXISTS `proc_adm_user_domain`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_user_domain`(in iiddomain int)
BEGIN
if ( iiddomain = 0 ) then
select
a.iddomain,
a.name as domain,
a.url
from domain a
inner join rel_domain_user b on(b.iddomain = a.iddomain)
group by
a.iddomain,
a.name,
a.url,
b.iddomain
;
else
select
a.iddomain,
a.name as domain,
a.url
from domain a
inner join rel_domain_user b on(b.iddomain = a.iddomain)
where a.iddomain = iiddomain
group by
a.iddomain,
a.name,
a.url,
b.iddomain
;
End if;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_user_painel`
--
DROP PROCEDURE IF EXISTS `proc_adm_user_painel`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_user_painel`()
BEGIN
select
a.iduser,
a.idlogin,
b.name,
b.mail,
c.datecreate,
b.status as user_status,
d.datemodify,
e.datesolicitation as login_recovery,
g.name as domain,
c.status as login_status ,
CONCAT(i.idpermission, '|', i.nickname ) as permission_nick
from secure.rel_user_login a
inner join secure.user b on(b.iduser = a.iduser)
inner join secure.login c on(c.idlogin = a.idlogin)
left join secure.rel_login_history d on(d.idlogin = a.idlogin)
left join secure.rel_login_recovery e on(e.iduser = a.iduser)
left join secure.rel_domain_user f on(f.iduser = a.iduser)
left join secure.domain g on(g.iddomain = f.iddomain)
left join secure.rel_permission_user h on(h.iduser = b.iduser)
left join secure.permission i on(i.idpermission = h.idpermission) ;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_user_status`
--
DROP PROCEDURE IF EXISTS `proc_adm_user_status`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_user_status`(
in iiduser int,
in iidstatus int,
out oireturn int)
BEGIN
declare status_atual int;
set iidstatus = (select status from secure.user where iduser = iiduser) ;
if (iidstatus = 0) then
set status_atual = 1;
else
set status_atual = 0;
End if;
update secure.user set status = status_atual where iduser = iiduser;
update secure.login set status = status_atual where idlogin in( select idlogin from secure.rel_user_login where iduser = iiduser);
set oireturn = status_atual;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
--
-- Definition of procedure `proc_adm_user_ticket`
--
DROP PROCEDURE IF EXISTS `proc_adm_user_ticket`;
DELIMITER $$
/*!50003 SET @TEMP_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_adm_user_ticket`(
in iiduser int
)
BEGIN
DECLARE vticket VARCHAR(15);
DECLARE oireturn INT;
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION set oireturn = @@error_count;
SET vticket = fun_new_ticket();
IF NOT EXISTS(SELECT 1 FROM rel_user_login WHERE iduser = iiduser limit 1) THEN
INSERT INTO rel_user_login (iduser,idlogin,ticket)
VALUES (iiduser, NULL, vticket);
End if;
END ;
END $$
/*!50003 SET SESSION SQL_MODE=@TEMP_SQL_MODE */ $$
DELIMITER ;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
--修改表
--文件上传记录表增加 唯一文件名字段,用 java.uuid 生成
alter table cms_precative_upload_file
add UNIONFILENAME varchar2(36);
--委托贷款还款表增加字段 还款计划ID
alter table CMS_PRECATIVE_LOAN_REPAY
add REPAYMENT_SCHEDULE_ID number(10);
--委托贷款还款增加字段 还款利息
alter table CMS_PRECATIVE_LOAN_REPAY
add REPAY_MONEY_RATE number(10,2);
--新建表 CMS_PRECATIVE_LOAN_CCAL 委托贷款试算信息
--刘建武
create table CMS_PRECATIVE_LOAN_SEND
(
BILL_CODE CHAR(13) not null,
PRECATIVE_ID NUMBER(10) not null,
FATHER_CODE VARCHAR2(13),
CONTRACT_CODE VARCHAR2(20),
MONEY NUMBER(15,2) not null,
RATE NUMBER(8,6),
SEND_DATE DATE not null,
DEADLINE_DATE DATE not null,
REPAY_TYPE CHAR(2) not null,
OP VARCHAR2(8) not null,
NEXT_CHECKER VARCHAR2(150),
APPROVES VARCHAR2(200),
STATUS NUMBER not null,
ENTER_DATE DATE not null,
RMK VARCHAR2(400),
VOUCHER_NO CHAR(15),
ORDER_NO CHAR(36),
TALLIER_CODE CHAR(8),
DEPOSIT_ACC VARCHAR2(50),
VOUCHER_NO2 CHAR(15),
VOUCHER_NO1 CHAR(15),
LOAN_ACC VARCHAR2(50),
FLOAT_WAY VARCHAR2(15),
RATE_ENTRIES_EFFECT_DATE DATE,
INTEREST_WAY VARCHAR2(15),
REFERENCE_RATE_TYPE VARCHAR2(50),
REPAY_CYCLE VARCHAR2(50),
POINTS_PROPORTION_SELECT VARCHAR2(50),
POINTS_PROPORTION_TEXT NUMBER(15,2),
TERM NUMBER,
CORP_ID NUMBER(10),
SEND_TIME NUMBER(10)
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Add comments to the columns
comment on column CMS_PRECATIVE_LOAN_SEND.BILL_CODE
is '发放编号(主键)';
comment on column CMS_PRECATIVE_LOAN_SEND.PRECATIVE_ID
is '委贷单位';
comment on column CMS_PRECATIVE_LOAN_SEND.FATHER_CODE
is '委贷申请编号';
comment on column CMS_PRECATIVE_LOAN_SEND.CONTRACT_CODE
is '委贷发放编码';
comment on column CMS_PRECATIVE_LOAN_SEND.MONEY
is '发放金额';
comment on column CMS_PRECATIVE_LOAN_SEND.RATE
is '利率';
comment on column CMS_PRECATIVE_LOAN_SEND.SEND_DATE
is '发放日期';
comment on column CMS_PRECATIVE_LOAN_SEND.DEADLINE_DATE
is '到期日期';
comment on column CMS_PRECATIVE_LOAN_SEND.REPAY_TYPE
is '还款方式,01 一次性偿还 ;02 分期偿还 ;03不定';
comment on column CMS_PRECATIVE_LOAN_SEND.OP
is '操作员';
comment on column CMS_PRECATIVE_LOAN_SEND.NEXT_CHECKER
is '下个审批人';
comment on column CMS_PRECATIVE_LOAN_SEND.APPROVES
is '已审批人';
comment on column CMS_PRECATIVE_LOAN_SEND.STATUS
is '状态';
comment on column CMS_PRECATIVE_LOAN_SEND.ENTER_DATE
is '录入日期';
comment on column CMS_PRECATIVE_LOAN_SEND.RMK
is '备注';
comment on column CMS_PRECATIVE_LOAN_SEND.VOUCHER_NO
is '记账凭证号';
comment on column CMS_PRECATIVE_LOAN_SEND.ORDER_NO
is '记账流水号';
comment on column CMS_PRECATIVE_LOAN_SEND.TALLIER_CODE
is '记账员';
comment on column CMS_PRECATIVE_LOAN_SEND.DEPOSIT_ACC
is '贷款账号';
comment on column CMS_PRECATIVE_LOAN_SEND.FLOAT_WAY
is '浮动方式';
comment on column CMS_PRECATIVE_LOAN_SEND.RATE_ENTRIES_EFFECT_DATE
is '利率调整生效日期';
comment on column CMS_PRECATIVE_LOAN_SEND.INTEREST_WAY
is '计息方式';
comment on column CMS_PRECATIVE_LOAN_SEND.REFERENCE_RATE_TYPE
is '基准利率类型';
comment on column CMS_PRECATIVE_LOAN_SEND.REPAY_CYCLE
is '贷款周期';
comment on column CMS_PRECATIVE_LOAN_SEND.POINTS_PROPORTION_SELECT
is '下拉框选择点数或者比例';
comment on column CMS_PRECATIVE_LOAN_SEND.POINTS_PROPORTION_TEXT
is '输入框维护贷款合同规定的点数或浮动比例';
comment on column CMS_PRECATIVE_LOAN_SEND.CORP_ID
is '值同PRECATIVE_ID,审批必须字段';
comment on column CMS_PRECATIVE_LOAN_SEND.SEND_TIME
is '第几次发放';
alter table CMS_PRECATIVE_LOAN_SEND
add constraint PK_CMS_PRECATIVE_LOAN_SEND primary key (BILL_CODE);
create index INDEX_CMS_PRECATIVE_LOAN_SEND on CMS_PRECATIVE_LOAN_SEND (BILL_CODE, STATUS, NEXT_CHECKER, APPROVES);
--新建视图
CREATE OR REPLACE VIEW V_CMS_PRECATIVE_LOAN_INFO AS
select info.BILL_CODE,
info.PD_CODE,
info.PRECATIVE_ID,
info.CORP_ID,
info.CONTRACT_CODE,
info.POUNDAGE,
info.LOAN_OPP,
info.PURPOSE,
info.CURRENCY,
info.TERM,
info.RATE,
info.MONEY,
info.HYPOTHEC_CODE,
info.SURETY_EXPLAIN,
info.REPAIR_OP,
info.END_DATE,
info.START_DATE,
info.OP,
info.NEXT_CHECKER,
info.APPROVES,
info.STATUS,
info.ENTER_DATE,
info.RMK,
info.VOUCHER_NO,
info.REVERSE1,
info.REVERSE2,
info.REVERSE3,
info.REVERSE4,
info.REVERSE5,
info.REVERSE6,
info.REVERSE7,
info.REVERSE8,
info.REVERSE9,
info.REVERSE10,
info.ORDER_NO,
info.TALLIER_CODE,
info.POUNDAGE_RATE,
info.DEPOSIT_ACC,
info.VOUCHER_NO2,
info.VOUCHER_NO1,
info.LOAN_ACC,
info.IS_BANK,
info.APP_CODE,
info.BANK_CODE,
info.GUA_HYPOTHEC_CODE,
info.REPAY_TYPE,
info.INTEREST_WAY,
info.LOAN_SEND_OUT_TYPE,
info.SKIP_LOAN_SEND_OUT,
info.FLOAT_WAY,
info.RATE_ENTRIES_EFFECT_DATE,
info.REFERENCE_RATE_TYPE,
info.REPAY_CYCLE,
info.POINTS_PROPORTION_SELECT,
info.POINTS_PROPORTION_TEXT,
corp1.corp_code precative_id_corp_code,
corp1.corp_name precative_id_corp_name,
corp3.corp_code corp_id_corp_code,
corp3.corp_name corp_id_corp_name,
corp2.corp_code loan_opp_corp_code,
corp2.corp_name loan_opp_corp_name,
bank.bank_name,
cur.cur_name,
typ.type_name
from cms_precative_loan_info info
inner join bt_corp corp1 on corp1.id = info.precative_id --委托方
inner join bt_corp corp2 on corp2.id = info.loan_opp --借款方(贷款对象)
left join bt_corp corp3 on corp3.id = info.corp_id --受托方,如果是is_bank=1, 受托方是银行
left join bt_bank bank on bank.bank_code = info.bank_code --银行受托方
inner join bt_currency cur on cur.cur_code = info.currency
inner join cms_provide_loan_type typ on typ.type_code = info.hypothec_code
and typ.operation_type = 'C';
/
CREATE OR REPLACE VIEW V_CMS_PRECATIVE_LOAN_SEND AS
select send.BILL_CODE,
send.PRECATIVE_ID,--委托方
send.FATHER_CODE,
send.CONTRACT_CODE,
send.MONEY,
send.RATE,
send.SEND_DATE,
send.DEADLINE_DATE,
send.REPAY_TYPE,
send.OP,
send.NEXT_CHECKER,
send.APPROVES,
send.STATUS,
send.ENTER_DATE,
send.RMK,
send.VOUCHER_NO,
send.ORDER_NO,
send.TALLIER_CODE,
send.DEPOSIT_ACC,
send.VOUCHER_NO2,
send.VOUCHER_NO1,
send.LOAN_ACC,
send.FLOAT_WAY,
send.RATE_ENTRIES_EFFECT_DATE,
send.INTEREST_WAY,
send.REFERENCE_RATE_TYPE,
send.REPAY_CYCLE,
send.POINTS_PROPORTION_SELECT,
send.POINTS_PROPORTION_TEXT,
send.TERM,
cur.cur_code,
cur.cur_name,
corp1.corp_code,
corp1.corp_name,
corp2.corp_code corp_id_corp_code,
corp2.corp_name corp_id_corp_name,
corp3.corp_code loan_opp_corp_code,
corp3.corp_name loan_opp_corp_name,
usr.user_code,
usr.user_name,
typ.type_code,
typ.type_name,
info.hypothec_code,
info.purpose,
info.pd_code,
info.loan_send_out_type,
info.skip_loan_send_out,
info.gua_hypothec_code,
info.bank_code,
info.app_code,
info.is_bank,
info.repair_op,
info.surety_explain,
info.poundage_rate,
info.poundage,
info.corp_id,--受托方
info.loan_opp,--借款人
bank.bank_name --受托行
from cms_precative_loan_send send
inner join cms_precative_loan_info info on send.father_code = info.bill_code
inner join bt_corp corp1 on info.precative_id = corp1.id
left join bt_corp corp2 on info.corp_id=corp2.id
inner join bt_corp corp3 on info.loan_opp=corp3.id
inner join bt_currency cur on info.currency = cur.cur_code
inner join cms_provide_loan_type typ on info.hypothec_code = typ.type_code and typ.operation_type = 'C'
inner join bt_user usr on send.op = usr.user_code
left join bt_bank bank on bank.bank_code=info.bank_code;
/
create or replace view v_cms_precative_loan_send_info as
select info.BILL_CODE info_bill_code, --委托贷款录入单号
info.PRECATIVE_ID info_PRECATIVE_ID, --委托人单位Id
info.CURRENCY info_CURRENCY, --币别代码
info.TERM info_TERM, --贷款期限
info.MONEY info_MONEY, --贷款金额
info.ENTER_DATE info_ENTER_DATE, --贷款录入日期
info.hypothec_code info_hypothec_code, --担保方式代码
send.BILL_CODE send_BILL_CODE, --发放编号(主键)
send.CONTRACT_CODE send_CONTRACT_CODE, --发放编号(输入)
send.MONEY send_MONEY, --发放金额
send.SEND_DATE send_SEND_DATE, --发放日期
send.STATUS send_STATUS, --发放状态
temp.USEDMONEY, --已发放金额
cur.cur_name, --币别名称
corp.corp_name precative_corp_name, --委托人名称
typ.type_name --担保方式名称
from cms_precative_loan_info info
--最多同时只能有一个发放记录在业务中
left join cms_precative_loan_send send on info.bill_code =
send.father_code
and send.status >= -1
and send.status < 102 --102记账完成
left join (select father_code, sum(money) usedmoney
from cms_precative_loan_send
where status >= 102
group by father_code) temp on temp.father_code =
info.bill_code
inner join bt_currency cur on cur.cur_code = info.currency
inner join bt_corp corp on corp.id = info.precative_id
inner join cms_provide_loan_type typ on typ.operation_type='C' and typ.type_code=info.hypothec_code
where info.status = 97 --补录完成
and (temp.usedmoney < info.money or temp.usedmoney is null) --发放金额未完;
;
/
--菜单 信贷管理>>委托贷款>>委托贷款发放
DECLARE
VN_COUNT NUMBER;
BEGIN
SELECT COUNT(*)
INTO VN_COUNT
FROM bt_sys_res t1 WHERE t1.sys_code='cms' AND t1.res_name='委托贷款发放' AND t1.res_url='/cms/cmsPrecativeLoanSendAction.do?method=goMainPage';
IF VN_COUNT < 1 THEN
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)
select (select max(res_code)+1 from bt_sys_res) , '委托贷款发放', 'cms', (select res_code from bt_sys_res where sys_code='cms' and res_name='委托贷款' and father_code=0), '/cms/cmsPrecativeLoanSendAction.do?method=goMainPage', '0', '0', '0', '0', 9, '中远', '', '', '', '', '', null, null, null, null, null, 1, ''
from bt_sys_res where res_name = '委托贷款' and sys_code = 'cms' and father_code=0;
END IF;
COMMIT;
END;
/
--审批业务 cms_C3 委托贷款发放
DECLARE
VN_COUNT NUMBER;
BEGIN
SELECT COUNT(*)
INTO VN_COUNT
from bt_approve_business where business_code='cms_C3';
IF VN_COUNT < 1 THEN
insert into bt_approve_business (business_code,sys_code,business_name,business_level,table_name,money_field,next_checker_field,bill_code_field,url1,class_path)
select 'cms_C3','cms','委托贷款发放','A,B,C','cms_precative_loan_send','money','next_checker','bill_code','../cms/cmsPrecativeLoanSendShow.jsp','com.byttersoft.cms.form.CmsPrecativeLoanSendForm'
from dual;
END IF;
COMMIT;
END;
/
--主键生成器
DECLARE
VN_count number;
begin
select count(*)
into VN_count
from bt_key_generator where keyalisename='CMS_PRECATIVE_LOAN_SEND' and genstrate='cu';
if VN_count<1 then
insert into bt_key_generator(id,keyalisename,custgenclass,genstrate)
values((select max(id)+1 from bt_key_generator),'CMS_PRECATIVE_LOAN_SEND','com.byttersoft.keyservice.usrdefgenerator.CmsPrecativeLoanSendKeyGenerator','cu');
end if;
commit;
end;
/
--旧流程数据处理,装换成send 数据
insert into cms_precative_loan_send
(bill_code,
precative_id,
father_code,
contract_code,
money,
rate,
send_date,
deadline_date,
repay_type,
op,
next_checker,
approves,
status,
enter_date,
rmk,
voucher_no,
order_no,
tallier_code,
deposit_acc,
voucher_no2,
voucher_no1,
loan_acc,
float_way,
rate_entries_effect_date,
interest_way,
reference_rate_type,
repay_cycle,
points_proportion_select,
points_proportion_text,
term,
corp_id,
send_time)
select info.bill_code,
info.precative_id,
info.bill_code,
info.contract_code,
info.money,
info.rate,
info.start_date,
info.end_date,
'02',
info.op,
info.next_checker,
info.approves,
info.status,
info.enter_date,
info.rmk,
info.voucher_no,
info.order_no,
info.tallier_code,
info.deposit_acc,
info.voucher_no2,
info.voucher_no1,
info.loan_acc,
'01', --浮动方式固定01 固定利率
info.rate_entries_effect_date,
'01', --计息方式固定 01 还本付息
info.reference_rate_type,
info.repay_cycle,
info.points_proportion_select,
to_number(info.points_proportion_text),
info.term,
info.corp_id,
1 --发放次数固定1
from cms_precative_loan_info info
where info.status>=97 --补录完成以后的数据
and info.loan_send_out_type is null --新流程之前的数据此字段一定为空
and info.bill_code not in(select father_code from cms_precative_loan_send) --在发放表中无发放明细
;
commit; |
select * from students;
create database db;
|
CONNECT / AS sysdba;
CREATE TABLESPACE busy_green_fish
DATAFILE
'/u01/qvs94/leftfish/node03/busygreenfish01.dbf'
SIZE 20M
REUSE
AUTOEXTEND ON
MAXSIZE UNLIMITED,
'/u01/qvs94/leftfish/node02/busygreenfish02.dbf'
SIZE 20M
REUSE
AUTOEXTEND ON
MAXSIZE UNLIMITED,
'/u01/qvs94/leftfish/node04/busygreenfish03.dbf'
SIZE 20M
REUSE
AUTOEXTEND ON
MAXSIZE UNLIMITED;
CREATE TABLESPACE dry_gray_soup
DATAFILE
'/u01/qvs94/leftfish/node03/drygraysoup01.dbf'
SIZE 20M
REUSE
AUTOEXTEND ON
MAXSIZE UNLIMITED,
'/u01/qvs94/leftfish/node04/drygraysoup02.dbf'
SIZE 20M
REUSE
AUTOEXTEND ON
MAXSIZE UNLIMITED; |
ALTER TABLE vilkar_resultat
RENAME COLUMN fk_periode_resultat_id TO fk_person_resultat_id;
|
/* ---------------------------------------------------- */
/* Generated by Enterprise Architect Version 15.0 */
/* Created On : 15-май-2021 19:30:01 */
/* DBMS : MySql */
/* ---------------------------------------------------- */
SET FOREIGN_KEY_CHECKS=0
;
/* Drop Tables */
DROP TABLE IF EXISTS `long_link` CASCADE
;
DROP TABLE IF EXISTS `rules` CASCADE
;
DROP TABLE IF EXISTS `rules_definition` CASCADE
;
DROP TABLE IF EXISTS `short_link` CASCADE
;
DROP TABLE IF EXISTS `stats` CASCADE
;
DROP TABLE IF EXISTS `user` CASCADE
;
/* Create Tables */
CREATE TABLE `long_link`
(
`ll_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`ll_sl_id` BIGINT UNSIGNED NOT NULL,
`ll_long_url` VARCHAR(2084) NOT NULL,
`ll_creation_time` DATETIME NOT NULL,
CONSTRAINT `PK_long_link` PRIMARY KEY (`ll_id` ASC)
)
;
CREATE TABLE `rules`
(
`r_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`r_rule_id` SMALLINT UNSIGNED NOT NULL,
`r_short_url_id` BIGINT UNSIGNED NOT NULL,
`r_param` VARCHAR(2048) NULL,
`r_is_active` BOOL NOT NULL,
CONSTRAINT `PK_Table1` PRIMARY KEY (`r_id` ASC)
)
;
CREATE TABLE `rules_definition`
(
`rd_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`rd_name` VARCHAR(128) NOT NULL,
CONSTRAINT `PK_rules_definition` PRIMARY KEY (`rd_id` ASC)
)
;
CREATE TABLE `short_link`
(
`sl_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`sl_user_id` INT UNSIGNED NOT NULL,
`sl_short_url` VARCHAR(200) NOT NULL,
`sl_creation_time` DATETIME NOT NULL,
CONSTRAINT `PK_short_link` PRIMARY KEY (`sl_id` ASC)
)
;
CREATE TABLE `stats`
(
`s_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`s_sl_id` BIGINT UNSIGNED NOT NULL,
`s_date_time` DATETIME NOT NULL,
`s_url_referrer` VARCHAR(2048) NULL,
`s_platform` VARCHAR(255) NULL,
`s_screen_width` MEDIUMINT UNSIGNED NULL,
`s_screen_height` MEDIUMINT UNSIGNED NULL,
`s_ip_address` VARCHAR(39) NULL,
CONSTRAINT `PK_stats` PRIMARY KEY (`s_id` ASC)
)
;
CREATE TABLE `user`
(
`u_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`u_login` VARCHAR(40) NOT NULL,
`u_email` VARCHAR(256) NOT NULL,
`u_hash` VARCHAR(60) NOT NULL,
CONSTRAINT `PK_user` PRIMARY KEY (`u_id` ASC)
)
;
/* Create Primary Keys, Indexes, Uniques, Checks */
ALTER TABLE `long_link`
ADD INDEX `IXFK_long_link_short_link` (`ll_sl_id` ASC)
;
ALTER TABLE `rules`
ADD INDEX `IXFK_rules_rules_definition` (`r_rule_id` ASC)
;
ALTER TABLE `rules`
ADD INDEX `IXFK_rules_short_link` (`r_short_url_id` ASC)
;
ALTER TABLE `short_link`
ADD INDEX `IXFK_short_link_user` (`sl_user_id` ASC)
;
ALTER TABLE `stats`
ADD INDEX `IXFK_stats_short_link` (`s_sl_id` ASC)
;
/* Create Foreign Key Constraints */
ALTER TABLE `long_link`
ADD CONSTRAINT `FK_long_link_short_link`
FOREIGN KEY (`ll_sl_id`) REFERENCES `short_link` (`sl_id`) ON DELETE Cascade ON UPDATE Cascade
;
ALTER TABLE `rules`
ADD CONSTRAINT `FK_rules_rules_definition`
FOREIGN KEY (`r_rule_id`) REFERENCES `rules_definition` (`rd_id`) ON DELETE Cascade ON UPDATE Cascade
;
ALTER TABLE `rules`
ADD CONSTRAINT `FK_rules_short_link`
FOREIGN KEY (`r_short_url_id`) REFERENCES `short_link` (`sl_id`) ON DELETE Cascade ON UPDATE Cascade
;
ALTER TABLE `short_link`
ADD CONSTRAINT `FK_short_link_user`
FOREIGN KEY (`sl_user_id`) REFERENCES `user` (`u_id`) ON DELETE Cascade ON UPDATE Cascade
;
ALTER TABLE `stats`
ADD CONSTRAINT `FK_stats_short_link`
FOREIGN KEY (`s_sl_id`) REFERENCES `short_link` (`sl_id`) ON DELETE Cascade ON UPDATE Cascade
;
SET FOREIGN_KEY_CHECKS=1
;
|
create or replace view v1_czcs017yh as
select
t."JSDE329",t."DE281",t."DE282",t."DE051",t."HDDE136",t."JSDE325",t."DE193",t."JSDE955",t."DE041",t."DE061",
t."HDDE137",t."HDDE127",t."DE001",t."HDDE128",t."JSDE067",t."HDDE129",t."HDDE130",t."HDDE120",t."DE011",t."DE022"
from czcs017yh t;
|
USE `arenafifadb_staging`;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculateEndOfTemporadaFUT` $$
CREATE PROCEDURE `spCalculateEndOfTemporadaFUT`(pIdTemp INTEGER, pIdNewTemp INTEGER)
Begin
UPDATE TB_CAMPEONATO SET IN_CAMPEONATO_ATIVO = FALSE
WHERE SG_TIPO_CAMPEONATO IN ("FUT1", "FUT2", "CFUT", "LFUT") AND IN_CAMPEONATO_ATIVO = TRUE;
call `arenafifadb_staging`.`spCalculateAllFasesEndOfTemporadaFUT`(pIdTemp, pIdNewTemp);
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculateAllFasesEndOfTemporadaFUT` $$
CREATE PROCEDURE `spCalculateAllFasesEndOfTemporadaFUT`(pIdTemp INTEGER, pIdTempNew INTEGER)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _sgCamps VARCHAR(50) DEFAULT "LFUT,FUT1,FUT2,CFUT";
DECLARE _sgLigas VARCHAR(50) DEFAULT "FUT1,FUT2,LFUT";
DECLARE _sgCamp VARCHAR(4) DEFAULT NULL;
DECLARE _count INTEGER DEFAULT 0;
DECLARE _idCamp INTEGER DEFAULT 0;
DECLARE _idCampAux INTEGER DEFAULT 0;
DECLARE _ptsVitoria INTEGER DEFAULT NULL;
DECLARE _ptsEmpate INTEGER DEFAULT NULL;
DECLARE _idUsuHome INTEGER DEFAULT NULL;
DECLARE _idUsuAway INTEGER DEFAULT NULL;
DECLARE _qtGolsHome INTEGER DEFAULT NULL;
DECLARE _qtGolsAway INTEGER DEFAULT NULL;
DECLARE _sumPoints INTEGER DEFAULT 0;
DECLARE _sumEmpate INTEGER DEFAULT 0;
DECLARE _sumVitoria INTEGER DEFAULT 0;
DECLARE _sumLiga INTEGER DEFAULT 0;
DECLARE _sumCopa INTEGER DEFAULT 0;
#Calculando as Fases de Classificação....
DECLARE tabela_cursor CURSOR FOR
SELECT J.ID_CAMPEONATO, J.ID_USUARIO_TIME_CASA, J.ID_USUARIO_TIME_VISITANTE, J.QT_GOLS_TIME_CASA, J.QT_GOLS_TIME_VISITANTE, C.SG_TIPO_CAMPEONATO
FROM TB_TABELA_JOGO J, TB_TIME T1 , TB_TIME T2, TB_USUARIO TU1, TB_USUARIO TU2, TB_CLASSIFICACAO TC1, TB_CLASSIFICACAO TC2, TB_CAMPEONATO C
WHERE C.ID_TEMPORADA = pIdTemp
AND J.ID_FASE = 0
AND FIND_IN_SET(C.SG_TIPO_CAMPEONATO, _sgCamps) > 0
AND C.ID_CAMPEONATO = J.ID_CAMPEONATO
AND C.ID_CAMPEONATO = TC1.ID_CAMPEONATO
AND C.ID_CAMPEONATO = TC2.ID_CAMPEONATO
AND J.ID_CAMPEONATO = TC1.ID_CAMPEONATO
AND J.ID_CAMPEONATO = TC2.ID_CAMPEONATO
AND J.ID_TIME_CASA = T1.ID_TIME
AND J.ID_TIME_VISITANTE = T2.ID_TIME
AND J.ID_USUARIO_TIME_CASA = TU1.ID_USUARIO
AND J.ID_USUARIO_TIME_VISITANTE = TU2.ID_USUARIO
AND J.ID_TIME_CASA = TC1.ID_TIME
AND J.ID_TIME_VISITANTE = TC2.ID_TIME
AND J.DT_EFETIVACAO_JOGO is not null
ORDER BY J.ID_CAMPEONATO, J.ID_FASE, J.DT_TABELA_INICIO_JOGO, J.DS_HORA_JOGO, J.ID_TABELA_JOGO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
#DELETE FROM TB_HISTORICO_ARTILHARIA_FUT WHERE ID_TEMPORADA >= pIdTemp;
DELETE FROM TB_HISTORICO_CONQUISTA_FUT WHERE ID_TEMPORADA >= pIdTemp;
DELETE FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA >= pIdTemp;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _idCamp, _idUsuHome, _idUsuAway, _qtGolsHome, _qtGolsAway, _sgCamp;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
IF _idCamp <> _idCampAux THEN
SELECT PT_VITORIAS_FASE1, PT_EMPATES_FASE1 into _ptsVitoria, _ptsEmpate
FROM TB_PONTUACAO_CAMPEONATO WHERE SG_TIPO_CAMPEONATO = _sgCamp;
IF _ptsVitoria IS NULL THEN
SET _ptsVitoria = 0;
SET _ptsEmpate = 0;
END IF;
SET _idCampAux = _idCamp;
END IF;
SELECT count(1) into _count FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsuHome;
IF _count = 0 THEN
call `arenafifadb_staging`.`spAddHistoricoTemporadaFUT`(pIdTemp, _idUsuHome, NULL);
END IF;
SET _sumPoints = 0;
SET _sumEmpate = 0;
SET _sumVitoria = 0;
IF _qtGolsHome = _qtGolsAway THEN
SET _sumPoints = _ptsEmpate;
SET _sumEmpate = _ptsEmpate;
ELSEIF _qtGolsHome > _qtGolsAway THEN
SET _sumPoints = _ptsVitoria;
SET _sumVitoria = _ptsVitoria;
END IF;
SET _sumLiga = 0;
SET _sumCopa = 0;
IF INSTR(_sgLigas,_sgCamp)> 0 THEN
SET _sumLiga = _sumPoints;
ELSE
SET _sumCopa = _sumPoints;
END IF;
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_EMPATES_FASE1 = (PT_EMPATES_FASE1+_sumEmpate),
PT_VITORIAS_FASE1 = (PT_VITORIAS_FASE1+_sumVitoria),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsuHome;
SELECT count(1) into _count FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsuAway;
IF _count = 0 THEN
call `arenafifadb_staging`.`spAddHistoricoTemporadaFUT`(pIdTemp, _idUsuAway, NULL);
END IF;
SET _sumPoints = 0;
SET _sumEmpate = 0;
SET _sumVitoria = 0;
IF _qtGolsHome = _qtGolsAway THEN
SET _sumPoints = _ptsEmpate;
SET _sumEmpate = _ptsEmpate;
ELSEIF _qtGolsHome < _qtGolsAway THEN
SET _sumPoints = _ptsVitoria;
SET _sumVitoria = _ptsVitoria;
END IF;
SET _sumLiga = 0;
SET _sumCopa = 0;
IF INSTR(_sgLigas,_sgCamp)> 0 THEN
SET _sumLiga = _sumPoints;
ELSE
SET _sumCopa = _sumPoints;
END IF;
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_EMPATES_FASE1 = (PT_EMPATES_FASE1+_sumEmpate),
PT_VITORIAS_FASE1 = (PT_VITORIAS_FASE1+_sumVitoria),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsuAway;
END LOOP get_tabela;
CLOSE tabela_cursor;
#Calculando fases playoff....
call `arenafifadb_staging`.`spCalculateFasePlayoffFUT_PRO`(pIdTemp, _sgCamps, _sgLigas, "FUT");
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculateFasePlayoffFUT_PRO` $$
CREATE PROCEDURE `spCalculateFasePlayoffFUT_PRO`(pIdTemp INTEGER, pSgCamps VARCHAR(50), pSgLigas VARCHAR(50), pTipo VARCHAR(3))
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _sgCamp VARCHAR(4) DEFAULT NULL;
DECLARE _idCamp INTEGER DEFAULT 0;
DECLARE _idCampAux INTEGER DEFAULT 0;
DECLARE _ptsCalssifFase2 INTEGER DEFAULT NULL;
DECLARE _idNextFase INTEGER DEFAULT NULL;
DECLARE _ptsRound16 INTEGER DEFAULT NULL;
DECLARE _ptsFase2 INTEGER DEFAULT NULL;
DECLARE _ptsQuarter INTEGER DEFAULT NULL;
DECLARE _ptsSemi INTEGER DEFAULT NULL;
DECLARE _ptsChampion INTEGER DEFAULT NULL;
DECLARE _ptsVice INTEGER DEFAULT NULL;
DECLARE _inIdaEVolta TINYINT DEFAULT NULL;
DECLARE _idPreviousTemp TINYINT DEFAULT NULL;
DECLARE _qtMaxGols INTEGER DEFAULT NULL;
DECLARE tabela_cursor CURSOR FOR
SELECT C.ID_CAMPEONATO, C.SG_TIPO_CAMPEONATO, C.IN_SISTEMA_IDA_VOLTA FROM TB_CAMPEONATO C
WHERE C.ID_TEMPORADA = pIdTemp AND FIND_IN_SET(C.SG_TIPO_CAMPEONATO, pSgCamps) > 0 ORDER BY C.ID_CAMPEONATO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _idCamp, _sgCamp, _inIdaEVolta;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
IF _idCamp <> _idCampAux THEN
SELECT PT_CLASSIF_FASE2, PT_FASE2, PT_OITAVAS, PT_QUARTAS, PT_SEMIS, PT_VICECAMPEAO, PT_CAMPEAO
into _ptsCalssifFase2, _ptsFase2, _ptsRound16, _ptsQuarter, _ptsSemi, _ptsVice, _ptsChampion
FROM TB_PONTUACAO_CAMPEONATO WHERE SG_TIPO_CAMPEONATO = _sgCamp;
IF _ptsCalssifFase2 IS NULL THEN
SET _ptsCalssifFase2 = 0;
SET _ptsFase2 = 0;
SET _ptsRound16 = 0;
SET _ptsQuarter = 0;
SET _ptsSemi = 0;
SET _ptsVice = 0;
SET _ptsChampion = 0;
END IF;
SET _idCampAux = _idCamp;
END IF;
SELECT ID_FASE into _idNextFase FROM TB_FASE_CAMPEONATO WHERE ID_CAMPEONATO = _idCamp AND ID_FASE > 0 ORDER BY IN_ORDENACAO LIMIT 1;
#Calculando passagens para a próxima fase....
call `arenafifadb_staging`.`spCalculatePassNextFaseFUT_PRO`(pIdTemp, _idCamp, _sgCamp, _idNextFase, _ptsCalssifFase2, pSgLigas, pTipo);
#Calculando Fases Seguintes de Playoff....
#2a Fase
call `arenafifadb_staging`.`spCalculateEachFasePlayoffFUT_PRO`(pIdTemp, _idCamp, _sgCamp, 1, "FASE2", _ptsFase2, pSgLigas, pTipo);
#Oitavas
call `arenafifadb_staging`.`spCalculateEachFasePlayoffFUT_PRO`(pIdTemp, _idCamp, _sgCamp, 2, "OITAVAS", _ptsRound16, pSgLigas, pTipo);
#Quartas
call `arenafifadb_staging`.`spCalculateEachFasePlayoffFUT_PRO`(pIdTemp, _idCamp, _sgCamp, 3, "QUARTAS", _ptsQuarter, pSgLigas, pTipo);
#Semi
call `arenafifadb_staging`.`spCalculateEachFasePlayoffFUT_PRO`(pIdTemp, _idCamp, _sgCamp, 4, "SEMI", _ptsSemi, pSgLigas, pTipo);
#Campeao e Vice
IF _inIdaEVolta = false THEN
call `arenafifadb_staging`.`spCalculateChampionAndViceFUT_PRO`(pIdTemp, _idCamp, _sgCamp, _ptsChampion, _ptsVice, pSgLigas, 0, "1", pTipo);
ELSE
call `arenafifadb_staging`.`spCalculateChampionAndViceFUT_PRO`(pIdTemp, _idCamp, _sgCamp, _ptsChampion, _ptsVice, pSgLigas, 1, "1,2", pTipo);
END IF;
#Artilharia
IF pTipo = "PRO" THEN
SELECT X.QT_GOLS_MARCADOS INTO _qtMaxGols
FROM (SELECT J.ID_GOLEADOR, SUM(J.QT_GOLS) as QT_GOLS_MARCADOS, J.ID_TIME
FROM TB_GOLEADOR_JOGO J
WHERE J.ID_CAMPEONATO = _idCamp
GROUP BY J.ID_GOLEADOR, J.ID_TIME) X, TB_GOLEADOR G, TB_TIME T
WHERE X.ID_GOLEADOR = G.ID_GOLEADOR
AND X.ID_TIME = G.ID_TIME
AND G.ID_TIME = T.ID_TIME
ORDER BY X.QT_GOLS_MARCADOS DESC, G.NM_GOLEADOR LIMIT 1;
call `arenafifadb_staging`.`spCalculateScorersPRO`(pIdTemp, _idCamp, _qtMaxGols);
END IF;
END LOOP get_tabela;
CLOSE tabela_cursor;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_TOTAL = (PT_CAMPEAO+PT_VICECAMPEAO+PT_SEMIS+PT_QUARTAS+PT_OITAVAS+PT_CLASSIF_FASE2+PT_VITORIAS_FASE1+PT_EMPATES_FASE1),
PT_TOTAL_TEMPORADA = (PT_LIGAS+PT_COPAS)
WHERE ID_TEMPORADA = pIdTemp;
SELECT ID_TEMPORADA into _idPreviousTemp FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA < pIdTemp ORDER BY ID_TEMPORADA DESC LIMIT 1;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_TOTAL = (PT_CAMPEAO+PT_VICECAMPEAO+PT_SEMIS+PT_QUARTAS+PT_OITAVAS+PT_CLASSIF_FASE2+PT_VITORIAS_FASE1+PT_EMPATES_FASE1),
PT_TOTAL_TEMPORADA = (PT_LIGAS+PT_COPAS)
WHERE ID_TEMPORADA = pIdTemp;
SELECT ID_TEMPORADA into _idPreviousTemp FROM TB_HISTORICO_TEMPORADA_PRO WHERE ID_TEMPORADA < pIdTemp ORDER BY ID_TEMPORADA DESC LIMIT 1;
END IF;
IF pTipo = "FUT" THEN
#Atualizando Aproveitamento dos técnicos....
call `arenafifadb_staging`.`spPrepareToCalculatePerformanceTecnicosFUT`(pIdTemp, _idPreviousTemp, pSgLigas);
#Atualizando Historico todos técnicos....
call `arenafifadb_staging`.`spAddAllTecnicosHistoricoTemporadaFUT`(pIdTemp);
#Atualizando o Hall da Fama....
call `arenafifadb_staging`.`spUpdateHallOfFameFUT`(pIdTemp);
ELSE
#Atualizando Aproveitamento dos técnicos....
call `arenafifadb_staging`.`spPrepareToCalculatePerformanceTecnicosPRO`(pIdTemp, _idPreviousTemp, pSgLigas);
#Atualizando Historico todos técnicos....
call `arenafifadb_staging`.`spAddAllTecnicosHistoricoTemporadaPRO`(pIdTemp);
#Atualizando o Hall da Fama....
call `arenafifadb_staging`.`spUpdateHallOfFamePRO`(pIdTemp);
END IF;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spUpdateHallOfFameFUT` $$
CREATE PROCEDURE `spUpdateHallOfFameFUT`(
pIdTemp INTEGER
)
Begin
call `arenafifadb_staging`.`spUpdateHallOfFameLstNegraFUT`(pIdTemp);
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET IN_REBAIXADO_TEMP_ANTERIOR = 0
WHERE ID_TEMPORADA = pIdTemp AND IN_REBAIXADO_TEMP_ANTERIOR IS NULL;
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET IN_ACESSO_TEMP_ATUAL = 0
WHERE ID_TEMPORADA = pIdTemp;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spUpdateHallOfFameLstNegraFUT` $$
CREATE PROCEDURE `spUpdateHallOfFameLstNegraFUT`(
pIdTemp INTEGER
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _IdUsu INTEGER DEFAULT 0;
DECLARE _qtTotalPG INTEGER DEFAULT 0;
DECLARE _qtTotalPGAux INTEGER DEFAULT -1;
DECLARE _qtLstNegra INTEGER DEFAULT NULL;
DECLARE _count INTEGER DEFAULT 0;
DECLARE _countAux INTEGER DEFAULT 1;
DECLARE tabela_cursor CURSOR FOR
SELECT ID_USUARIO, PT_TOTAL FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA = pIdTemp
ORDER BY PT_TOTAL DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _IdUsu, _qtTotalPG;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
IF _qtTotalPGAux <> _qtTotalPG THEN
SET _qtTotalPGAux = _qtTotalPG;
SET _count = _count + _countAux;
SET _countAux = 1;
ELSE
SET _countAux = _countAux + 1;
END IF;
SELECT PT_TOTAL into _qtLstNegra FROM TB_LISTA_NEGRA
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _IdUsu;
IF _qtLstNegra IS NULL THEN
SET _qtLstNegra = 0;
END IF;
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET IN_POSICAO_ATUAL = _count,
QT_LSTNEGRA = _qtLstNegra
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _IdUsu;
END LOOP get_tabela;
CLOSE tabela_cursor;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spAddAllTecnicosHistoricoTemporadaFUT` $$
CREATE PROCEDURE `spAddAllTecnicosHistoricoTemporadaFUT`(
pIdTemp INTEGER
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _idUsu INTEGER DEFAULT 0;
DECLARE _idTemp INTEGER DEFAULT 0;
DECLARE _total INTEGER DEFAULT 0;
DECLARE _totLstNegra INTEGER DEFAULT 0;
DECLARE _apGeral DECIMAL(5,2) DEFAULT 0;
DECLARE tabela_cursor CURSOR FOR
SELECT ID_USUARIO, max(ID_TEMPORADA) FROM TB_HISTORICO_TEMPORADA_FUT
WHERE ID_USUARIO NOT IN (SELECT ID_USUARIO FROM TB_HISTORICO_TEMPORADA WHERE ID_Temporada = pIdTemp)
GROUP BY ID_USUARIO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _idUsu, _idTemp;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SELECT PT_TOTAL, PC_APROVEITAMENTO_GERAL, QT_LSTNEGRA into _total, _apGeral, _totLstNegra
FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA = _idTemp AND ID_USUARIO = _idUsu;
call `arenafifadb_staging`.`spAddHistoricoTemporadaFUT`(pIdTemp, _idUsu, 0);
IF (_total IS NOT NULL) THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_TOTAL = _total, PC_APROVEITAMENTO_GERAL = _apGeral, QT_LSTNEGRA = _totLstNegra, IN_ACESSO_TEMP_ATUAL = 0
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu;
ELSE
INSERT INTO TB_HISTORICO_TEMPORADA_FUT (ID_TEMPORADA, ID_USUARIO, IN_ACESSO_TEMP_ATUAL, PT_CAMPEAO, PT_VICECAMPEAO, PT_SEMIS, PT_QUARTAS, PT_OITAVAS, PT_CLASSIF_FASE2,
PT_VITORIAS_FASE1, PT_EMPATES_FASE1, IN_POSICAO_ATUAL, PT_LIGAS, PT_COPAS, PT_TOTAL_TEMPORADA, QT_JOGOS_TEMPORADA,
QT_TOTAL_PONTOS_TEMPORADA, QT_TOTAL_VITORIAS_TEMPORADA, QT_TOTAL_EMPATES_TEMPORADA, PC_APROVEITAMENTO_TEMPORADAS,
IN_REBAIXADO_TEMP_ANTERIOR, QT_LSTNEGRA, PT_TOTAL, PT_TOTAL_TEMPORADA_ANTERIOR, IN_POSICAO_ANTERIOR,
QT_JOGOS_GERAL, QT_TOTAL_PONTOS_GERAL, QT_TOTAL_VITORIAS_GERAL, QT_TOTAL_EMPATES_GERAL, PC_APROVEITAMENTO_GERAL)
SELECT pIdTemp, _idUsu, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, COALESCE(T.PT_TOTAL,0), COALESCE(T.PT_TOTAL_TEMPORADA_ANTERIOR,0),
COALESCE(T.IN_POSICAO_ANTERIOR,0), COALESCE(T.QT_JOGOS_GERAL,0), COALESCE(T.QT_TOTAL_PONTOS_GERAL,0), COALESCE(T.QT_TOTAL_VITORIAS_GERAL,0),
COALESCE(T.QT_TOTAL_EMPATES_GERAL,0), COALESCE(T.PC_APROVEITAMENTO_GERAL,0)
FROM TB_HISTORICO_TEMPORADA_FUT T
WHERE T.ID_TEMPORADA < pIdTemp AND T.ID_USUARIO = _idUsu ORDER BY T.ID_TEMPORADA DESC limit 1;
END IF;
END LOOP get_tabela;
CLOSE tabela_cursor;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spPrepareToCalculatePerformanceTecnicosFUT` $$
CREATE PROCEDURE `spPrepareToCalculatePerformanceTecnicosFUT`(
pIdTemp INTEGER,
pIdPreviousTemp INTEGER,
pSgLigas VARCHAR(50)
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _idUsu INTEGER DEFAULT 0;
DECLARE _totPontos INTEGER DEFAULT 0;
DECLARE _totTemp INTEGER DEFAULT 0;
DECLARE _totPreviusTemp INTEGER DEFAULT 0;
DECLARE tabela_cursor CURSOR FOR
SELECT ID_USUARIO, PT_TOTAL_TEMPORADA FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA = pIdTemp ORDER BY ID_USUARIO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _idUsu, _totTemp;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SELECT PT_TOTAL into _totPreviusTemp FROM TB_HISTORICO_TEMPORADA_FUT WHERE ID_TEMPORADA = pIdPreviousTemp AND ID_USUARIO = _idUsu;
IF _totPreviusTemp IS NULL THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_TOTAL_TEMPORADA_ANTERIOR = PT_TOTAL_TEMPORADA
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_TOTAL_TEMPORADA_ANTERIOR = _totPreviusTemp, PT_TOTAL = (PT_TOTAL+_totPreviusTemp)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu;
END IF;
call `arenafifadb_staging`.`spCalculatePerformanceTecnicosFUT_PRO`(pIdTemp, _idUsu, pSgLigas, "FUT");
call `arenafifadb_staging`.`spCalculatePerformanceGeralTecnicosFUT_PRO`(pIdTemp, _idUsu, pSgLigas, "FUT");
END LOOP get_tabela;
CLOSE tabela_cursor;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculatePerformanceGeralTecnicosFUT_PRO` $$
CREATE PROCEDURE `spCalculatePerformanceGeralTecnicosFUT_PRO`(
pIdTemp INTEGER,
pIdUsu INTEGER,
pSgLigas VARCHAR(50), pTipo VARCHAR(3)
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _IdUsuHome INTEGER DEFAULT 0;
DECLARE _IdUsuAway INTEGER DEFAULT 0;
DECLARE _sumGolsHome INTEGER DEFAULT 0;
DECLARE _sumGolsAway INTEGER DEFAULT 0;
DECLARE _qtJogosGeral INTEGER DEFAULT 0;
DECLARE _qtdVitoriasGeral INTEGER DEFAULT 0;
DECLARE _qtdEmpatesGeral INTEGER DEFAULT 0;
DECLARE _qtdPontosGanhosGeral INTEGER DEFAULT 0;
DECLARE _totPontosGeral INTEGER DEFAULT 0;
DECLARE tabela_cursor CURSOR FOR
SELECT J.QT_GOLS_TIME_CASA, J.QT_GOLS_TIME_VISITANTE, J.ID_USUARIO_TIME_CASA, J.ID_USUARIO_TIME_VISITANTE
FROM TB_TABELA_JOGO J, TB_CAMPEONATO C, TB_TEMPORADA T WHERE T.ID_TEMPORADA <= pIdTemp
AND (J.ID_USUARIO_TIME_CASA = pIdUsu OR J.ID_USUARIO_TIME_VISITANTE = pIdUsu)
AND J.ID_CAMPEONATO = C.ID_CAMPEONATO AND C.ID_TEMPORADA = T.ID_TEMPORADA AND C.SG_TIPO_CAMPEONATO IN (pSgLigas)
ORDER BY J.ID_TABELA_JOGO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _sumGolsHome, _sumGolsAway, _IdUsuHome, _IdUsuAway;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SET _qtJogosGeral = _qtJogosGeral + 1;
IF _sumGolsHome = _sumGolsAway THEN
SET _qtdEmpatesGeral = _qtdEmpatesGeral + 1;
ELSEIF (pIdUsu = _IdUsuHome) AND (_sumGolsHome > _sumGolsAway) THEN
SET _qtdVitoriasGeral = _qtdVitoriasGeral + 1;
ELSEIF (pIdUsu = _IdUsuAway) AND (_sumGolsAway > _sumGolsHome) THEN
SET _qtdVitoriasGeral = _qtdVitoriasGeral + 1;
END IF;
END LOOP get_tabela;
CLOSE tabela_cursor;
SET _totPontosGeral = _qtJogosGeral * 3;
SET _qtdPontosGanhosGeral = (_qtdVitoriasGeral * 3) + _qtdEmpatesGeral;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET QT_JOGOS_GERAL = _qtJogosGeral,
QT_TOTAL_VITORIAS_GERAL = _qtdVitoriasGeral,
QT_TOTAL_EMPATES_GERAL = _qtdEmpatesGeral,
QT_TOTAL_PONTOS_GERAL = _totPontosGeral,
PC_APROVEITAMENTO_GERAL = ( (_qtdPontosGanhosGeral * 100) / _totPontosGeral )
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = pIdUsu;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET QT_JOGOS_GERAL = _qtJogosGeral,
QT_TOTAL_VITORIAS_GERAL = _qtdVitoriasGeral,
QT_TOTAL_EMPATES_GERAL = _qtdEmpatesGeral,
QT_TOTAL_PONTOS_GERAL = _totPontosGeral,
PC_APROVEITAMENTO_GERAL = ( (_qtdPontosGanhosGeral * 100) / _totPontosGeral )
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = pIdUsu;
END IF;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculatePerformanceTecnicosFUT_PRO` $$
CREATE PROCEDURE `spCalculatePerformanceTecnicosFUT_PRO`(
pIdTemp INTEGER,
pIdUsu INTEGER,
pSgLigas VARCHAR(50), pTipo VARCHAR(3)
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _IdUsuHome INTEGER DEFAULT 0;
DECLARE _IdUsuAway INTEGER DEFAULT 0;
DECLARE _sumGolsHome INTEGER DEFAULT 0;
DECLARE _sumGolsAway INTEGER DEFAULT 0;
DECLARE _qtJogosTemp INTEGER DEFAULT 0;
DECLARE _qtdVitorias INTEGER DEFAULT 0;
DECLARE _qtdEmpates INTEGER DEFAULT 0;
DECLARE _qtdPontosGanhos INTEGER DEFAULT 0;
DECLARE _totPontosTemporada INTEGER DEFAULT 0;
DECLARE tabela_cursor CURSOR FOR
SELECT J.QT_GOLS_TIME_CASA, J.QT_GOLS_TIME_VISITANTE, J.ID_USUARIO_TIME_CASA, J.ID_USUARIO_TIME_VISITANTE
FROM TB_TABELA_JOGO J, TB_CAMPEONATO C, TB_TEMPORADA T WHERE T.ID_TEMPORADA = pIdTemp
AND (J.ID_USUARIO_TIME_CASA = pIdUsu OR J.ID_USUARIO_TIME_VISITANTE = pIdUsu)
AND J.ID_CAMPEONATO = C.ID_CAMPEONATO AND C.ID_TEMPORADA = T.ID_TEMPORADA AND C.SG_TIPO_CAMPEONATO IN (pSgLigas)
ORDER BY J.ID_TABELA_JOGO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _sumGolsHome, _sumGolsAway, _IdUsuHome, _IdUsuAway;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SET _qtJogosTemp = _qtJogosTemp + 1;
IF _sumGolsHome = _sumGolsAway THEN
SET _qtdEmpates = _qtdEmpates + 1;
ELSEIF (pIdUsu = _IdUsuHome) AND (_sumGolsHome > _sumGolsAway) THEN
SET _qtdVitorias = _qtdVitorias + 1;
ELSEIF (pIdUsu = _IdUsuAway) AND (_sumGolsAway > _sumGolsHome) THEN
SET _qtdVitorias = _qtdVitorias + 1;
END IF;
END LOOP get_tabela;
CLOSE tabela_cursor;
SET _totPontosTemporada = _qtJogosTemp * 3;
SET _qtdPontosGanhos = (_qtdVitorias * 3) + _qtdEmpates;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET QT_JOGOS_TEMPORADA = _qtJogosTemp,
QT_TOTAL_VITORIAS_TEMPORADA = _qtdVitorias,
QT_TOTAL_EMPATES_TEMPORADA = _qtdEmpates,
QT_TOTAL_PONTOS_TEMPORADA = _totPontosTemporada,
PC_APROVEITAMENTO_TEMPORADAS = ( (_qtdPontosGanhos * 100) / _totPontosTemporada )
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = pIdUsu;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET QT_JOGOS_TEMPORADA = _qtJogosTemp,
QT_TOTAL_VITORIAS_TEMPORADA = _qtdVitorias,
QT_TOTAL_EMPATES_TEMPORADA = _qtdEmpates,
QT_TOTAL_PONTOS_TEMPORADA = _totPontosTemporada,
PC_APROVEITAMENTO_TEMPORADAS = ( (_qtdPontosGanhos * 100) / _totPontosTemporada )
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = pIdUsu;
END IF;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculateChampionAndViceFUT_PRO` $$
CREATE PROCEDURE `spCalculateChampionAndViceFUT_PRO`(
pIdTemp INTEGER,
pIdCamp INTEGER,
pSgCamp VARCHAR(4),
pPtsChampion INTEGER,
pPtsVice INTEGER,
pSgLigas VARCHAR(50),
pInIdaEVolta INTEGER,
pNumRodadas VARCHAR(5), pTipo VARCHAR(3)
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _idUsu1 INTEGER DEFAULT 0;
DECLARE _idUsu2 INTEGER DEFAULT 0;
DECLARE _sumLiga INTEGER DEFAULT 0;
DECLARE _sumCopa INTEGER DEFAULT 0;
DECLARE _QtdGolsHome INTEGER DEFAULT 0;
DECLARE _QtdGolsAway INTEGER DEFAULT 0;
DECLARE _IdTimeHome INTEGER DEFAULT 0;
DECLARE _IdTimeAway INTEGER DEFAULT 0;
DECLARE _sumGolsTime1 INTEGER DEFAULT 0;
DECLARE _sumGolsTime2 INTEGER DEFAULT 0;
DECLARE _sumGolsAwayTime1 INTEGER DEFAULT 0;
DECLARE _sumGolsAwayTime2 INTEGER DEFAULT 0;
DECLARE tabela_cursor CURSOR FOR
SELECT TU1.ID_USUARIO as IDUSU1, TU2.ID_USUARIO as IDUSU2, J.QT_GOLS_TIME_CASA, J.QT_GOLS_TIME_VISITANTE, J.ID_TIME_CASA, J.ID_TIME_VISITANTE
FROM TB_TABELA_JOGO J, TB_USUARIO TU1, TB_USUARIO TU2
WHERE J.ID_CAMPEONATO = pIdCamp
AND J.ID_FASE = 5
AND J.IN_NUMERO_RODADA IN (pNumRodadas)
AND J.DT_EFETIVACAO_JOGO IS NOT NULL
AND J.ID_USUARIO_TIME_CASA = TU1.ID_USUARIO
AND J.ID_USUARIO_TIME_VISITANTE = TU2.ID_USUARIO
ORDER BY J.IN_JOGO_MATAXMATA, J.IN_NUMERO_RODADA, J.DT_TABELA_INICIO_JOGO, J.DS_HORA_JOGO, J.ID_TABELA_JOGO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _idUsu1, _idUsu2, _QtdGolsHome, _QtdGolsAway, _IdTimeHome, _IdTimeAway;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SET _sumLiga = 0;
SET _sumCopa = 0;
IF pInIdaEVolta = 0 THEN
IF _QtdGolsHome > _QtdGolsAway OR _QtdGolsHome = _QtdGolsAway THEN
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsChampion;
ELSE
SET _sumCopa = pPtsChampion;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
END IF;
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsVice;
ELSE
SET _sumCopa = pPtsVice;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
INSERT INTO TB_HISTORICO_CONQUISTA_FUT (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu1, _IdTimeHome, _idUsu2, _IdTimeAway);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
INSERT INTO TB_HISTORICO_CONQUISTA_PRO (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu1, _IdTimeHome, _idUsu2, _IdTimeAway);
END IF;
ELSEIF _QtdGolsHome < _QtdGolsAway THEN
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsChampion;
ELSE
SET _sumCopa = pPtsChampion;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
END IF;
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsVice;
ELSE
SET _sumCopa = pPtsVice;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
INSERT INTO TB_HISTORICO_CONQUISTA_FUT (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu2, _IdTimeAway, _idUsu1, _IdTimeHome);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
INSERT INTO TB_HISTORICO_CONQUISTA_PRO (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu2, _IdTimeAway, _idUsu1, _IdTimeHome);
END IF;
END IF;
ELSE
SET _sumGolsTime1 = _QtdGolsHome;
SET _sumGolsTime2 = _QtdGolsAway;
SET _sumGolsAwayTime2 = _QtdGolsAway;
FETCH tabela_cursor INTO _idUsu1, _idUsu2, _QtdGolsHome, _QtdGolsAway, _IdTimeHome, _IdTimeAway;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SET _sumGolsTime2 = _sumGolsTime2 + _QtdGolsHome;
SET _sumGolsTime1 = _sumGolsTime1 + _QtdGolsAway;
SET _sumGolsAwayTime1 = _QtdGolsAway;
IF ((_sumGolsTime2 > _sumGolsTime1) OR (_sumGolsTime1 = _sumGolsTime2 AND _sumGolsAwayTime2 > _sumGolsAwayTime1)) THEN
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsChampion;
ELSE
SET _sumCopa = pPtsChampion;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
END IF;
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsVice;
ELSE
SET _sumCopa = pPtsVice;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
INSERT INTO TB_HISTORICO_CONQUISTA_FUT (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu2, _IdTimeAway, _idUsu1, _IdTimeHome);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
INSERT INTO TB_HISTORICO_CONQUISTA_PRO (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu2, _IdTimeAway, _idUsu1, _IdTimeHome);
END IF;
ELSEIF ((_sumGolsTime1 > _sumGolsTime2) OR (_sumGolsTime1 = _sumGolsTime2 AND _sumGolsAwayTime1 > _sumGolsAwayTime2)) THEN
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsChampion;
ELSE
SET _sumCopa = pPtsChampion;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_CAMPEAO = (PT_CAMPEAO+pPtsChampion),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu1;
END IF;
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsVice;
ELSE
SET _sumCopa = pPtsVice;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
INSERT INTO TB_HISTORICO_CONQUISTA_FUT (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu1, _IdTimeHome, _idUsu2, _IdTimeAway);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_VICECAMPEAO = (PT_VICECAMPEAO+pPtsVice),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO = _idUsu2;
INSERT INTO TB_HISTORICO_CONQUISTA_PRO (ID_TEMPORADA, ID_CAMPEONATO, ID_USUARIO_CAMPEAO, ID_TIME_CAMPEAO, ID_USUARIO_VICECAMPEAO, ID_TIME_VICECAMPEAO)
VALUES (pIdTemp, pIdCamp, _idUsu1, _IdTimeHome, _idUsu2, _IdTimeAway);
END IF;
END IF;
END IF;
END LOOP get_tabela;
CLOSE tabela_cursor;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculateEachFasePlayoffFUT_PRO` $$
CREATE PROCEDURE `spCalculateEachFasePlayoffFUT_PRO`(
pIdTemp INTEGER,
pIdCamp INTEGER,
pSgCamp VARCHAR(4),
pIdFasePlayoff INTEGER,
pTipoFasePlayoff VARCHAR(10),
pPtsFasePlayoff INTEGER,
pSgLigas VARCHAR(50), pTipo VARCHAR(3)
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _idUsu1 INTEGER DEFAULT 0;
DECLARE _idUsu2 INTEGER DEFAULT 0;
DECLARE _sumLiga INTEGER DEFAULT 0;
DECLARE _sumCopa INTEGER DEFAULT 0;
DECLARE tabela_cursor CURSOR FOR
SELECT TU1.ID_USUARIO, TU2.ID_USUARIO
FROM TB_TABELA_JOGO J, TB_USUARIO TU1, TB_USUARIO TU2
WHERE J.ID_CAMPEONATO = pIdCamp
AND J.ID_FASE = pIdFasePlayoff
AND J.IN_NUMERO_RODADA = 1
AND J.ID_USUARIO_TIME_CASA = TU1.ID_USUARIO
AND J.ID_USUARIO_TIME_VISITANTE = TU2.ID_USUARIO
AND J.DT_EFETIVACAO_JOGO IS NOT NULL;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _idUsu1, _idUsu2;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SET _sumLiga = 0;
SET _sumCopa = 0;
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsFasePlayoff;
ELSE
SET _sumCopa = pPtsFasePlayoff;
END IF;
IF pTipoFasePlayoff = "FASE2" THEN
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_CLASSIF_FASE2 = (PT_CLASSIF_FASE2+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_CLASSIF_FASE2 = (PT_CLASSIF_FASE2+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
END IF;
ELSEIF pTipoFasePlayoff = "OITAVAS" THEN
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_OITAVAS = (PT_OITAVAS+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_OITAVAS = (PT_OITAVAS+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
END IF;
ELSEIF pTipoFasePlayoff = "QUARTAS" THEN
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_QUARTAS = (PT_QUARTAS+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_QUARTAS = (PT_QUARTAS+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
END IF;
ELSEIF pTipoFasePlayoff = "SEMI" THEN
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_SEMIS = (PT_SEMIS+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_SEMIS = (PT_SEMIS+pPtsFasePlayoff),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
END IF;
END IF;
END LOOP get_tabela;
CLOSE tabela_cursor;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spCalculatePassNextFaseFUT_PRO` $$
CREATE PROCEDURE `spCalculatePassNextFaseFUT_PRO`(
pIdTemp INTEGER,
pIdCamp INTEGER,
pSgCamp VARCHAR(4),
pIdNextFase INTEGER,
pPtsCalssifFase2 INTEGER,
pSgLigas VARCHAR(50), pTipo VARCHAR(3)
)
Begin
DECLARE _finished INTEGER DEFAULT 0;
DECLARE _idUsu1 INTEGER DEFAULT 0;
DECLARE _idUsu2 INTEGER DEFAULT 0;
DECLARE _sumLiga INTEGER DEFAULT 0;
DECLARE _sumCopa INTEGER DEFAULT 0;
DECLARE tabela_cursor CURSOR FOR
SELECT TU1.ID_USUARIO as IDUSU1, TU2.ID_USUARIO as IDUSU2
FROM TB_TABELA_JOGO J, TB_USUARIO TU1, TB_USUARIO TU2
WHERE J.ID_CAMPEONATO = pIdCamp
AND J.ID_FASE = pIdNextFase
AND J.IN_NUMERO_RODADA = 1
AND J.DT_EFETIVACAO_JOGO IS NOT NULL
AND J.ID_USUARIO_TIME_CASA = TU1.ID_USUARIO
AND J.ID_USUARIO_TIME_VISITANTE = TU2.ID_USUARIO
ORDER BY J.DT_TABELA_INICIO_JOGO, J.DS_HORA_JOGO, J.ID_TABELA_JOGO;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _finished = 1;
OPEN tabela_cursor;
get_tabela: LOOP
FETCH tabela_cursor INTO _idUsu1, _idUsu2;
IF _finished = 1 THEN
LEAVE get_tabela;
END IF;
SET _sumLiga = 0;
SET _sumCopa = 0;
IF pSgCamp IN (pSgLigas) THEN
SET _sumLiga = pPtsCalssifFase2;
ELSE
SET _sumCopa = pPtsCalssifFase2;
END IF;
IF pTipo = "FUT" THEN
UPDATE TB_HISTORICO_TEMPORADA_FUT
SET PT_CLASSIF_FASE2 = (PT_CLASSIF_FASE2+pPtsCalssifFase2),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
ELSE
UPDATE TB_HISTORICO_TEMPORADA_PRO
SET PT_CLASSIF_FASE2 = (PT_CLASSIF_FASE2+pPtsCalssifFase2),
PT_COPAS = (PT_COPAS+_sumCopa),
PT_LIGAS = (PT_LIGAS+_sumLiga)
WHERE ID_TEMPORADA = pIdTemp AND ID_USUARIO IN (_idUsu1, _idUsu2);
END IF;
END LOOP get_tabela;
CLOSE tabela_cursor;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spGenerateCampeonatoLigaFUT` $$
CREATE PROCEDURE `spGenerateCampeonatoLigaFUT`(
pIdTemp INTEGER,
pTpCamp VARCHAR(4),
pDtInicio DATE,
pDtSorteio DATE,
pNmCamp VARCHAR(50),
pQtTimesAcesso INTEGER,
pQtTimesRebaix INTEGER,
pQtTimes INTEGER,
pQtDiasClassif INTEGER,
pQtDiasPlayoff INTEGER,
pListaTimes VARCHAR(500),
pInLimiteLstNegra INTEGER
)
Begin
DECLARE _TipoTimeFUT INTEGER DEFAULT 37;
DECLARE _SiglaTimeFUT VARCHAR(3) DEFAULT "FUT";
DECLARE _IdCampLigas VARCHAR(5) DEFAULT "8,9";
DECLARE _IdCampBco INTEGER DEFAULT 7;
DECLARE _idCamp INTEGER DEFAULT NULL;
DECLARE _idTime INTEGER DEFAULT NULL;
DECLARE _countTecnicos INTEGER DEFAULT 0;
SET _idCamp = fcAddNovoCampeonato(pIdTemp, pTpCamp, FALSE);
IF (_idCamp>0) THEN
UPDATE TB_CAMPEONATO
SET NM_CAMPEONATO = pNmCamp,
DT_INICIO = pDtInicio,
DT_SORTEIO = pDtSorteio,
QT_DIAS_PARTIDA_FASE_MATAxMATA = pQtDiasPlayoff,
QT_TIMES_ACESSO = pQtTimesAcesso,
QT_DIAS_PARTIDA_CLASSIFICACAO = pQtDiasClassif,
QT_TIMES = pQtTimes,
QT_TIMES_REBAIXADOS = pQtTimesRebaix,
IN_DISPUTA_3o_4o_Lugar = FALSE
WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_GRUPO WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_POTE_TIME_GRUPO WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_CAMPEONATO_USUARIO WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_CAMPEONATO_TIME WHERE ID_CAMPEONATO = _idCamp;
SET _countTecnicos = fcAddTecnicos(pIdTemp, _idCamp, _IdCampLigas, _IdCampBco, pQtTimes, pInLimiteLstNegra, _SiglaTimeFUT, _TipoTimeFUT);
SET _countTecnicos = fcAddTecnicosBco(pIdTemp, _idCamp, _IdCampBco, pQtTimes, pInLimiteLstNegra, _countTecnicos, _SiglaTimeFUT, _TipoTimeFUT);
call `arenafifadb_staging`.`spAddLoadClassificacaoInitialOfCampeonatov2`(_idCamp);
call `arenafifadb_staging`.`spAssumeTimes`(_idCamp);
END IF;
SELECT _idCamp as idNewCampeonato, _countTecnicos as QtdTimes;
End$$
DELIMITER ;
DELIMITER $$
DROP PROCEDURE IF EXISTS `spGenerateCampeonatoCopaFUT` $$
CREATE PROCEDURE `spGenerateCampeonatoCopaFUT`(
pIdTemp INTEGER,
pTpCamp VARCHAR(4),
pDtInicio DATE,
pDtSorteio DATE,
pNmCamp VARCHAR(50),
pQtTimesAcesso INTEGER,
pQtTimesRebaix INTEGER,
pQtTimes INTEGER,
pQtDiasClassif INTEGER,
pQtDiasPlayoff INTEGER,
pIdsCampLiga VARCHAR(10),
pListaTimesPreCopa VARCHAR(500)
)
Begin
DECLARE _SiglaTimeFUT VARCHAR(3) DEFAULT "FUT";
DECLARE _idCamp INTEGER DEFAULT NULL;
SET _idCamp = fcAddNovoCampeonato(pIdTemp, pTpCamp, FALSE);
IF (_idCamp>0) THEN
UPDATE TB_CAMPEONATO
SET NM_CAMPEONATO = pNmCamp,
DT_INICIO = pDtInicio,
DT_SORTEIO = pDtSorteio,
QT_DIAS_PARTIDA_FASE_MATAxMATA = pQtDiasPlayoff,
QT_TIMES_ACESSO = pQtTimesAcesso,
QT_DIAS_PARTIDA_CLASSIFICACAO = pQtDiasClassif,
QT_TIMES = pQtTimes,
QT_TIMES_REBAIXADOS = pQtTimesRebaix,
IN_DISPUTA_3o_4o_Lugar = FALSE
WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_FASE_CAMPEONATO WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_GRUPO WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_POTE_TIME_GRUPO WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_CAMPEONATO_USUARIO WHERE ID_CAMPEONATO = _idCamp;
DELETE FROM TB_CAMPEONATO_TIME WHERE ID_CAMPEONATO = _idCamp;
INSERT INTO TB_FASE_CAMPEONATO VALUES (_idCamp, -1, 1);
INSERT INTO TB_FASE_CAMPEONATO VALUES (_idCamp, 2, 2);
INSERT INTO TB_FASE_CAMPEONATO VALUES (_idCamp, 3, 3);
INSERT INTO TB_FASE_CAMPEONATO VALUES (_idCamp, 4, 4);
INSERT INTO TB_FASE_CAMPEONATO VALUES (_idCamp, 5, 5);
call `arenafifadb_staging`.`spAddTecnicosFromLigasToCampeonatoTimeUsuario`(_idCamp, pIdsCampLiga);
call `arenafifadb_staging`.`spAddLoadClassificacaoInitialOfCampeonatov2`(_idCamp);
IF (pListaTimesPreCopa<>"") THEN
call `arenafifadb_staging`.`spAddListaTimesPreCopa`(_idCamp, pListaTimesPreCopa, _SiglaTimeFUT);
END IF;
call `arenafifadb_staging`.`spAssumeTimes`(_idCamp);
END IF;
SELECT _idCamp as idNewCampeonato;
End$$
DELIMITER ;
|
-- Adminer 4.7.2 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
SET NAMES utf8mb4;
DROP DATABASE IF EXISTS `homestead`;
CREATE DATABASE `homestead` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */;
USE `homestead`;
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`userid` int(11) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(20) COLLATE utf8mb4_bin NOT NULL,
`password` varchar(20) COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
INSERT INTO `users` (`userid`, `username`, `password`) VALUES
(1, 'ikhmal', 'secretable'),
(2, 'mala', 'hello');
-- 2019-08-16 09:23:18
|
-- How to identify which Groups have access to a Project in JIRA
-- https://confluence.atlassian.com/jirakb/how-to-identify-which-groups-have-access-to-a-project-in-jira-884354938.html
select project.pkey as pkey,project.pname as project_name,projectrole.name as project_role_name,cwd_membership.parent_name as groupuser
from cwd_membership,projectrole,projectroleactor,project
where project.id = projectroleactor.pid and projectroleactor.projectroleid = projectrole.id
and roletype = 'atlassian-group-role-actor' and membership_type='GROUP_USER' and parent_name=roletypeparameter
group by pkey,project_name,project_role_name,groupuser; |
-- +micrate Up
-- SQL in section 'Up' is executed when this migration is applied
create table flipper_settings (
id serial primary key,
feature_name text not null,
guild_id bigint not null,
enabled bool not null default false,
unique (feature_name, guild_id)
);
-- +micrate Down
-- SQL section 'Down' is executed when this migration is rolled back
drop table flipper_settings;
|
--PROBLEM 03 ALTER TABLE FOREIGN KEY
ALTER TABLE Minions
ADD TownId INT NOT NULL FOREIGN KEY REFERENCES Towns(Id)
ALTER TABLE Minions
ALTER COLUMN Age INT |
CREATE TABLE IF NOT EXISTS denuncias (
id SERIAL NOT NULL PRIMARY KEY,
name VARCHAR(50) NOT NULL,
age INTEGER NOT NULL,
phone VARCHAR(50),
assedioType VARCHAR(50) NOT NULL,
description VARCHAR(250) NULL,
local VARCHAR(50) NOT NULL,
incontact BOOLEAN NOT NULL DEFAULT FALSE
);
|
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50505
Source Host : localhost:3306
Source Database : thuonggiado.vn
Target Server Type : MYSQL
Target Server Version : 50505
File Encoding : 65001
Date: 2020-10-12 12:29:36
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for sma_addresses
-- ----------------------------
DROP TABLE IF EXISTS `sma_addresses`;
CREATE TABLE `sma_addresses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`company_id` int(11) NOT NULL,
`line1` varchar(50) NOT NULL,
`line2` varchar(50) DEFAULT NULL,
`city` varchar(25) NOT NULL,
`postal_code` varchar(20) DEFAULT NULL,
`state` varchar(25) NOT NULL,
`country` varchar(50) NOT NULL,
`phone` varchar(50) DEFAULT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_addresses
-- ----------------------------
-- ----------------------------
-- Table structure for sma_adjustments
-- ----------------------------
DROP TABLE IF EXISTS `sma_adjustments`;
CREATE TABLE `sma_adjustments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`reference_no` varchar(55) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`note` text,
`attachment` varchar(55) DEFAULT NULL,
`created_by` int(11) NOT NULL,
`updated_by` int(11) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`count_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `warehouse_id` (`warehouse_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_adjustments
-- ----------------------------
-- ----------------------------
-- Table structure for sma_adjustment_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_adjustment_items`;
CREATE TABLE `sma_adjustment_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`adjustment_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`option_id` int(11) DEFAULT NULL,
`quantity` decimal(15,4) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`serial_no` varchar(255) DEFAULT NULL,
`type` varchar(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `adjustment_id` (`adjustment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_adjustment_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_brands
-- ----------------------------
DROP TABLE IF EXISTS `sma_brands`;
CREATE TABLE `sma_brands` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(20) DEFAULT NULL,
`name` varchar(50) NOT NULL,
`image` varchar(50) DEFAULT NULL,
`slug` varchar(55) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_brands
-- ----------------------------
INSERT INTO `sma_brands` VALUES ('1', 'XIAOMI', 'XIAOMI', null, 'xiaomi', 'ALL XIAOMI PRODUCT');
-- ----------------------------
-- Table structure for sma_calendar
-- ----------------------------
DROP TABLE IF EXISTS `sma_calendar`;
CREATE TABLE `sma_calendar` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(55) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`start` datetime NOT NULL,
`end` datetime DEFAULT NULL,
`color` varchar(7) NOT NULL,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_calendar
-- ----------------------------
-- ----------------------------
-- Table structure for sma_captcha
-- ----------------------------
DROP TABLE IF EXISTS `sma_captcha`;
CREATE TABLE `sma_captcha` (
`captcha_id` bigint(13) unsigned NOT NULL AUTO_INCREMENT,
`captcha_time` int(10) unsigned NOT NULL,
`ip_address` varchar(16) CHARACTER SET latin1 NOT NULL DEFAULT '0',
`word` varchar(20) CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`captcha_id`),
KEY `word` (`word`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_captcha
-- ----------------------------
-- ----------------------------
-- Table structure for sma_categories
-- ----------------------------
DROP TABLE IF EXISTS `sma_categories`;
CREATE TABLE `sma_categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(55) NOT NULL,
`name` varchar(55) NOT NULL,
`image` varchar(55) DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
`slug` varchar(55) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_categories
-- ----------------------------
INSERT INTO `sma_categories` VALUES ('1', 'C1', 'Category 1', null, null, null, null);
-- ----------------------------
-- Table structure for sma_combo_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_combo_items`;
CREATE TABLE `sma_combo_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`item_code` varchar(20) NOT NULL,
`quantity` decimal(12,4) NOT NULL,
`unit_price` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_combo_items
-- ----------------------------
INSERT INTO `sma_combo_items` VALUES ('1', '3', '6970740900936', '2.0000', '490000.0000');
-- ----------------------------
-- Table structure for sma_companies
-- ----------------------------
DROP TABLE IF EXISTS `sma_companies`;
CREATE TABLE `sma_companies` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(10) unsigned DEFAULT NULL,
`group_name` varchar(20) NOT NULL,
`customer_group_id` int(11) DEFAULT NULL,
`customer_group_name` varchar(100) DEFAULT NULL,
`name` varchar(55) NOT NULL,
`company` varchar(255) NOT NULL,
`vat_no` varchar(100) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
`city` varchar(55) DEFAULT NULL,
`state` varchar(55) DEFAULT NULL,
`postal_code` varchar(8) DEFAULT NULL,
`country` varchar(100) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`email` varchar(100) NOT NULL,
`cf1` varchar(100) DEFAULT NULL,
`cf2` varchar(100) DEFAULT NULL,
`cf3` varchar(100) DEFAULT NULL,
`cf4` varchar(100) DEFAULT NULL,
`cf5` varchar(100) DEFAULT NULL,
`cf6` varchar(100) DEFAULT NULL,
`invoice_footer` text,
`payment_term` int(11) DEFAULT '0',
`logo` varchar(255) DEFAULT 'logo.png',
`award_points` int(11) DEFAULT '0',
`deposit_amount` decimal(25,4) DEFAULT NULL,
`price_group_id` int(11) DEFAULT NULL,
`price_group_name` varchar(50) DEFAULT NULL,
`gst_no` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `group_id` (`group_id`),
KEY `group_id_2` (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_companies
-- ----------------------------
INSERT INTO `sma_companies` VALUES ('1', '3', 'customer', '1', 'General', 'Walk-in Customer', 'Walk-in Customer', '', 'Customer Address', 'Petaling Jaya', 'Selangor', '46000', 'Malaysia', '0123456789', 'customer@tecdiary.com', '', '', '', '', '', '', null, '0', 'logo.png', '0', null, null, null, null);
INSERT INTO `sma_companies` VALUES ('2', '4', 'supplier', null, null, 'Test Supplier', 'Supplier Company Name', null, 'Supplier Address', 'Petaling Jaya', 'Selangor', '46050', 'Malaysia', '0123456789', 'supplier@tecdiary.com', '-', '-', '-', '-', '-', '-', null, '0', 'logo.png', '0', null, null, null, null);
INSERT INTO `sma_companies` VALUES ('3', null, 'biller', null, null, 'Mian Saleem', 'Test Biller', '5555', 'Biller adddress', 'City', '', '', 'Country', '012345678', 'saleem@tecdiary.com', '', '', '', '', '', '', ' Thank you for shopping with us. Please come again', '0', 'logo1.png', '0', null, null, null, null);
INSERT INTO `sma_companies` VALUES ('4', '4', 'supplier', null, null, 'T2', 'Xiaomi Deerma', '', 'Shenzhen', 'Guangdong', '', '', '', '0708591830', 'dovinh.tgd@gmail.com', '', '', '', '', '', '', null, '0', 'logo.png', '0', null, null, null, '');
-- ----------------------------
-- Table structure for sma_costing
-- ----------------------------
DROP TABLE IF EXISTS `sma_costing`;
CREATE TABLE `sma_costing` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`product_id` int(11) DEFAULT NULL,
`sale_item_id` int(11) NOT NULL,
`sale_id` int(11) DEFAULT NULL,
`purchase_item_id` int(11) DEFAULT NULL,
`quantity` decimal(15,4) NOT NULL,
`purchase_net_unit_cost` decimal(25,4) DEFAULT NULL,
`purchase_unit_cost` decimal(25,4) DEFAULT NULL,
`sale_net_unit_price` decimal(25,4) NOT NULL,
`sale_unit_price` decimal(25,4) NOT NULL,
`quantity_balance` decimal(15,4) DEFAULT NULL,
`inventory` tinyint(1) DEFAULT '0',
`overselling` tinyint(1) DEFAULT '0',
`option_id` int(11) DEFAULT NULL,
`purchase_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_costing
-- ----------------------------
-- ----------------------------
-- Table structure for sma_currencies
-- ----------------------------
DROP TABLE IF EXISTS `sma_currencies`;
CREATE TABLE `sma_currencies` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(5) NOT NULL,
`name` varchar(55) NOT NULL,
`rate` decimal(12,4) NOT NULL,
`auto_update` tinyint(1) NOT NULL DEFAULT '0',
`symbol` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_currencies
-- ----------------------------
INSERT INTO `sma_currencies` VALUES ('3', 'VND', 'Việt Nam Đồng', '1.0000', '0', 'đ');
-- ----------------------------
-- Table structure for sma_customer_groups
-- ----------------------------
DROP TABLE IF EXISTS `sma_customer_groups`;
CREATE TABLE `sma_customer_groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`percent` int(11) NOT NULL,
`discount` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_customer_groups
-- ----------------------------
INSERT INTO `sma_customer_groups` VALUES ('1', 'General', '0', null);
INSERT INTO `sma_customer_groups` VALUES ('2', 'Reseller', '-5', null);
INSERT INTO `sma_customer_groups` VALUES ('3', 'Distributor', '-15', null);
INSERT INTO `sma_customer_groups` VALUES ('4', 'New Customer (+10)', '10', null);
-- ----------------------------
-- Table structure for sma_date_format
-- ----------------------------
DROP TABLE IF EXISTS `sma_date_format`;
CREATE TABLE `sma_date_format` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`js` varchar(20) NOT NULL,
`php` varchar(20) NOT NULL,
`sql` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_date_format
-- ----------------------------
INSERT INTO `sma_date_format` VALUES ('1', 'mm-dd-yyyy', 'm-d-Y', '%m-%d-%Y');
INSERT INTO `sma_date_format` VALUES ('2', 'mm/dd/yyyy', 'm/d/Y', '%m/%d/%Y');
INSERT INTO `sma_date_format` VALUES ('3', 'mm.dd.yyyy', 'm.d.Y', '%m.%d.%Y');
INSERT INTO `sma_date_format` VALUES ('4', 'dd-mm-yyyy', 'd-m-Y', '%d-%m-%Y');
INSERT INTO `sma_date_format` VALUES ('5', 'dd/mm/yyyy', 'd/m/Y', '%d/%m/%Y');
INSERT INTO `sma_date_format` VALUES ('6', 'dd.mm.yyyy', 'd.m.Y', '%d.%m.%Y');
-- ----------------------------
-- Table structure for sma_deliveries
-- ----------------------------
DROP TABLE IF EXISTS `sma_deliveries`;
CREATE TABLE `sma_deliveries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`sale_id` int(11) NOT NULL,
`do_reference_no` varchar(50) NOT NULL,
`sale_reference_no` varchar(50) NOT NULL,
`customer` varchar(55) NOT NULL,
`address` varchar(1000) NOT NULL,
`note` varchar(1000) DEFAULT NULL,
`status` varchar(15) DEFAULT NULL,
`attachment` varchar(50) DEFAULT NULL,
`delivered_by` varchar(50) DEFAULT NULL,
`received_by` varchar(50) DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_deliveries
-- ----------------------------
-- ----------------------------
-- Table structure for sma_deposits
-- ----------------------------
DROP TABLE IF EXISTS `sma_deposits`;
CREATE TABLE `sma_deposits` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`company_id` int(11) NOT NULL,
`amount` decimal(25,4) NOT NULL,
`paid_by` varchar(50) DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
`created_by` int(11) NOT NULL,
`updated_by` int(11) NOT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_deposits
-- ----------------------------
-- ----------------------------
-- Table structure for sma_expenses
-- ----------------------------
DROP TABLE IF EXISTS `sma_expenses`;
CREATE TABLE `sma_expenses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`reference` varchar(50) NOT NULL,
`amount` decimal(25,4) NOT NULL,
`note` varchar(1000) DEFAULT NULL,
`created_by` varchar(55) NOT NULL,
`attachment` varchar(55) DEFAULT NULL,
`category_id` int(11) DEFAULT NULL,
`warehouse_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_expenses
-- ----------------------------
-- ----------------------------
-- Table structure for sma_expense_categories
-- ----------------------------
DROP TABLE IF EXISTS `sma_expense_categories`;
CREATE TABLE `sma_expense_categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(55) NOT NULL,
`name` varchar(55) NOT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_expense_categories
-- ----------------------------
-- ----------------------------
-- Table structure for sma_gift_cards
-- ----------------------------
DROP TABLE IF EXISTS `sma_gift_cards`;
CREATE TABLE `sma_gift_cards` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`card_no` varchar(20) NOT NULL,
`value` decimal(25,4) NOT NULL,
`customer_id` int(11) DEFAULT NULL,
`customer` varchar(255) DEFAULT NULL,
`balance` decimal(25,4) NOT NULL,
`expiry` date DEFAULT NULL,
`created_by` varchar(55) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `card_no` (`card_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_gift_cards
-- ----------------------------
-- ----------------------------
-- Table structure for sma_gift_card_topups
-- ----------------------------
DROP TABLE IF EXISTS `sma_gift_card_topups`;
CREATE TABLE `sma_gift_card_topups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`card_id` int(11) NOT NULL,
`amount` decimal(15,4) NOT NULL,
`created_by` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `card_id` (`card_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_gift_card_topups
-- ----------------------------
-- ----------------------------
-- Table structure for sma_groups
-- ----------------------------
DROP TABLE IF EXISTS `sma_groups`;
CREATE TABLE `sma_groups` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`description` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_groups
-- ----------------------------
INSERT INTO `sma_groups` VALUES ('1', 'owner', 'Owner');
INSERT INTO `sma_groups` VALUES ('2', 'admin', 'Administrator');
INSERT INTO `sma_groups` VALUES ('3', 'customer', 'Customer');
INSERT INTO `sma_groups` VALUES ('4', 'supplier', 'Supplier');
INSERT INTO `sma_groups` VALUES ('5', 'sales', 'Sales Staff');
-- ----------------------------
-- Table structure for sma_login_attempts
-- ----------------------------
DROP TABLE IF EXISTS `sma_login_attempts`;
CREATE TABLE `sma_login_attempts` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`ip_address` varbinary(16) NOT NULL,
`login` varchar(100) NOT NULL,
`time` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_login_attempts
-- ----------------------------
INSERT INTO `sma_login_attempts` VALUES ('2', 0x31342E3234382E3134322E323332, 'owner@tcdiary.com', '1602061251');
INSERT INTO `sma_login_attempts` VALUES ('3', 0x3132332E33312E31382E3137, 'vuquoctrung', '1602064819');
-- ----------------------------
-- Table structure for sma_logs
-- ----------------------------
DROP TABLE IF EXISTS `sma_logs`;
CREATE TABLE `sma_logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`detail` varchar(190) NOT NULL,
`model` longtext,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_logs
-- ----------------------------
-- ----------------------------
-- Table structure for sma_migrations
-- ----------------------------
DROP TABLE IF EXISTS `sma_migrations`;
CREATE TABLE `sma_migrations` (
`version` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_migrations
-- ----------------------------
INSERT INTO `sma_migrations` VALUES ('315');
-- ----------------------------
-- Table structure for sma_notifications
-- ----------------------------
DROP TABLE IF EXISTS `sma_notifications`;
CREATE TABLE `sma_notifications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`comment` text NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`from_date` datetime DEFAULT NULL,
`till_date` datetime DEFAULT NULL,
`scope` tinyint(1) NOT NULL DEFAULT '3',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_notifications
-- ----------------------------
INSERT INTO `sma_notifications` VALUES ('1', '<p>Thank you for purchasing Stock Manager Advance. Please do not forget to check the documentation in help folder. If you find any error/bug, please email to support@tecdiary.com with details. You can send us your valued suggestions/feedback too.</p><p>Please rate Stock Manager Advance on your download page of codecanyon.net</p>', '2014-08-15 06:00:57', '2015-01-01 00:00:00', '2017-01-01 00:00:00', '3');
-- ----------------------------
-- Table structure for sma_order_ref
-- ----------------------------
DROP TABLE IF EXISTS `sma_order_ref`;
CREATE TABLE `sma_order_ref` (
`ref_id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`so` int(11) NOT NULL DEFAULT '1',
`qu` int(11) NOT NULL DEFAULT '1',
`po` int(11) NOT NULL DEFAULT '1',
`to` int(11) NOT NULL DEFAULT '1',
`pos` int(11) NOT NULL DEFAULT '1',
`do` int(11) NOT NULL DEFAULT '1',
`pay` int(11) NOT NULL DEFAULT '1',
`re` int(11) NOT NULL DEFAULT '1',
`rep` int(11) NOT NULL DEFAULT '1',
`ex` int(11) NOT NULL DEFAULT '1',
`ppay` int(11) NOT NULL DEFAULT '1',
`qa` int(11) DEFAULT '1',
PRIMARY KEY (`ref_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_order_ref
-- ----------------------------
INSERT INTO `sma_order_ref` VALUES ('1', '2015-03-01', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1');
-- ----------------------------
-- Table structure for sma_payments
-- ----------------------------
DROP TABLE IF EXISTS `sma_payments`;
CREATE TABLE `sma_payments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`sale_id` int(11) DEFAULT NULL,
`return_id` int(11) DEFAULT NULL,
`purchase_id` int(11) DEFAULT NULL,
`reference_no` varchar(50) NOT NULL,
`transaction_id` varchar(50) DEFAULT NULL,
`paid_by` varchar(20) NOT NULL,
`cheque_no` varchar(20) DEFAULT NULL,
`cc_no` varchar(20) DEFAULT NULL,
`cc_holder` varchar(25) DEFAULT NULL,
`cc_month` varchar(2) DEFAULT NULL,
`cc_year` varchar(4) DEFAULT NULL,
`cc_type` varchar(20) DEFAULT NULL,
`amount` decimal(25,4) NOT NULL,
`currency` varchar(3) DEFAULT NULL,
`created_by` int(11) NOT NULL,
`attachment` varchar(55) DEFAULT NULL,
`type` varchar(20) NOT NULL,
`note` varchar(1000) DEFAULT NULL,
`pos_paid` decimal(25,4) DEFAULT '0.0000',
`pos_balance` decimal(25,4) DEFAULT '0.0000',
`approval_code` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_payments
-- ----------------------------
-- ----------------------------
-- Table structure for sma_paypal
-- ----------------------------
DROP TABLE IF EXISTS `sma_paypal`;
CREATE TABLE `sma_paypal` (
`id` int(11) NOT NULL,
`active` tinyint(4) NOT NULL,
`account_email` varchar(255) NOT NULL,
`paypal_currency` varchar(3) NOT NULL DEFAULT 'USD',
`fixed_charges` decimal(25,4) NOT NULL DEFAULT '2.0000',
`extra_charges_my` decimal(25,4) NOT NULL DEFAULT '3.9000',
`extra_charges_other` decimal(25,4) NOT NULL DEFAULT '4.4000',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_paypal
-- ----------------------------
INSERT INTO `sma_paypal` VALUES ('1', '1', 'mypaypal@paypal.com', 'USD', '0.0000', '0.0000', '0.0000');
-- ----------------------------
-- Table structure for sma_permissions
-- ----------------------------
DROP TABLE IF EXISTS `sma_permissions`;
CREATE TABLE `sma_permissions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL,
`products-index` tinyint(1) DEFAULT '0',
`products-add` tinyint(1) DEFAULT '0',
`products-edit` tinyint(1) DEFAULT '0',
`products-delete` tinyint(1) DEFAULT '0',
`products-cost` tinyint(1) DEFAULT '0',
`products-price` tinyint(1) DEFAULT '0',
`quotes-index` tinyint(1) DEFAULT '0',
`quotes-add` tinyint(1) DEFAULT '0',
`quotes-edit` tinyint(1) DEFAULT '0',
`quotes-pdf` tinyint(1) DEFAULT '0',
`quotes-email` tinyint(1) DEFAULT '0',
`quotes-delete` tinyint(1) DEFAULT '0',
`sales-index` tinyint(1) DEFAULT '0',
`sales-add` tinyint(1) DEFAULT '0',
`sales-edit` tinyint(1) DEFAULT '0',
`sales-pdf` tinyint(1) DEFAULT '0',
`sales-email` tinyint(1) DEFAULT '0',
`sales-delete` tinyint(1) DEFAULT '0',
`purchases-index` tinyint(1) DEFAULT '0',
`purchases-add` tinyint(1) DEFAULT '0',
`purchases-edit` tinyint(1) DEFAULT '0',
`purchases-pdf` tinyint(1) DEFAULT '0',
`purchases-email` tinyint(1) DEFAULT '0',
`purchases-delete` tinyint(1) DEFAULT '0',
`transfers-index` tinyint(1) DEFAULT '0',
`transfers-add` tinyint(1) DEFAULT '0',
`transfers-edit` tinyint(1) DEFAULT '0',
`transfers-pdf` tinyint(1) DEFAULT '0',
`transfers-email` tinyint(1) DEFAULT '0',
`transfers-delete` tinyint(1) DEFAULT '0',
`customers-index` tinyint(1) DEFAULT '0',
`customers-add` tinyint(1) DEFAULT '0',
`customers-edit` tinyint(1) DEFAULT '0',
`customers-delete` tinyint(1) DEFAULT '0',
`suppliers-index` tinyint(1) DEFAULT '0',
`suppliers-add` tinyint(1) DEFAULT '0',
`suppliers-edit` tinyint(1) DEFAULT '0',
`suppliers-delete` tinyint(1) DEFAULT '0',
`sales-deliveries` tinyint(1) DEFAULT '0',
`sales-add_delivery` tinyint(1) DEFAULT '0',
`sales-edit_delivery` tinyint(1) DEFAULT '0',
`sales-delete_delivery` tinyint(1) DEFAULT '0',
`sales-email_delivery` tinyint(1) DEFAULT '0',
`sales-pdf_delivery` tinyint(1) DEFAULT '0',
`sales-gift_cards` tinyint(1) DEFAULT '0',
`sales-add_gift_card` tinyint(1) DEFAULT '0',
`sales-edit_gift_card` tinyint(1) DEFAULT '0',
`sales-delete_gift_card` tinyint(1) DEFAULT '0',
`pos-index` tinyint(1) DEFAULT '0',
`sales-return_sales` tinyint(1) DEFAULT '0',
`reports-index` tinyint(1) DEFAULT '0',
`reports-warehouse_stock` tinyint(1) DEFAULT '0',
`reports-quantity_alerts` tinyint(1) DEFAULT '0',
`reports-expiry_alerts` tinyint(1) DEFAULT '0',
`reports-products` tinyint(1) DEFAULT '0',
`reports-daily_sales` tinyint(1) DEFAULT '0',
`reports-monthly_sales` tinyint(1) DEFAULT '0',
`reports-sales` tinyint(1) DEFAULT '0',
`reports-payments` tinyint(1) DEFAULT '0',
`reports-purchases` tinyint(1) DEFAULT '0',
`reports-profit_loss` tinyint(1) DEFAULT '0',
`reports-customers` tinyint(1) DEFAULT '0',
`reports-suppliers` tinyint(1) DEFAULT '0',
`reports-staff` tinyint(1) DEFAULT '0',
`reports-register` tinyint(1) DEFAULT '0',
`sales-payments` tinyint(1) DEFAULT '0',
`purchases-payments` tinyint(1) DEFAULT '0',
`purchases-expenses` tinyint(1) DEFAULT '0',
`products-adjustments` tinyint(1) NOT NULL DEFAULT '0',
`bulk_actions` tinyint(1) NOT NULL DEFAULT '0',
`customers-deposits` tinyint(1) NOT NULL DEFAULT '0',
`customers-delete_deposit` tinyint(1) NOT NULL DEFAULT '0',
`products-barcode` tinyint(1) NOT NULL DEFAULT '0',
`purchases-return_purchases` tinyint(1) NOT NULL DEFAULT '0',
`reports-expenses` tinyint(1) NOT NULL DEFAULT '0',
`reports-daily_purchases` tinyint(1) DEFAULT '0',
`reports-monthly_purchases` tinyint(1) DEFAULT '0',
`products-stock_count` tinyint(1) DEFAULT '0',
`edit_price` tinyint(1) DEFAULT '0',
`returns-index` tinyint(1) DEFAULT '0',
`returns-add` tinyint(1) DEFAULT '0',
`returns-edit` tinyint(1) DEFAULT '0',
`returns-delete` tinyint(1) DEFAULT '0',
`returns-email` tinyint(1) DEFAULT '0',
`returns-pdf` tinyint(1) DEFAULT '0',
`reports-tax` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_permissions
-- ----------------------------
INSERT INTO `sma_permissions` VALUES ('1', '5', '1', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '0', '1', '1', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '1', '1', '1', '0', '0', '1', '1', '1', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
-- ----------------------------
-- Table structure for sma_pos_register
-- ----------------------------
DROP TABLE IF EXISTS `sma_pos_register`;
CREATE TABLE `sma_pos_register` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` int(11) NOT NULL,
`cash_in_hand` decimal(25,4) NOT NULL,
`status` varchar(10) NOT NULL,
`total_cash` decimal(25,4) DEFAULT NULL,
`total_cheques` int(11) DEFAULT NULL,
`total_cc_slips` int(11) DEFAULT NULL,
`total_cash_submitted` decimal(25,4) DEFAULT NULL,
`total_cheques_submitted` int(11) DEFAULT NULL,
`total_cc_slips_submitted` int(11) DEFAULT NULL,
`note` text,
`closed_at` timestamp NULL DEFAULT NULL,
`transfer_opened_bills` varchar(50) DEFAULT NULL,
`closed_by` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_pos_register
-- ----------------------------
-- ----------------------------
-- Table structure for sma_pos_settings
-- ----------------------------
DROP TABLE IF EXISTS `sma_pos_settings`;
CREATE TABLE `sma_pos_settings` (
`pos_id` int(1) NOT NULL,
`cat_limit` int(11) NOT NULL,
`pro_limit` int(11) NOT NULL,
`default_category` int(11) NOT NULL,
`default_customer` int(11) NOT NULL,
`default_biller` int(11) NOT NULL,
`display_time` varchar(3) NOT NULL DEFAULT 'yes',
`cf_title1` varchar(255) DEFAULT NULL,
`cf_title2` varchar(255) DEFAULT NULL,
`cf_value1` varchar(255) DEFAULT NULL,
`cf_value2` varchar(255) DEFAULT NULL,
`receipt_printer` varchar(55) DEFAULT NULL,
`cash_drawer_codes` varchar(55) DEFAULT NULL,
`focus_add_item` varchar(55) DEFAULT NULL,
`add_manual_product` varchar(55) DEFAULT NULL,
`customer_selection` varchar(55) DEFAULT NULL,
`add_customer` varchar(55) DEFAULT NULL,
`toggle_category_slider` varchar(55) DEFAULT NULL,
`toggle_subcategory_slider` varchar(55) DEFAULT NULL,
`cancel_sale` varchar(55) DEFAULT NULL,
`suspend_sale` varchar(55) DEFAULT NULL,
`print_items_list` varchar(55) DEFAULT NULL,
`finalize_sale` varchar(55) DEFAULT NULL,
`today_sale` varchar(55) DEFAULT NULL,
`open_hold_bills` varchar(55) DEFAULT NULL,
`close_register` varchar(55) DEFAULT NULL,
`keyboard` tinyint(1) NOT NULL,
`pos_printers` varchar(255) DEFAULT NULL,
`java_applet` tinyint(1) NOT NULL,
`product_button_color` varchar(20) NOT NULL DEFAULT 'default',
`tooltips` tinyint(1) DEFAULT '1',
`paypal_pro` tinyint(1) DEFAULT '0',
`stripe` tinyint(1) DEFAULT '0',
`rounding` tinyint(1) DEFAULT '0',
`char_per_line` tinyint(4) DEFAULT '42',
`pin_code` varchar(20) DEFAULT NULL,
`purchase_code` varchar(100) DEFAULT 'purchase_code',
`envato_username` varchar(50) DEFAULT 'envato_username',
`version` varchar(10) DEFAULT '3.4.38',
`after_sale_page` tinyint(1) DEFAULT '0',
`item_order` tinyint(1) DEFAULT '0',
`authorize` tinyint(1) DEFAULT '0',
`toggle_brands_slider` varchar(55) DEFAULT NULL,
`remote_printing` tinyint(1) DEFAULT '1',
`printer` int(11) DEFAULT NULL,
`order_printers` varchar(55) DEFAULT NULL,
`auto_print` tinyint(1) DEFAULT '0',
`customer_details` tinyint(1) DEFAULT NULL,
`local_printers` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`pos_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_pos_settings
-- ----------------------------
INSERT INTO `sma_pos_settings` VALUES ('1', '22', '20', '1', '1', '3', '1', 'GST Reg', 'VAT Reg', '123456789', '987654321', 'BIXOLON SRP-350II', 'x1C', 'Ctrl+F3', 'Ctrl+Shift+M', 'Ctrl+Shift+C', 'Ctrl+Shift+A', 'Ctrl+F11', 'Ctrl+F12', 'F4', 'F7', 'F9', 'F8', 'Ctrl+F1', 'Ctrl+F2', 'Ctrl+F10', '1', 'BIXOLON SRP-350II, BIXOLON SRP-350II', '0', 'default', '1', '0', '0', '0', '42', null, 'purchase_code', 'envato_username', '3.4.38', '0', '0', '0', null, '1', null, null, '0', null, null);
-- ----------------------------
-- Table structure for sma_price_groups
-- ----------------------------
DROP TABLE IF EXISTS `sma_price_groups`;
CREATE TABLE `sma_price_groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_price_groups
-- ----------------------------
INSERT INTO `sma_price_groups` VALUES ('1', 'Default');
-- ----------------------------
-- Table structure for sma_printers
-- ----------------------------
DROP TABLE IF EXISTS `sma_printers`;
CREATE TABLE `sma_printers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(55) NOT NULL,
`type` varchar(25) NOT NULL,
`profile` varchar(25) NOT NULL,
`char_per_line` tinyint(3) unsigned DEFAULT NULL,
`path` varchar(255) DEFAULT NULL,
`ip_address` varbinary(45) DEFAULT NULL,
`port` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_printers
-- ----------------------------
-- ----------------------------
-- Table structure for sma_products
-- ----------------------------
DROP TABLE IF EXISTS `sma_products`;
CREATE TABLE `sma_products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(50) NOT NULL,
`name` varchar(255) NOT NULL,
`unit` int(11) DEFAULT NULL,
`cost` decimal(25,4) DEFAULT NULL,
`price` decimal(25,4) NOT NULL,
`alert_quantity` decimal(15,4) DEFAULT '20.0000',
`image` varchar(255) DEFAULT 'no_image.png',
`category_id` int(11) NOT NULL,
`subcategory_id` int(11) DEFAULT NULL,
`cf1` varchar(255) DEFAULT NULL,
`cf2` varchar(255) DEFAULT NULL,
`cf3` varchar(255) DEFAULT NULL,
`cf4` varchar(255) DEFAULT NULL,
`cf5` varchar(255) DEFAULT NULL,
`cf6` varchar(255) DEFAULT NULL,
`quantity` decimal(15,4) DEFAULT '0.0000',
`tax_rate` int(11) DEFAULT NULL,
`track_quantity` tinyint(1) DEFAULT '1',
`details` varchar(1000) DEFAULT NULL,
`warehouse` int(11) DEFAULT NULL,
`barcode_symbology` varchar(55) NOT NULL DEFAULT 'code128',
`file` varchar(100) DEFAULT NULL,
`product_details` text,
`tax_method` tinyint(1) DEFAULT '0',
`type` varchar(55) NOT NULL DEFAULT 'standard',
`supplier1` int(11) DEFAULT NULL,
`supplier1price` decimal(25,4) DEFAULT NULL,
`supplier2` int(11) DEFAULT NULL,
`supplier2price` decimal(25,4) DEFAULT NULL,
`supplier3` int(11) DEFAULT NULL,
`supplier3price` decimal(25,4) DEFAULT NULL,
`supplier4` int(11) DEFAULT NULL,
`supplier4price` decimal(25,4) DEFAULT NULL,
`supplier5` int(11) DEFAULT NULL,
`supplier5price` decimal(25,4) DEFAULT NULL,
`promotion` tinyint(1) DEFAULT '0',
`promo_price` decimal(25,4) DEFAULT NULL,
`start_date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`supplier1_part_no` varchar(50) DEFAULT NULL,
`supplier2_part_no` varchar(50) DEFAULT NULL,
`supplier3_part_no` varchar(50) DEFAULT NULL,
`supplier4_part_no` varchar(50) DEFAULT NULL,
`supplier5_part_no` varchar(50) DEFAULT NULL,
`sale_unit` int(11) DEFAULT NULL,
`purchase_unit` int(11) DEFAULT NULL,
`brand` int(11) DEFAULT NULL,
`slug` varchar(55) DEFAULT NULL,
`featured` tinyint(1) DEFAULT NULL,
`weight` decimal(10,4) DEFAULT NULL,
`hsn_code` int(11) DEFAULT NULL,
`views` int(11) NOT NULL DEFAULT '0',
`hide` tinyint(1) NOT NULL DEFAULT '0',
`second_name` varchar(255) DEFAULT NULL,
`hide_pos` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `code` (`code`),
KEY `category_id` (`category_id`),
KEY `id` (`id`),
KEY `id_2` (`id`),
KEY `category_id_2` (`category_id`),
KEY `unit` (`unit`),
KEY `brand` (`brand`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_products
-- ----------------------------
INSERT INTO `sma_products` VALUES ('1', '6970740900936', 'Kính mắt Xiaomi', '1', '480000.0000', '490000.0000', '0.0000', 'no_image.png', '1', null, '', '', '', '', '', '', null, null, '0', '', null, 'code128', '6b5dcf249eaeb4e67a8d951c40553302.jpg', '', null, 'standard', '4', '480000.0000', null, null, null, null, null, null, null, null, null, null, null, null, '10', null, null, null, null, '1', '1', '0', 'kinh-mat-xiaomi', null, '200.0000', null, '0', '0', 'ts sm011-0220', '0');
INSERT INTO `sma_products` VALUES ('2', '33438916', 'Test sp type dịch vụ', '1', '200000.0000', '280000.0000', '10.0000', '4b80b501f0fff189f93de5308bc83b2a.jpg', '1', null, 'Product Custom Field', 'Product Custom Field', 'Product Custom Field', 'Product Custom Field', 'Product Custom Field', 'Product Custom Field', null, null, '1', '<p>fsdfsdf</p>', null, 'code128', '', '<p>fsdfsfsdfdsfd</p>', null, 'standard', '4', '180000.0000', '0', null, '0', null, null, null, null, null, '1', '260000.0000', '2020-10-08', '2020-10-15', 'abc', '', '', null, null, '1', '1', '1', 'test-sp-type-dich-vu', '1', '1.0000', null, '0', '1', 'Test sp type dịch vụ ', '0');
INSERT INTO `sma_products` VALUES ('3', '68830816', 'Test 3', null, null, '980000.0000', '0.0000', '5bce1c90dba81a1ccc6c08e27d5a6e39.png', '1', null, 'Product Custom Field 1', 'Product Custom Field 1', 'Product Custom Field 1', 'Product Custom Field 1', 'Product Custom Field 1', 'Product Custom Field 1', null, null, '0', '<p>Product Custom Field 1</p>', null, 'code128', '', '<p>Product Custom Field 1</p>', null, 'combo', '0', null, null, null, null, null, null, null, null, null, null, null, null, null, '', null, null, null, null, '0', '0', '1', '68830816', '1', '1.0000', null, '0', '1', 'Test 3', '0');
-- ----------------------------
-- Table structure for sma_product_photos
-- ----------------------------
DROP TABLE IF EXISTS `sma_product_photos`;
CREATE TABLE `sma_product_photos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`photo` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_product_photos
-- ----------------------------
INSERT INTO `sma_product_photos` VALUES ('1', '2', 'bc98ccfbf3bd9346462f58ced36c489d.jpg');
INSERT INTO `sma_product_photos` VALUES ('2', '3', '866a7094201a306d57a0f639b63c7803.jpg');
-- ----------------------------
-- Table structure for sma_product_prices
-- ----------------------------
DROP TABLE IF EXISTS `sma_product_prices`;
CREATE TABLE `sma_product_prices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`price_group_id` int(11) NOT NULL,
`price` decimal(25,4) NOT NULL,
PRIMARY KEY (`id`),
KEY `product_id` (`product_id`),
KEY `price_group_id` (`price_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_product_prices
-- ----------------------------
-- ----------------------------
-- Table structure for sma_product_variants
-- ----------------------------
DROP TABLE IF EXISTS `sma_product_variants`;
CREATE TABLE `sma_product_variants` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`name` varchar(55) NOT NULL,
`cost` decimal(25,4) DEFAULT NULL,
`price` decimal(25,4) DEFAULT NULL,
`quantity` decimal(15,4) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_product_id_name` (`product_id`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_product_variants
-- ----------------------------
INSERT INTO `sma_product_variants` VALUES ('1', '2', 'X', null, '0.0000', null);
INSERT INTO `sma_product_variants` VALUES ('2', '2', 'đỏ', null, '0.0000', null);
INSERT INTO `sma_product_variants` VALUES ('3', '2', 'vàng', null, '0.0000', null);
INSERT INTO `sma_product_variants` VALUES ('4', '2', 'đen', null, '0.0000', null);
-- ----------------------------
-- Table structure for sma_promos
-- ----------------------------
DROP TABLE IF EXISTS `sma_promos`;
CREATE TABLE `sma_promos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`product2buy` int(11) NOT NULL,
`product2get` int(11) NOT NULL,
`start_date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`description` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_promos
-- ----------------------------
-- ----------------------------
-- Table structure for sma_purchases
-- ----------------------------
DROP TABLE IF EXISTS `sma_purchases`;
CREATE TABLE `sma_purchases` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`reference_no` varchar(55) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`supplier_id` int(11) NOT NULL,
`supplier` varchar(55) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`note` varchar(1000) NOT NULL,
`total` decimal(25,4) DEFAULT NULL,
`product_discount` decimal(25,4) DEFAULT NULL,
`order_discount_id` varchar(20) DEFAULT NULL,
`order_discount` decimal(25,4) DEFAULT NULL,
`total_discount` decimal(25,4) DEFAULT NULL,
`product_tax` decimal(25,4) DEFAULT NULL,
`order_tax_id` int(11) DEFAULT NULL,
`order_tax` decimal(25,4) DEFAULT NULL,
`total_tax` decimal(25,4) DEFAULT '0.0000',
`shipping` decimal(25,4) DEFAULT '0.0000',
`grand_total` decimal(25,4) NOT NULL,
`paid` decimal(25,4) NOT NULL DEFAULT '0.0000',
`status` varchar(55) DEFAULT '',
`payment_status` varchar(20) DEFAULT 'pending',
`created_by` int(11) DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`attachment` varchar(55) DEFAULT NULL,
`payment_term` tinyint(4) DEFAULT NULL,
`due_date` date DEFAULT NULL,
`return_id` int(11) DEFAULT NULL,
`surcharge` decimal(25,4) NOT NULL DEFAULT '0.0000',
`return_purchase_ref` varchar(55) DEFAULT NULL,
`purchase_id` int(11) DEFAULT NULL,
`return_purchase_total` decimal(25,4) NOT NULL DEFAULT '0.0000',
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_purchases
-- ----------------------------
-- ----------------------------
-- Table structure for sma_purchase_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_purchase_items`;
CREATE TABLE `sma_purchase_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`purchase_id` int(11) DEFAULT NULL,
`transfer_id` int(11) DEFAULT NULL,
`product_id` int(11) NOT NULL,
`product_code` varchar(50) NOT NULL,
`product_name` varchar(255) NOT NULL,
`option_id` int(11) DEFAULT NULL,
`net_unit_cost` decimal(25,4) NOT NULL,
`quantity` decimal(15,4) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`item_tax` decimal(25,4) DEFAULT NULL,
`tax_rate_id` int(11) DEFAULT NULL,
`tax` varchar(20) DEFAULT NULL,
`discount` varchar(20) DEFAULT NULL,
`item_discount` decimal(25,4) DEFAULT NULL,
`expiry` date DEFAULT NULL,
`subtotal` decimal(25,4) NOT NULL,
`quantity_balance` decimal(15,4) DEFAULT '0.0000',
`date` date NOT NULL,
`status` varchar(50) NOT NULL,
`unit_cost` decimal(25,4) DEFAULT NULL,
`real_unit_cost` decimal(25,4) DEFAULT NULL,
`quantity_received` decimal(15,4) DEFAULT NULL,
`supplier_part_no` varchar(50) DEFAULT NULL,
`purchase_item_id` int(11) DEFAULT NULL,
`product_unit_id` int(11) DEFAULT NULL,
`product_unit_code` varchar(10) DEFAULT NULL,
`unit_quantity` decimal(15,4) NOT NULL,
`gst` varchar(20) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
`base_unit_cost` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `purchase_id` (`purchase_id`),
KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_purchase_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_quotes
-- ----------------------------
DROP TABLE IF EXISTS `sma_quotes`;
CREATE TABLE `sma_quotes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`reference_no` varchar(55) NOT NULL,
`customer_id` int(11) NOT NULL,
`customer` varchar(55) NOT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`biller_id` int(11) NOT NULL,
`biller` varchar(55) NOT NULL,
`note` varchar(1000) DEFAULT NULL,
`internal_note` varchar(1000) DEFAULT NULL,
`total` decimal(25,4) NOT NULL,
`product_discount` decimal(25,4) DEFAULT '0.0000',
`order_discount` decimal(25,4) DEFAULT NULL,
`order_discount_id` varchar(20) DEFAULT NULL,
`total_discount` decimal(25,4) DEFAULT '0.0000',
`product_tax` decimal(25,4) DEFAULT '0.0000',
`order_tax_id` int(11) DEFAULT NULL,
`order_tax` decimal(25,4) DEFAULT NULL,
`total_tax` decimal(25,4) DEFAULT NULL,
`shipping` decimal(25,4) DEFAULT '0.0000',
`grand_total` decimal(25,4) NOT NULL,
`status` varchar(20) DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`attachment` varchar(55) DEFAULT NULL,
`supplier_id` int(11) DEFAULT NULL,
`supplier` varchar(55) DEFAULT NULL,
`hash` varchar(255) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_quotes
-- ----------------------------
-- ----------------------------
-- Table structure for sma_quote_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_quote_items`;
CREATE TABLE `sma_quote_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`quote_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`product_code` varchar(55) NOT NULL,
`product_name` varchar(255) NOT NULL,
`product_type` varchar(20) DEFAULT NULL,
`option_id` int(11) DEFAULT NULL,
`net_unit_price` decimal(25,4) NOT NULL,
`unit_price` decimal(25,4) DEFAULT NULL,
`quantity` decimal(15,4) NOT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`item_tax` decimal(25,4) DEFAULT NULL,
`tax_rate_id` int(11) DEFAULT NULL,
`tax` varchar(55) DEFAULT NULL,
`discount` varchar(55) DEFAULT NULL,
`item_discount` decimal(25,4) DEFAULT NULL,
`subtotal` decimal(25,4) NOT NULL,
`serial_no` varchar(255) DEFAULT NULL,
`real_unit_price` decimal(25,4) DEFAULT NULL,
`product_unit_id` int(11) DEFAULT NULL,
`product_unit_code` varchar(10) DEFAULT NULL,
`unit_quantity` decimal(15,4) NOT NULL,
`gst` varchar(20) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `quote_id` (`quote_id`),
KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_quote_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_returns
-- ----------------------------
DROP TABLE IF EXISTS `sma_returns`;
CREATE TABLE `sma_returns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`reference_no` varchar(55) NOT NULL,
`customer_id` int(11) NOT NULL,
`customer` varchar(55) NOT NULL,
`biller_id` int(11) NOT NULL,
`biller` varchar(55) NOT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`note` varchar(1000) DEFAULT NULL,
`staff_note` varchar(1000) DEFAULT NULL,
`total` decimal(25,4) NOT NULL,
`product_discount` decimal(25,4) DEFAULT '0.0000',
`order_discount_id` varchar(20) DEFAULT NULL,
`total_discount` decimal(25,4) DEFAULT '0.0000',
`order_discount` decimal(25,4) DEFAULT '0.0000',
`product_tax` decimal(25,4) DEFAULT '0.0000',
`order_tax_id` int(11) DEFAULT NULL,
`order_tax` decimal(25,4) DEFAULT '0.0000',
`total_tax` decimal(25,4) DEFAULT '0.0000',
`grand_total` decimal(25,4) NOT NULL,
`created_by` int(11) DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`total_items` smallint(6) DEFAULT NULL,
`paid` decimal(25,4) DEFAULT '0.0000',
`surcharge` decimal(25,4) NOT NULL DEFAULT '0.0000',
`attachment` varchar(55) DEFAULT NULL,
`hash` varchar(255) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
`shipping` decimal(25,4) DEFAULT '0.0000',
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_returns
-- ----------------------------
-- ----------------------------
-- Table structure for sma_return_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_return_items`;
CREATE TABLE `sma_return_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`return_id` int(11) unsigned NOT NULL,
`product_id` int(11) unsigned NOT NULL,
`product_code` varchar(55) NOT NULL,
`product_name` varchar(255) NOT NULL,
`product_type` varchar(20) DEFAULT NULL,
`option_id` int(11) DEFAULT NULL,
`net_unit_price` decimal(25,4) NOT NULL,
`unit_price` decimal(25,4) DEFAULT NULL,
`quantity` decimal(15,4) NOT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`item_tax` decimal(25,4) DEFAULT NULL,
`tax_rate_id` int(11) DEFAULT NULL,
`tax` varchar(55) DEFAULT NULL,
`discount` varchar(55) DEFAULT NULL,
`item_discount` decimal(25,4) DEFAULT NULL,
`subtotal` decimal(25,4) NOT NULL,
`serial_no` varchar(255) DEFAULT NULL,
`real_unit_price` decimal(25,4) DEFAULT NULL,
`product_unit_id` int(11) DEFAULT NULL,
`product_unit_code` varchar(10) DEFAULT NULL,
`unit_quantity` decimal(15,4) NOT NULL,
`comment` varchar(255) DEFAULT NULL,
`gst` varchar(20) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `return_id` (`return_id`),
KEY `product_id` (`product_id`),
KEY `product_id_2` (`product_id`,`return_id`),
KEY `return_id_2` (`return_id`,`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_return_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_sales
-- ----------------------------
DROP TABLE IF EXISTS `sma_sales`;
CREATE TABLE `sma_sales` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`reference_no` varchar(55) NOT NULL,
`customer_id` int(11) NOT NULL,
`customer` varchar(55) NOT NULL,
`biller_id` int(11) NOT NULL,
`biller` varchar(55) NOT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`note` varchar(1000) DEFAULT NULL,
`staff_note` varchar(1000) DEFAULT NULL,
`total` decimal(25,4) NOT NULL,
`product_discount` decimal(25,4) DEFAULT '0.0000',
`order_discount_id` varchar(20) DEFAULT NULL,
`total_discount` decimal(25,4) DEFAULT '0.0000',
`order_discount` decimal(25,4) DEFAULT '0.0000',
`product_tax` decimal(25,4) DEFAULT '0.0000',
`order_tax_id` int(11) DEFAULT NULL,
`order_tax` decimal(25,4) DEFAULT '0.0000',
`total_tax` decimal(25,4) DEFAULT '0.0000',
`shipping` decimal(25,4) DEFAULT '0.0000',
`grand_total` decimal(25,4) NOT NULL,
`sale_status` varchar(20) DEFAULT NULL,
`payment_status` varchar(20) DEFAULT NULL,
`payment_term` tinyint(4) DEFAULT NULL,
`due_date` date DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`updated_by` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`total_items` smallint(6) DEFAULT NULL,
`pos` tinyint(1) NOT NULL DEFAULT '0',
`paid` decimal(25,4) DEFAULT '0.0000',
`return_id` int(11) DEFAULT NULL,
`surcharge` decimal(25,4) NOT NULL DEFAULT '0.0000',
`attachment` varchar(55) DEFAULT NULL,
`return_sale_ref` varchar(55) DEFAULT NULL,
`sale_id` int(11) DEFAULT NULL,
`return_sale_total` decimal(25,4) NOT NULL DEFAULT '0.0000',
`rounding` decimal(10,4) DEFAULT NULL,
`suspend_note` varchar(255) DEFAULT NULL,
`api` tinyint(1) DEFAULT '0',
`shop` tinyint(1) DEFAULT '0',
`address_id` int(11) DEFAULT NULL,
`reserve_id` int(11) DEFAULT NULL,
`hash` varchar(255) DEFAULT NULL,
`manual_payment` varchar(55) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
`payment_method` varchar(55) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_sales
-- ----------------------------
-- ----------------------------
-- Table structure for sma_sale_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_sale_items`;
CREATE TABLE `sma_sale_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sale_id` int(11) unsigned NOT NULL,
`product_id` int(11) unsigned NOT NULL,
`product_code` varchar(55) NOT NULL,
`product_name` varchar(255) NOT NULL,
`product_type` varchar(20) DEFAULT NULL,
`option_id` int(11) DEFAULT NULL,
`net_unit_price` decimal(25,4) NOT NULL,
`unit_price` decimal(25,4) DEFAULT NULL,
`quantity` decimal(15,4) NOT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`item_tax` decimal(25,4) DEFAULT NULL,
`tax_rate_id` int(11) DEFAULT NULL,
`tax` varchar(55) DEFAULT NULL,
`discount` varchar(55) DEFAULT NULL,
`item_discount` decimal(25,4) DEFAULT NULL,
`subtotal` decimal(25,4) NOT NULL,
`serial_no` varchar(255) DEFAULT NULL,
`real_unit_price` decimal(25,4) DEFAULT NULL,
`sale_item_id` int(11) DEFAULT NULL,
`product_unit_id` int(11) DEFAULT NULL,
`product_unit_code` varchar(10) DEFAULT NULL,
`unit_quantity` decimal(15,4) NOT NULL,
`comment` varchar(255) DEFAULT NULL,
`gst` varchar(20) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `sale_id` (`sale_id`),
KEY `product_id` (`product_id`),
KEY `product_id_2` (`product_id`,`sale_id`),
KEY `sale_id_2` (`sale_id`,`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_sale_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_sessions
-- ----------------------------
DROP TABLE IF EXISTS `sma_sessions`;
CREATE TABLE `sma_sessions` (
`id` varchar(40) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned NOT NULL DEFAULT '0',
`data` blob NOT NULL,
PRIMARY KEY (`id`),
KEY `ci_sessions_timestamp` (`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_sessions
-- ----------------------------
INSERT INTO `sma_sessions` VALUES ('3jdb1uct6bump3040v0ud4bbd6ks9mab', '::1', '1602240858', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323234303835373B7265717565737465645F706167657C733A32313A2261646D696E2F70726F64756374732F656469742F32223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032313432353639223B6C6173745F69707C733A333A223A3A31223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('4229a785dc3a56cd81aa25bfa8b85944102c368a', '42.114.191.197', '1602142313', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323134323234303B7265717565737465645F706167657C733A31383A2261646D696E2F70726F64756374732F616464223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032313234333732223B6C6173745F69707C733A31343A2231342E3234382E3134322E323332223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('46d856085126ab312faf98286644a532cacf3af2', '42.114.191.197', '1602141517', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323134313531373B7265717565737465645F706167657C733A31383A2261646D696E2F70726F64756374732F616464223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032313234333732223B6C6173745F69707C733A31343A2231342E3234382E3134322E323332223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('60ireeh00s8qpogr74mdriibkps4vae9', '::1', '1602411004', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323431313030333B7265717565737465645F706167657C733A32313A2261646D696E2F70726F64756374732F656469742F32223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032333930383938223B6C6173745F69707C733A333A223A3A31223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('7f8494b7c6f514593b0f55980ad4521b9d6e0509', '42.114.191.197', '1602142240', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323134323234303B7265717565737465645F706167657C733A31383A2261646D696E2F70726F64756374732F616464223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032313234333732223B6C6173745F69707C733A31343A2231342E3234382E3134322E323332223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('84r8jh6ogbi3259da0b098mgr6rhkedi', '::1', '1602261095', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323236313039343B7265717565737465645F706167657C733A32313A2261646D696E2F70726F64756374732F656469742F32223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032323430383537223B6C6173745F69707C733A333A223A3A31223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('c5da2dea2dfbdd4f40a40720104b71876bce9f02', '42.114.191.197', '1602141916', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323134313931363B7265717565737465645F706167657C733A31383A2261646D696E2F70726F64756374732F616464223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032313234333732223B6C6173745F69707C733A31343A2231342E3234382E3134322E323332223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('ce27f3084b38bb7ca2ef891a90aa70d91eaf78e5', '42.114.191.197', '1602140951', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323134303935313B7265717565737465645F706167657C733A31383A2261646D696E2F70726F64756374732F616464223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032313234333732223B6C6173745F69707C733A31343A2231342E3234382E3134322E323332223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('d6e5b85b98020a195f5f746e885879a15a795751', '139.99.8.123', '1602142094', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323134323039343B7265717565737465645F706167657C733A353A2261646D696E223B);
INSERT INTO `sma_sessions` VALUES ('ip28vhrh6tq8k96oo2ammimebu19uepn', '::1', '1602390898', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323339303839383B7265717565737465645F706167657C733A32313A2261646D696E2F70726F64756374732F656469742F32223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032323631303934223B6C6173745F69707C733A333A223A3A31223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
INSERT INTO `sma_sessions` VALUES ('ukh513ubu4qhih15dtpl3tku47qtfkjh', '::1', '1602142744', 0x5F5F63695F6C6173745F726567656E65726174657C693A313630323134323534343B7265717565737465645F706167657C733A353A2261646D696E223B6964656E746974797C733A31383A226F776E65724074656364696172792E636F6D223B757365726E616D657C733A353A226F776E6572223B656D61696C7C733A31383A226F776E65724074656364696172792E636F6D223B757365725F69647C733A313A2231223B6F6C645F6C6173745F6C6F67696E7C733A31303A2231363032313430363330223B6C6173745F69707C733A31343A2234322E3131342E3139312E313937223B6176617461727C4E3B67656E6465727C733A343A226D616C65223B67726F75705F69647C733A313A2231223B77617265686F7573655F69647C4E3B766965775F72696768747C733A313A2230223B656469745F72696768747C733A313A2230223B616C6C6F775F646973636F756E747C733A313A2230223B62696C6C65725F69647C4E3B636F6D70616E795F69647C4E3B73686F775F636F73747C733A313A2230223B73686F775F70726963657C733A313A2230223B);
-- ----------------------------
-- Table structure for sma_settings
-- ----------------------------
DROP TABLE IF EXISTS `sma_settings`;
CREATE TABLE `sma_settings` (
`setting_id` int(1) NOT NULL,
`logo` varchar(255) NOT NULL,
`logo2` varchar(255) NOT NULL,
`site_name` varchar(55) NOT NULL,
`language` varchar(20) NOT NULL,
`default_warehouse` int(2) NOT NULL,
`accounting_method` tinyint(4) NOT NULL DEFAULT '0',
`default_currency` varchar(3) NOT NULL,
`default_tax_rate` int(2) NOT NULL,
`rows_per_page` int(2) NOT NULL,
`version` varchar(10) NOT NULL DEFAULT '1.0',
`default_tax_rate2` int(11) NOT NULL DEFAULT '0',
`dateformat` int(11) NOT NULL,
`sales_prefix` varchar(20) DEFAULT NULL,
`quote_prefix` varchar(20) DEFAULT NULL,
`purchase_prefix` varchar(20) DEFAULT NULL,
`transfer_prefix` varchar(20) DEFAULT NULL,
`delivery_prefix` varchar(20) DEFAULT NULL,
`payment_prefix` varchar(20) DEFAULT NULL,
`return_prefix` varchar(20) DEFAULT NULL,
`returnp_prefix` varchar(20) DEFAULT NULL,
`expense_prefix` varchar(20) DEFAULT NULL,
`item_addition` tinyint(1) NOT NULL DEFAULT '0',
`theme` varchar(20) NOT NULL,
`product_serial` tinyint(4) NOT NULL,
`default_discount` int(11) NOT NULL,
`product_discount` tinyint(1) NOT NULL DEFAULT '0',
`discount_method` tinyint(4) NOT NULL,
`tax1` tinyint(4) NOT NULL,
`tax2` tinyint(4) NOT NULL,
`overselling` tinyint(1) NOT NULL DEFAULT '0',
`restrict_user` tinyint(4) NOT NULL DEFAULT '0',
`restrict_calendar` tinyint(4) NOT NULL DEFAULT '0',
`timezone` varchar(100) DEFAULT NULL,
`iwidth` int(11) NOT NULL DEFAULT '0',
`iheight` int(11) NOT NULL,
`twidth` int(11) NOT NULL,
`theight` int(11) NOT NULL,
`watermark` tinyint(1) DEFAULT NULL,
`reg_ver` tinyint(1) DEFAULT NULL,
`allow_reg` tinyint(1) DEFAULT NULL,
`reg_notification` tinyint(1) DEFAULT NULL,
`auto_reg` tinyint(1) DEFAULT NULL,
`protocol` varchar(20) NOT NULL DEFAULT 'mail',
`mailpath` varchar(55) DEFAULT '/usr/sbin/sendmail',
`smtp_host` varchar(100) DEFAULT NULL,
`smtp_user` varchar(100) DEFAULT NULL,
`smtp_pass` varchar(255) DEFAULT NULL,
`smtp_port` varchar(10) DEFAULT '25',
`smtp_crypto` varchar(10) DEFAULT NULL,
`corn` datetime DEFAULT NULL,
`customer_group` int(11) NOT NULL,
`default_email` varchar(100) NOT NULL,
`mmode` tinyint(1) NOT NULL,
`bc_fix` tinyint(4) NOT NULL DEFAULT '0',
`auto_detect_barcode` tinyint(1) NOT NULL DEFAULT '0',
`captcha` tinyint(1) NOT NULL DEFAULT '1',
`reference_format` tinyint(1) NOT NULL DEFAULT '1',
`racks` tinyint(1) DEFAULT '0',
`attributes` tinyint(1) NOT NULL DEFAULT '0',
`product_expiry` tinyint(1) NOT NULL DEFAULT '0',
`decimals` tinyint(2) NOT NULL DEFAULT '2',
`qty_decimals` tinyint(2) NOT NULL DEFAULT '2',
`decimals_sep` varchar(2) NOT NULL DEFAULT '.',
`thousands_sep` varchar(2) NOT NULL DEFAULT ',',
`invoice_view` tinyint(1) DEFAULT '0',
`default_biller` int(11) DEFAULT NULL,
`envato_username` varchar(50) DEFAULT NULL,
`purchase_code` varchar(100) DEFAULT NULL,
`rtl` tinyint(1) DEFAULT '0',
`each_spent` decimal(15,4) DEFAULT NULL,
`ca_point` tinyint(4) DEFAULT NULL,
`each_sale` decimal(15,4) DEFAULT NULL,
`sa_point` tinyint(4) DEFAULT NULL,
`update` tinyint(1) DEFAULT '0',
`sac` tinyint(1) DEFAULT '0',
`display_all_products` tinyint(1) DEFAULT '0',
`display_symbol` tinyint(1) DEFAULT NULL,
`symbol` varchar(50) DEFAULT NULL,
`remove_expired` tinyint(1) DEFAULT '0',
`barcode_separator` varchar(2) NOT NULL DEFAULT '-',
`set_focus` tinyint(1) NOT NULL DEFAULT '0',
`price_group` int(11) DEFAULT NULL,
`barcode_img` tinyint(1) NOT NULL DEFAULT '1',
`ppayment_prefix` varchar(20) DEFAULT 'POP',
`disable_editing` smallint(6) DEFAULT '90',
`qa_prefix` varchar(55) DEFAULT NULL,
`update_cost` tinyint(1) DEFAULT NULL,
`apis` tinyint(1) NOT NULL DEFAULT '0',
`state` varchar(100) DEFAULT NULL,
`pdf_lib` varchar(20) DEFAULT 'dompdf',
`use_code_for_slug` tinyint(1) DEFAULT NULL,
`ws_barcode_type` varchar(10) DEFAULT 'weight',
`ws_barcode_chars` tinyint(4) DEFAULT NULL,
`flag_chars` tinyint(4) DEFAULT NULL,
`item_code_start` tinyint(4) DEFAULT NULL,
`item_code_chars` tinyint(4) DEFAULT NULL,
`price_start` tinyint(4) DEFAULT NULL,
`price_chars` tinyint(4) DEFAULT NULL,
`price_divide_by` int(11) DEFAULT NULL,
`weight_start` tinyint(4) DEFAULT NULL,
`weight_chars` tinyint(4) DEFAULT NULL,
`weight_divide_by` int(11) DEFAULT NULL,
PRIMARY KEY (`setting_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_settings
-- ----------------------------
INSERT INTO `sma_settings` VALUES ('1', 'logo2.png', 'logo3.png', 'Stock Manager Advance', 'vietnamese', '3', '0', 'VND', '0', '10', '3.4.38', '1', '5', 'SALE', 'QUOTE', 'PO', 'TR', 'DO', 'IPAY', 'SR', 'PR', '', '0', 'default', '1', '1', '1', '1', '0', '1', '0', '1', '0', 'Asia/Ho_Chi_Minh', '800', '800', '150', '150', '1', '0', '0', '0', null, 'mail', '/usr/sbin/sendmail', 'pop.gmail.com', 'contact@sma.tecdiary.org', 'jEFTM4T63AiQ9dsidxhPKt9CIg4HQjCN58n/RW9vmdC/UDXCzRLR469ziZ0jjpFlbOg43LyoSmpJLBkcAHh0Yw==', '25', null, null, '1', 'contact@tecdiary.com', '0', '4', '1', '0', '2', '0', '0', '0', '2', '2', '.', ',', '0', '3', 'vuquoctrungbk', '9551b330-b8bf-431b-8c03-32749d4c221d', '0', null, null, null, null, '0', '0', '1', '0', '', '0', '-', '0', '1', '1', 'POP', '90', '', '0', '0', 'AN', 'dompdf', '0', 'weight', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
-- ----------------------------
-- Table structure for sma_skrill
-- ----------------------------
DROP TABLE IF EXISTS `sma_skrill`;
CREATE TABLE `sma_skrill` (
`id` int(11) NOT NULL,
`active` tinyint(4) NOT NULL,
`account_email` varchar(255) NOT NULL DEFAULT 'testaccount2@moneybookers.com',
`secret_word` varchar(20) NOT NULL DEFAULT 'mbtest',
`skrill_currency` varchar(3) NOT NULL DEFAULT 'USD',
`fixed_charges` decimal(25,4) NOT NULL DEFAULT '0.0000',
`extra_charges_my` decimal(25,4) NOT NULL DEFAULT '0.0000',
`extra_charges_other` decimal(25,4) NOT NULL DEFAULT '0.0000',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_skrill
-- ----------------------------
INSERT INTO `sma_skrill` VALUES ('1', '1', 'testaccount2@moneybookers.com', 'mbtest', 'USD', '0.0000', '0.0000', '0.0000');
-- ----------------------------
-- Table structure for sma_stock_counts
-- ----------------------------
DROP TABLE IF EXISTS `sma_stock_counts`;
CREATE TABLE `sma_stock_counts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`reference_no` varchar(55) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`type` varchar(10) NOT NULL,
`initial_file` varchar(50) NOT NULL,
`final_file` varchar(50) DEFAULT NULL,
`brands` varchar(50) DEFAULT NULL,
`brand_names` varchar(100) DEFAULT NULL,
`categories` varchar(50) DEFAULT NULL,
`category_names` varchar(100) DEFAULT NULL,
`note` text,
`products` int(11) DEFAULT NULL,
`rows` int(11) DEFAULT NULL,
`differences` int(11) DEFAULT NULL,
`matches` int(11) DEFAULT NULL,
`missing` int(11) DEFAULT NULL,
`created_by` int(11) NOT NULL,
`updated_by` int(11) DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`finalized` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `warehouse_id` (`warehouse_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_stock_counts
-- ----------------------------
-- ----------------------------
-- Table structure for sma_stock_count_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_stock_count_items`;
CREATE TABLE `sma_stock_count_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`stock_count_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`product_code` varchar(50) DEFAULT NULL,
`product_name` varchar(255) DEFAULT NULL,
`product_variant` varchar(55) DEFAULT NULL,
`product_variant_id` int(11) DEFAULT NULL,
`expected` decimal(15,4) NOT NULL,
`counted` decimal(15,4) NOT NULL,
`cost` decimal(25,4) NOT NULL,
PRIMARY KEY (`id`),
KEY `stock_count_id` (`stock_count_id`),
KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_stock_count_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_suspended_bills
-- ----------------------------
DROP TABLE IF EXISTS `sma_suspended_bills`;
CREATE TABLE `sma_suspended_bills` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`customer_id` int(11) NOT NULL,
`customer` varchar(55) DEFAULT NULL,
`count` int(11) NOT NULL,
`order_discount_id` varchar(20) DEFAULT NULL,
`order_tax_id` int(11) DEFAULT NULL,
`total` decimal(25,4) NOT NULL,
`biller_id` int(11) DEFAULT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`created_by` int(11) NOT NULL,
`suspend_note` varchar(255) DEFAULT NULL,
`shipping` decimal(15,4) DEFAULT '0.0000',
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_suspended_bills
-- ----------------------------
-- ----------------------------
-- Table structure for sma_suspended_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_suspended_items`;
CREATE TABLE `sma_suspended_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`suspend_id` int(11) unsigned NOT NULL,
`product_id` int(11) unsigned NOT NULL,
`product_code` varchar(55) NOT NULL,
`product_name` varchar(255) NOT NULL,
`net_unit_price` decimal(25,4) NOT NULL,
`unit_price` decimal(25,4) NOT NULL,
`quantity` decimal(15,4) DEFAULT '0.0000',
`warehouse_id` int(11) DEFAULT NULL,
`item_tax` decimal(25,4) DEFAULT NULL,
`tax_rate_id` int(11) DEFAULT NULL,
`tax` varchar(55) DEFAULT NULL,
`discount` varchar(55) DEFAULT NULL,
`item_discount` decimal(25,4) DEFAULT NULL,
`subtotal` decimal(25,4) NOT NULL,
`serial_no` varchar(255) DEFAULT NULL,
`option_id` int(11) DEFAULT NULL,
`product_type` varchar(20) DEFAULT NULL,
`real_unit_price` decimal(25,4) DEFAULT NULL,
`product_unit_id` int(11) DEFAULT NULL,
`product_unit_code` varchar(10) DEFAULT NULL,
`unit_quantity` decimal(15,4) NOT NULL,
`comment` varchar(255) DEFAULT NULL,
`gst` varchar(20) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_suspended_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_tax_rates
-- ----------------------------
DROP TABLE IF EXISTS `sma_tax_rates`;
CREATE TABLE `sma_tax_rates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(55) NOT NULL,
`code` varchar(10) DEFAULT NULL,
`rate` decimal(12,4) NOT NULL,
`type` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_tax_rates
-- ----------------------------
INSERT INTO `sma_tax_rates` VALUES ('1', 'No Tax', 'NT', '0.0000', '2');
INSERT INTO `sma_tax_rates` VALUES ('2', 'VAT @10%', 'VAT10', '10.0000', '1');
INSERT INTO `sma_tax_rates` VALUES ('3', 'GST @6%', 'GST', '6.0000', '1');
INSERT INTO `sma_tax_rates` VALUES ('4', 'VAT @20%', 'VT20', '20.0000', '1');
-- ----------------------------
-- Table structure for sma_transfers
-- ----------------------------
DROP TABLE IF EXISTS `sma_transfers`;
CREATE TABLE `sma_transfers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`transfer_no` varchar(55) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`from_warehouse_id` int(11) NOT NULL,
`from_warehouse_code` varchar(55) NOT NULL,
`from_warehouse_name` varchar(55) NOT NULL,
`to_warehouse_id` int(11) NOT NULL,
`to_warehouse_code` varchar(55) NOT NULL,
`to_warehouse_name` varchar(55) NOT NULL,
`note` varchar(1000) DEFAULT NULL,
`total` decimal(25,4) DEFAULT NULL,
`total_tax` decimal(25,4) DEFAULT NULL,
`grand_total` decimal(25,4) DEFAULT NULL,
`created_by` varchar(255) DEFAULT NULL,
`status` varchar(55) NOT NULL DEFAULT 'pending',
`shipping` decimal(25,4) NOT NULL DEFAULT '0.0000',
`attachment` varchar(55) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_transfers
-- ----------------------------
-- ----------------------------
-- Table structure for sma_transfer_items
-- ----------------------------
DROP TABLE IF EXISTS `sma_transfer_items`;
CREATE TABLE `sma_transfer_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`transfer_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`product_code` varchar(55) NOT NULL,
`product_name` varchar(255) NOT NULL,
`option_id` int(11) DEFAULT NULL,
`expiry` date DEFAULT NULL,
`quantity` decimal(15,4) NOT NULL,
`tax_rate_id` int(11) DEFAULT NULL,
`tax` varchar(55) DEFAULT NULL,
`item_tax` decimal(25,4) DEFAULT NULL,
`net_unit_cost` decimal(25,4) DEFAULT NULL,
`subtotal` decimal(25,4) DEFAULT NULL,
`quantity_balance` decimal(15,4) NOT NULL,
`unit_cost` decimal(25,4) DEFAULT NULL,
`real_unit_cost` decimal(25,4) DEFAULT NULL,
`date` date DEFAULT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`product_unit_id` int(11) DEFAULT NULL,
`product_unit_code` varchar(10) DEFAULT NULL,
`unit_quantity` decimal(15,4) NOT NULL,
`gst` varchar(20) DEFAULT NULL,
`cgst` decimal(25,4) DEFAULT NULL,
`sgst` decimal(25,4) DEFAULT NULL,
`igst` decimal(25,4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `transfer_id` (`transfer_id`),
KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_transfer_items
-- ----------------------------
-- ----------------------------
-- Table structure for sma_units
-- ----------------------------
DROP TABLE IF EXISTS `sma_units`;
CREATE TABLE `sma_units` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) NOT NULL,
`name` varchar(55) NOT NULL,
`base_unit` int(11) DEFAULT NULL,
`operator` varchar(1) DEFAULT NULL,
`unit_value` varchar(55) DEFAULT NULL,
`operation_value` varchar(55) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `base_unit` (`base_unit`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_units
-- ----------------------------
INSERT INTO `sma_units` VALUES ('1', 'CAI', 'Cái', null, null, null, null);
INSERT INTO `sma_units` VALUES ('2', 'HOP', 'Hộp', null, null, null, null);
-- ----------------------------
-- Table structure for sma_users
-- ----------------------------
DROP TABLE IF EXISTS `sma_users`;
CREATE TABLE `sma_users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`last_ip_address` varbinary(45) DEFAULT NULL,
`ip_address` varbinary(45) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(40) NOT NULL,
`salt` varchar(40) DEFAULT NULL,
`email` varchar(100) NOT NULL,
`activation_code` varchar(40) DEFAULT NULL,
`forgotten_password_code` varchar(40) DEFAULT NULL,
`forgotten_password_time` int(11) unsigned DEFAULT NULL,
`remember_code` varchar(40) DEFAULT NULL,
`created_on` int(11) unsigned NOT NULL,
`last_login` int(11) unsigned DEFAULT NULL,
`active` tinyint(1) unsigned DEFAULT NULL,
`first_name` varchar(50) DEFAULT NULL,
`last_name` varchar(50) DEFAULT NULL,
`company` varchar(100) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`avatar` varchar(55) DEFAULT NULL,
`gender` varchar(20) DEFAULT NULL,
`group_id` int(10) unsigned NOT NULL,
`warehouse_id` int(10) unsigned DEFAULT NULL,
`biller_id` int(10) unsigned DEFAULT NULL,
`company_id` int(11) DEFAULT NULL,
`show_cost` tinyint(1) DEFAULT '0',
`show_price` tinyint(1) DEFAULT '0',
`award_points` int(11) DEFAULT '0',
`view_right` tinyint(1) NOT NULL DEFAULT '0',
`edit_right` tinyint(1) NOT NULL DEFAULT '0',
`allow_discount` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `group_id` (`group_id`,`warehouse_id`,`biller_id`),
KEY `group_id_2` (`group_id`,`company_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_users
-- ----------------------------
INSERT INTO `sma_users` VALUES ('1', 0x3A3A31, 0x0000, 'owner', '91258ce5897f7089414a62f98b7b6beee1fc4586', null, 'owner@tecdiary.com', null, null, null, '019d337513ff2dfa6881db167a1f743f9d3a150e', '1351661704', '1602411003', '1', 'Owner', 'Owner', 'Stock Manager', '012345678', null, 'male', '1', null, null, null, '0', '0', '0', '0', '0', '0');
-- ----------------------------
-- Table structure for sma_user_logins
-- ----------------------------
DROP TABLE IF EXISTS `sma_user_logins`;
CREATE TABLE `sma_user_logins` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`company_id` int(11) DEFAULT NULL,
`ip_address` varbinary(16) NOT NULL,
`login` varchar(100) NOT NULL,
`time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_user_logins
-- ----------------------------
INSERT INTO `sma_user_logins` VALUES ('1', '1', null, 0x3137312E3234342E38342E313638, 'owner@tecdiary.com', '2020-10-07 10:51:43');
INSERT INTO `sma_user_logins` VALUES ('2', '1', null, 0x34322E3131342E3139312E313937, 'owner@tecdiary.com', '2020-10-07 10:52:59');
INSERT INTO `sma_user_logins` VALUES ('3', '1', null, 0x3137312E3234342E38342E313638, 'owner@tecdiary.com', '2020-10-07 10:54:09');
INSERT INTO `sma_user_logins` VALUES ('4', '1', null, 0x31342E3234382E3134322E323332, 'owner@tecdiary.com', '2020-10-07 14:28:35');
INSERT INTO `sma_user_logins` VALUES ('5', '1', null, 0x31342E3234382E3134322E323332, 'owner@tecdiary.com', '2020-10-07 16:02:15');
INSERT INTO `sma_user_logins` VALUES ('6', '1', null, 0x3132332E33312E31382E3137, 'owner@tecdiary.com', '2020-10-07 17:02:11');
INSERT INTO `sma_user_logins` VALUES ('7', '1', null, 0x34322E3131342E3139312E313937, 'owner@tecdiary.com', '2020-10-07 19:45:40');
INSERT INTO `sma_user_logins` VALUES ('8', '1', null, 0x3A3A31, 'owner@tecdiary.com', '2020-10-08 14:36:09');
-- ----------------------------
-- Table structure for sma_variants
-- ----------------------------
DROP TABLE IF EXISTS `sma_variants`;
CREATE TABLE `sma_variants` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(55) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_variants
-- ----------------------------
-- ----------------------------
-- Table structure for sma_warehouses
-- ----------------------------
DROP TABLE IF EXISTS `sma_warehouses`;
CREATE TABLE `sma_warehouses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(50) NOT NULL,
`name` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL,
`map` varchar(255) DEFAULT NULL,
`phone` varchar(55) DEFAULT NULL,
`email` varchar(55) DEFAULT NULL,
`price_group_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_warehouses
-- ----------------------------
INSERT INTO `sma_warehouses` VALUES ('3', 'CAUGIAY', 'Cửa hàng', '<p>Cau Giay</p>', null, '0123456789', '', '1');
INSERT INTO `sma_warehouses` VALUES ('4', 'TQK', 'Trần Quý Kiên', '<p>HN</p>', null, '', '', '1');
-- ----------------------------
-- Table structure for sma_warehouses_products
-- ----------------------------
DROP TABLE IF EXISTS `sma_warehouses_products`;
CREATE TABLE `sma_warehouses_products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`quantity` decimal(15,4) NOT NULL,
`rack` varchar(55) DEFAULT NULL,
`avg_cost` decimal(25,4) NOT NULL,
PRIMARY KEY (`id`),
KEY `product_id` (`product_id`),
KEY `warehouse_id` (`warehouse_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_warehouses_products
-- ----------------------------
INSERT INTO `sma_warehouses_products` VALUES ('3', '1', '3', '0.0000', null, '480000.0000');
INSERT INTO `sma_warehouses_products` VALUES ('4', '1', '4', '0.0000', null, '480000.0000');
INSERT INTO `sma_warehouses_products` VALUES ('5', '2', '3', '0.0000', null, '200000.0000');
INSERT INTO `sma_warehouses_products` VALUES ('6', '2', '4', '0.0000', null, '200000.0000');
INSERT INTO `sma_warehouses_products` VALUES ('7', '3', '3', '0.0000', null, '0.0000');
INSERT INTO `sma_warehouses_products` VALUES ('8', '3', '4', '0.0000', null, '0.0000');
-- ----------------------------
-- Table structure for sma_warehouses_products_variants
-- ----------------------------
DROP TABLE IF EXISTS `sma_warehouses_products_variants`;
CREATE TABLE `sma_warehouses_products_variants` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`option_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`warehouse_id` int(11) NOT NULL,
`quantity` decimal(15,4) NOT NULL,
`rack` varchar(55) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `option_id` (`option_id`),
KEY `product_id` (`product_id`),
KEY `warehouse_id` (`warehouse_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sma_warehouses_products_variants
-- ----------------------------
INSERT INTO `sma_warehouses_products_variants` VALUES ('1', '1', '2', '3', '0.0000', null);
INSERT INTO `sma_warehouses_products_variants` VALUES ('2', '1', '2', '4', '0.0000', null);
INSERT INTO `sma_warehouses_products_variants` VALUES ('3', '2', '2', '3', '0.0000', null);
INSERT INTO `sma_warehouses_products_variants` VALUES ('4', '2', '2', '4', '0.0000', null);
INSERT INTO `sma_warehouses_products_variants` VALUES ('5', '3', '2', '3', '0.0000', null);
INSERT INTO `sma_warehouses_products_variants` VALUES ('6', '3', '2', '4', '0.0000', null);
INSERT INTO `sma_warehouses_products_variants` VALUES ('7', '4', '2', '3', '0.0000', null);
INSERT INTO `sma_warehouses_products_variants` VALUES ('8', '4', '2', '4', '0.0000', null);
|
-- Create the tables by importing the necessary file source 'create-timeseries.cql';
source 'C:\Users\Angela_Shi\Desktop\angela\week5\day-02\data\create-timeseries.cql';
-- Load the file from the load-timeseries.cql
source 'C:\Users\Angela_Shi\Desktop\angela\week5\day-02\data\load-timeseries.cql';
-- Check if the tables are created
desc tables
-- Switch to the newly created keyspace
use isd_weather_data;
-- Check you tables
desc tables
-- Check the structure of the weather_station table
desc weather_station;
-- Now copy some data to the database
COPY raw_weather_data (wsid, year, month, day, hour, temperature, dewpoint, pressure, wind_direction, wind_speed, sky_condition, one_hour_precip, six_hour_precip)
... FROM 'C:\Users\Angela_Shi\Desktop\angela\week5\day-02\data\2014.csv';
-----------------------------------------------------------------------
SELECT hour, temperature
FROM raw_weather_data
WHERE wsid = '724940:23234'
LIMIT 5;
hour | temperature
------+-------------
23 | 11.7
22 | 12.2
21 | 12.2
20 | 11.7
19 | 11.1
-------------------------------------------------------------------------
-- Questions
-- Q1:Where is this weather station?
select country_code from weather_station where id = '724940:23234';
country_code
--------------
US
-- Q1:Show the temperature for June 1st, 2008
select temperature from raw_weather_data where wsid = '724940:23234'
and year = 2008 and month = 6 and day = 1 allow filtering;
temperature
-------------
15
15
15.6
15
15
14.4
13.3
12.2
11.7
10.6
10
10
10.6
11.1
11.1
0
11.7
11.7
11.7
11.7
11.7
12.2
12.8
13.3
(24 rows)
-- Show the temperatures for June 1st, 2008 from 9AM to 3PM.
select temperature from raw_weather_data where wsid = '724940:23234' and year = 2008 and month = 6
and day = 1 and hour >= 9 and hour <= 15 allow filtering;
temperature
-------------
11.7
10.6
10
10
10.6
11.1
11.1
(7 rows)
-- What is the average elevation of the weather stations in Indiana?
select avg(elevation) from weather_station where state_code = 'IN' allow filtering;
system.avg(elevation)
-----------------------
213.85122
-- What is the latitude of the northest weather station in Texas?
SELECT max(lat) FROM weather_station WHERE state_code = 'TX' ALLOW FILTERING;
system.max(lat)
-----------------
36.017
-- Insert the current temperature for today.
INSERT INTO raw_weather_data (wsid, year, month, day, hour, temperature) VALUES ('shenzhen', 2019, 6, 5, 20,32);
select * from raw_weather_data where wsid = 'shenzhen';
wsid | year | month | day | hour | dewpoint | one_hour_precip | pressure | six_hour_precip | sky_condition | sky_condition_text | temperature | wind_direction | wind_speed
----------+------+-------+-----+------+----------+-----------------+----------+-----------------+---------------+--------------------+-------------+----------------+------------
shenzhen | 2019 | 6 | 5 | 20 | null | null | null | null | null | null | 32 | null | null
|
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE SCHEMA IF NOT EXISTS `issueTrackerDb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
use issueTrackerDb;
-- -----------------------------------------------------
-- Table `issueTrackerDb`.`Project`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS PROJECT (
PROJECT_ID INTEGER NOT NULL AUTO_INCREMENT,
PROJECT_NAME VARCHAR(200) NULL,
OWNER VARCHAR(100) NULL,
DESCRIPTION TEXT NULL,
ORGANIZATION_ID INTEGER DEFAULT 0,
PROJECT_KEY VARCHAR(100) NOT NULL,
CONSTRAINT PK_PROJECT PRIMARY KEY (PROJECT_ID),
UNIQUE(PROJECT_KEY, ORGANIZATION_ID)
) ENGINE=INNODB;
-- -----------------------------------------------------
-- Table `issueTrackerDb`.`Version`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS VERSION (
VERSION_ID INTEGER NOT NULL AUTO_INCREMENT,
VERSION VARCHAR(200) NULL,
PROJECT_ID INT NOT NULL,
CONSTRAINT PK_VERSION PRIMARY KEY (VERSION_ID),
UNIQUE(VERSION, PROJECT_ID)
) ENGINE=INNODB;
ALTER TABLE VERSION ADD CONSTRAINT VERSION_FK_BY_PROJECT_ID FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT (PROJECT_ID);
CREATE INDEX VERSION_IND_BY_PROJECT_ID USING HASH ON VERSION(PROJECT_ID);
-- -----------------------------------------------------
-- Table `issueTrackerDb`.`Issue`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS ISSUE (
ISSUE_ID INTEGER NOT NULL AUTO_INCREMENT,
PKEY VARCHAR(100),
PROJECT_ID INT NOT NULL,
SUMMARY VARCHAR (255) NOT NULL,
DESCRIPTION TEXT NULL,
ISSUE_TYPE VARCHAR(100) NULL,
PRIORITY VARCHAR(100) NULL,
OWNER VARCHAR(100) NULL,
STATUS VARCHAR(100) NULL,
ASSIGNEE VARCHAR(100) NULL,
VERSION_ID INT NULL,
CREATED_TIME TIMESTAMP NULL,
UPDATED_TIME TIMESTAMP NULL,
SEVERITY VARCHAR(45) NULL,
CONSTRAINT PK_ISSUE PRIMARY KEY (ISSUE_ID),
ORGANIZATION_ID INTEGER DEFAULT 0,
UNIQUE (PKEY, ORGANIZATION_ID),
UNIQUE (SUMMARY, ORGANIZATION_ID)
) ENGINE=INNODB;
ALTER TABLE ISSUE ADD CONSTRAINT ISSUE_FK_BY_PROJECT_ID FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT (PROJECT_ID);
CREATE INDEX ISSUE_IND_BY_PROJECT_ID USING HASH ON ISSUE (PROJECT_ID);
ALTER TABLE ISSUE ADD CONSTRAINT ISSUE_FK_BY_VERSION_ID FOREIGN KEY (VERSION_ID) REFERENCES VERSION(VERSION_ID);
CREATE INDEX ISSUE_IND_BY_VERSION_ID USING HASH ON ISSUE (VERSION_ID);
-- -----------------------------------------------------
-- Table `issueTrackerDb`.`Comment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS COMMENT (
ID INTEGER NOT NULL AUTO_INCREMENT,
DESCRIPTION TEXT NULL,
CREATED_TIME TIMESTAMP NULL,
UPDATED_TIME TIMESTAMP NULL,
CREATOR VARCHAR(100) NULL,
ISSUE_ID INT NOT NULL,
ORGANIZATION_ID INTEGER DEFAULT 0,
CONSTRAINT PK_COMMENT PRIMARY KEY (ID)
) ENGINE INNODB;
ALTER TABLE COMMENT ADD CONSTRAINT COMMENT_FK_BY_ISSUE_ID FOREIGN KEY (ISSUE_ID) REFERENCES ISSUE (ISSUE_ID);
CREATE INDEX COMMENT_IND_BY_ISSUE_ID USING HASH ON COMMENT(ISSUE_ID);
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
set TRANSACTION ISOLATION level SERIALIZABLE;
select sum(price) 총액 from book;
create tablespace md_tbs
datafile 'c:\madang\oradata\md_tbs_data01.dbf'
size 10M;
create TABLESPACE md_test
datafile 'c:\madang\oradata\md_test_data01.dbf'
size 20M;
-- 목록보기
select * from dba_tablespaces;
select tablespace_name, status, contents from dba_tablespaces;
-- 파일용량
select * from dba_data_files;
select file_name, tablespace_name, bytes, status from dba_data_files;
-- 남은 공간 확인
select * from dba_free_space;
select tablespace_name, bytes, blocks from dba_free_space;
-- 계정생성 및 스페이스 적용
-- mdguest
create user mdguest IDENTIFIED by mdguest;
-- mdguest2 생성과 스페이스 할당
create user mdguest2 IDENTIFIED by mdguest2
default tablespace md_tbs;
-- 권한
grant connect, resource to mdguest;
grant connect, resource to mdguest2;
-- 테이블 스페이스 삭제
drop tablespace md_test INCLUDING CONTENTS and DATAFILES;
--mdguest 에게 book테이블의 select 권한 부여
grant select on madang.book to mdguest;
--mdguest 에게 customer 테이블의 select와 update 권한 동시 부여
-- 단 다른 사용자에게 허가할 수 있는 권한 추가
grant select, update on madang.customer to mdguest with grant option;
--mdguest 접속 상태에서 book상속여부 에러가 나야함 (book테이블에 대한 권한만을 부여함)
grant select on madang.book to mdguest2;
--mdguest 접속 상태에서 customer상속여부 정상작동되야함
--(customer 테이블에 대한 권한을 부여하면서 with grant option으로 타 사용자에 대한 권한 허가권한도 부여했기 때문)
grant select on madang.customer to mdguest2;
-- orders 테이블에 대하여 모든 사용자가 select 할 수 있도록 권한 부여
grant select on madang.orders to public;
/* 권한 취소 REBOKE : from / CASCADE(:연속적)
GRANT : to / with grant option */
-- mdguest 권한취소
REVOKE select on customer from mdguest;
-- mdguest2 권한취소
REVOKE select on book from mdguest2;
REVOKE select on customer from mdguest CASCADE CONSTRAINTS; -- mdguest가 부여한 것에 대한 것 까지 회수
REVOKE update on customer from mdguest CASCADE CONSTRAINTS;
|
CREATE TABLE `Document` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`url` varchar(128) NOT NULL DEFAULT '',
`content` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `url` (`url`)
) ENGINE=InnoDB AUTO_INCREMENT=411 DEFAULT CHARSET=utf8;
CREATE TABLE `Entry` (
`document_id` int(11) unsigned NOT NULL,
`term` varchar(32) NOT NULL DEFAULT '',
`count` int(11) NOT NULL,
PRIMARY KEY (`document_id`,`term`),
KEY `term` (`term`),
CONSTRAINT `entry_document_fk` FOREIGN KEY (`document_id`) REFERENCES `Document` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
drop table DT_DEPARTMENTS CASCADE CONSTRAINTS;
DROP TABLE DT_EMPLOYEES CASCADE CONSTRAINTS;
create table DT_DEPARTMENTS( ID NUMBER PRIMARY KEY,
DENUMIRE VARCHAR2(50));
CREATE TABLE DT_EMPLOYEES(ID NUMBER PRIMARY KEY,
NUME VARCHAR2(50),
PRENUME VARCHAR2(50),
DATA_NASTERII DATE,
DATA_ANGAJARII DATE DEFAULT SYSDATE,
GEN VARCHAR2(1) CHECK (GEN='M' OR GEN='F'),
SALARIU NUMBER DEFAULT 0,
ID_DEPT NUMBER,
FOREIGN KEY (ID_DEPT) REFERENCES DT_DEPARTMENTS(ID));
INSERT INTO DT_DEPARTMENTS VALUES(1,'IT');
INSERT INTO DT_DEPARTMENTS VALUES(2,'MARKETING');
INSERT INTO DT_DEPARTMENTS VALUES(3,'CONTABILITATE');
INSERT INTO DT_DEPARTMENTS VALUES(4,'PUBLICITATE');
INSERT INTO DT_DEPARTMENTS VALUES(5,'HR');
INSERT INTO DT_EMPLOYEES VALUES(1,'POPESCU','MIHAI',TO_DATE('10.01.1990','dd.mm.yyyy'),TO_DATE('14.03.2014','dd.mm.yyyy'),'M', 1450,1);
INSERT INTO DT_EMPLOYEES VALUES(2,'IONESCU','ANDREI',TO_DATE('15.09.1890','dd.mm.yyyy'),TO_DATE('12.05.2016','dd.mm.yyyy'),'M',2000,2);
INSERT INTO DT_EMPLOYEES VALUES(3,'ION','MARIA',TO_DATE('01.01.1991','dd.mm.yyyy'),TO_DATE('20.09.2010','dd.mm.yyyy'),'F',1200,3);
INSERT INTO DT_EMPLOYEES VALUES(4,'CRISTESCU','ANDREEA',TO_DATE('03.10.1897','dd.mm.yyyy'),TO_DATE('14.06.2009','dd.mm.yyyy'),'F',2500,4);
INSERT INTO DT_EMPLOYEES VALUES(5,'OANCEA','IOANA',TO_DATE('05.09.1995','dd.mm.yyyy'),TO_DATE('20.06.2013','dd.mm.yyyy'),'F',2300,5);
INSERT INTO DT_EMPLOYEES VALUES(6,'IONESCU','ALIN',TO_DATE('10.01.1990','dd.mm.yyyy'),TO_DATE('01.01.2015','dd.mm.yyyy'),'M',900,1);
INSERT INTO DT_EMPLOYEES VALUES(7,'GRIGORE','RAUL',TO_DATE('12.10.1993','dd.mm.yyyy'),TO_DATE('06.07.2014','dd.mm.yyyy'),'M',940,3);
INSERT INTO DT_EMPLOYEES VALUES(8,'OANCEA','MARIA',TO_DATE('31.03.1970','dd.mm.yyyy'),TO_DATE('15.10.2016','dd.mm.yyyy'),'F',4000,1);
INSERT INTO DT_EMPLOYEES VALUES(9,'CRISTESCU','VASILE',TO_DATE('15.04.1984','dd.mm.yyyy'),TO_DATE('20.04.2014','dd.mm.yyyy'),'M',550,1);
UPDATE DT_EMPLOYEES SET PRENUME=INITCAP(PRENUME);
SELECT * FROM DT_EMPLOYEES;
INSERT INTO DT_EMPLOYEES VALUES(10,'POPESCU','Oana',TO_DATE('23.05.1981','dd.mm.yyyy'),TO_DATE('03.06.2016','dd.mm.yyyy'),'F',750,1);
INSERT INTO DT_EMPLOYEES VALUES(11,'STROE','Ion',TO_DATE('29.09.1982','dd.mm.yyyy'),TO_DATE('01.01.2017','dd.mm.yyyy'),'M',3560,2);
INSERT INTO DT_EMPLOYEES VALUES(12,'POPESCU','Mihai',TO_DATE('20.08.1994','dd.mm.yyyy'),TO_DATE('15.06.2015','dd.mm.yyyy'),'M',230,2);
INSERT INTO DT_EMPLOYEES VALUES(13,'GANEA','Bogdan',TO_DATE('01.02.1997','dd.mm.yyyy'),TO_DATE('01.01.2017','dd.mm.yyyy'),'M',1100,2);
INSERT INTO DT_EMPLOYEES VALUES(14,'MARINESCU','Emil',TO_DATE('25.12.1995','dd.mm.yyyy'),TO_DATE('23.05.2016','dd.mm.yyyy'),'M',1200,3);
INSERT INTO DT_EMPLOYEES VALUES(15,'MARINCA','Eugenia',TO_DATE('29.11.1985','dd.mm.yyyy'),TO_DATE('04.12.2015','dd.mm.yyyy'),'F',900,3);
INSERT INTO DT_EMPLOYEES VALUES(16,'POPA','Rodica',TO_DATE('06.04.1988','dd.mm.yyyy'),TO_DATE('20.10.2015','dd.mm.yyyy'),'F',700,3);
INSERT INTO DT_EMPLOYEES(ID ,NUME,PRENUME,DATA_NASTERII,DATA_ANGAJARII,GEN,SALARIU) VALUES
(17,'ICHIM','Cristina',TO_DATE('15.11.1993','dd.mm.yyyy'),TO_DATE('05.11.2016','dd.mm.yyyy'),'F',200);
INSERT INTO DT_EMPLOYEES VALUES(18,'GRECU','Radu',TO_DATE('31.10.1992','dd.mm.yyyy'),TO_DATE('30.08.2016','dd.mm.yyyy'),'M',4570,3);
COMMIT;
-- Selectati toti angajatii care au data nasterii intre 01.01.1990 si 31.12.1995.
SELECT NUME,PRENUME FROM DT_EMPLOYEES WHERE DATA_NASTERII BETWEEN TO_DATE('01.01.1990','dd.mm.yyyy') AND TO_DATE('31.12.1995','dd.mm.yyyy');
-- Numarati angajatii din fiecare departament, care au data angajarii > 01.01.2016.
SELECT COUNT(ID),ID_DEPT FROM DT_EMPLOYEES WHERE (DATA_ANGAJARII) > TO_DATE('01.01.2016','dd.mm.yyyy') GROUP BY ID_DEPT;
-- Selectati angajatii din fiecare department care au primele 2 salarii ca marime din departamentul lor.
SELECT ID,NUME,PRENUME,TO_CHAR(DATA_NASTERII,'DD.MM.YYYY'),TO_CHAR(DATA_ANGAJARII,'DD.MM.YYYY'),GEN,SALARIU,ID_DEPT
FROM DT_EMPLOYEES DT1 WHERE (SELECT COUNT(DISTINCT (SALARIU)) FROM DT_EMPLOYEES DT2
WHERE DT2.ID_DEPT=DT1.ID_DEPT AND DT2.SALARIU >= DT1.SALARIU) <=2 order by id_dept ;
-- Afisati toti angajatii care au salariul mai mare decat media salariului din firma
SELECT ID,NUME,PRENUME,TO_CHAR(DATA_NASTERII,'DD.MM.YYYY'),TO_CHAR(DATA_ANGAJARII,'DD.MM.YYYY'),GEN,SALARIU,ID_DEPT
FROM DT_EMPLOYEES WHERE SALARIU>(SELECT AVG(SALARIU) FROM DT_EMPLOYEES);
-- Scrieti un query care sa afiseze intr-o singura coloana:
SELECT 'Angajatul' || ' ' || NUME ||' ' || PRENUME || '' || ' ' || 'are salariul' ||' ' || SALARIU FROM DT_EMPLOYEES;
-- Scrieti un query care sa afiseze pozitia caracterului ?o? din coloana NUME pentru angajatii care au acest character in nume.
SELECT NUME,INSTR(NUME,'O') FROM DT_EMPLOYEES WHERE NUME LIKE '%O%'; |
USE seandb;
CREATE TABLE IF NOT EXISTS `cards_trie` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`word1` VARCHAR(30) DEFAULT "",
`word2` VARCHAR(30) DEFAULT "",
`word3` VARCHAR(30) DEFAULT "",
`word4` VARCHAR(30) DEFAULT "",
`url` VARCHAR(100),
`disabled` TINYINT DEFAULT 0,
PRIMARY KEY `id` (`id`),
UNIQUE `name` (`word1`, `word2`, `word3`, `word4`)
) ENGINE=InnoDB;
/*
* the bot will not post info for the same card twice in the same thread
*/
CREATE TABLE IF NOT EXISTS `threads` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`thread_id` VARCHAR(10) DEFAULT "",
`card_ids_json` VARCHAR(4000) DEFAULT "",
`last_update` INT(11),
`url` VARCHAR(100),
PRIMARY KEY `id` (`id`),
KEY `thread_id` (`thread_id`)
) ENGINE=InnoDB;
/*
* the bot will not examine the same post twice, regardless of whether it posted on it or not.
*/
CREATE TABLE IF NOT EXISTS `posts` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`thread_id` VARCHAR(10) DEFAULT "",
`post_id` VARCHAR(10) DEFAULT "",
`last_update` INT(11),
PRIMARY KEY `id` (`id`),
KEY `thread_id` (`thread_id`),
KEY `post_id` (`post_id`)
) ENGINE=InnoDB; |
-- DROP VIEW rv_pp_order_bomline;
CREATE OR REPLACE VIEW rv_pp_order_bomline AS
SELECT
obl.ad_client_id,
obl.ad_org_id,
obl.createdby,
obl.updatedby,
obl.updated,
obl.created,
obl.isactive,
obl.pp_order_bom_id,
obl.pp_order_bomline_id,
obl.pp_order_id,
obl.iscritical,
obl.componenttype,
obl.m_product_id,
obl.c_uom_id,
round(obl.qtyrequired, 4) AS qtyrequired,
round(bomqtyreserved(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS qtyreserved,
round(bomqtyavailable(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS qtyavailable,
round(bomqtyonhand(obl.m_product_id, obl.m_warehouse_id, 0), 4) AS qtyonhand,
obl.m_warehouse_id,
round(obl.qtybom, 4) AS qtybom,
obl.isqtypercentage,
round(obl.qtybatch, 4) AS qtybatch,
CASE WHEN o.qtybatchs = 0 THEN 1 ELSE round(obl.qtyrequired / o.qtybatchs, 4) END AS qtybatchsize
FROM pp_order_bomline obl
JOIN pp_order o ON o.pp_order_id = obl.pp_order_id;
|
/* Создание таблицы движения документов */
CREATE TABLE /*PREFIX*/MOTIONS
(
MOTION_ID VARCHAR(32) NOT NULL,
POSITION_ID VARCHAR(32) NOT NULL,
DOC_ID VARCHAR(32) NOT NULL,
DATE_ISSUE DATETIME NOT NULL,
ACCOUNT_ID VARCHAR(32),
DATE_PROCESS DATETIME,
DESCRIPTION VARCHAR(1000),
PRIMARY KEY (MOTION_ID),
FOREIGN KEY (POSITION_ID) REFERENCES /*PREFIX*/POSITIONS (POSITION_ID),
FOREIGN KEY (DOC_ID) REFERENCES /*PREFIX*/DOCS (DOC_ID),
FOREIGN KEY (ACCOUNT_ID) REFERENCES /*PREFIX*/ACCOUNTS (ACCOUNT_ID)
)
--
/* Создание просмотра таблицы движения документов */
CREATE VIEW /*PREFIX*/S_MOTIONS
AS
SELECT M.*,
P.PRIORITY AS POSITION_PRIORITY,
PL.NAME AS PLAN_NAME,
D.NUM+' '+CONVERT(VARCHAR(10),D.DATE_DOC,104)+' '+D.NAME AS DOC_FULL_NAME,
A.USER_NAME,
F.SMALL_NAME AS FIRM_SMALL_NAME
FROM /*PREFIX*/MOTIONS M
JOIN /*PREFIX*/POSITIONS P ON P.POSITION_ID=M.POSITION_ID
JOIN /*PREFIX*/PLANS PL ON PL.PLAN_ID=P.PLAN_ID
JOIN /*PREFIX*/DOCS D ON D.DOC_ID=M.DOC_ID
LEFT JOIN /*PREFIX*/ACCOUNTS A ON A.ACCOUNT_ID=M.ACCOUNT_ID
LEFT JOIN /*PREFIX*/FIRMS F ON F.FIRM_ID=A.FIRM_ID
--
/* Создание процедуры добавления движения документу */
CREATE PROCEDURE /*PREFIX*/I_MOTION
@MOTION_ID VARCHAR(32),
@POSITION_ID VARCHAR(32),
@DOC_ID VARCHAR(32),
@DATE_ISSUE DATETIME,
@ACCOUNT_ID VARCHAR(32),
@DATE_PROCESS DATETIME,
@DESCRIPTION VARCHAR(1000)
AS
BEGIN
INSERT INTO /*PREFIX*/MOTIONS (MOTION_ID,POSITION_ID,DOC_ID,DATE_ISSUE,
ACCOUNT_ID,DATE_PROCESS,DESCRIPTION)
VALUES (@MOTION_ID,@POSITION_ID,@DOC_ID,@DATE_ISSUE,
@ACCOUNT_ID,@DATE_PROCESS,@DESCRIPTION);
END;
--
/* Создание процедуры изменения движения документа */
CREATE PROCEDURE /*PREFIX*/U_MOTION
@MOTION_ID VARCHAR(32),
@POSITION_ID VARCHAR(32),
@DOC_ID VARCHAR(32),
@DATE_ISSUE DATETIME,
@ACCOUNT_ID VARCHAR(32),
@DATE_PROCESS DATETIME,
@DESCRIPTION VARCHAR(1000),
@OLD_MOTION_ID VARCHAR(32)
AS
BEGIN
UPDATE /*PREFIX*/MOTIONS
SET MOTION_ID=@MOTION_ID,
POSITION_ID=@POSITION_ID,
DOC_ID=@DOC_ID,
DATE_ISSUE=@DATE_ISSUE,
ACCOUNT_ID=@ACCOUNT_ID,
DATE_PROCESS=@DATE_PROCESS,
DESCRIPTION=@DESCRIPTION
WHERE MOTION_ID=@OLD_MOTION_ID;
END;
--
/* Создание процедуры удаления движения документа */
CREATE PROCEDURE /*PREFIX*/D_MOTION
@OLD_MOTION_ID VARCHAR(32)
AS
BEGIN
DELETE FROM /*PREFIX*/MOTIONS
WHERE MOTION_ID=@OLD_MOTION_ID;
END;
-- |
# 7. Mostre apenas os ids dos 5 últimos registros da tabela `products`
# (a ordernação deve ser baseada na coluna `id`).
SELECT id FROM northwind.products
ORDER BY id DESC LIMIT 5;
|
create table price_today
select b.date date, a.price price
from test1 as a right join list_date as b on a.date = b.date; |
/*
* http://localhost:8080/h2-console
*
* JDBC URL: jdbc:h2:mem:testdb
*
*/
DROP TABLE SECUENCIAS IF EXISTS;
DROP TABLE PRODUCTOS IF EXISTS;
DROP TABLE PLAZAS IF EXISTS;
DROP TABLE USUARIOS IF EXISTS;
DROP TABLE RESERVAS IF EXISTS;
CREATE TABLE PLAZAS (
CODIGO BIGINT NOT NULL,
PLANTA VARCHAR(100) NOT NULL,
PROPIETARIO VARCHAR(100) NOT NULL,
TELEFONO VARCHAR(100) NOT NULL,
EMAIL VARCHAR(100) NOT NULL,
DISPONIBLE BOOLEAN NOT NULL,
PRIMARY KEY(CODIGO)
);
CREATE TABLE USUARIOS (
CODIGO BIGINT NOT NULL,
NOMBRE VARCHAR(100) NOT NULL,
APELLIDO1 VARCHAR(100) NOT NULL,
APELLIDO2 VARCHAR(100) NOT NULL,
PRIMARY KEY(CODIGO)
);
CREATE TABLE RESERVAS (
CODIGO BIGINT NOT NULL,
CODIGO_USUARIO BIGINT NOT NULL,
CODIGO_PLAZA BIGINT NOT NULL,
FECHA_INI DATETIME NOT NULL,
FECHA_FIN DATETIME NOT NULL,
PRIMARY KEY(CODIGO),
FOREIGN KEY (CODIGO_USUARIO) REFERENCES USUARIOS(CODIGO),
FOREIGN KEY (CODIGO_PLAZA) REFERENCES PLAZAS(CODIGO)
);
CREATE TABLE SECUENCIAS(
SEQ_NAME VARCHAR(100) NOT NULL,
SEQ_NUMBER BIGINT NOT NULL
);
|
create table user_info(
user_id int primary key auto_increment,
user_name varchar(25) not null,
user_password varchar(25) not null,
user_email varchar(30) not null,
user_address varchar(70) not null,
unique(user_email)); |
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Comments')
BEGIN
CREATE TABLE Comments (
Id BIGINT NOT NULL,
Date DATETIME NOT NULL,
Content VARCHAR(MAX) NOT NULL,
PostId BIGINT NOT NULL,
CONSTRAINT PK_Comments PRIMARY KEY (Id),
CONSTRAINT FK_Comments_PostId_Posts_Id FOREIGN KEY (PostId) REFERENCES Posts(Id)
);
END |
-- Query the number of EvalPts in each of the Census Tracts
UPDATE foodmap_censustract
SET no_eval_pts = Q.counter
FROM
(
SELECT B.geoid as geoid, count(*) as counter
FROM (
SELECT location
FROM foodmap_evaluationpoint
) AS A
LEFT JOIN (
SELECT geoid, geom
FROM foodmap_censustract
) AS B
ON ST_Contains(B.geom, A.location)
GROUP BY geoid
) AS Q
WHERE foodmap_censustract.geoid = Q.geoid;
-- Calculate/Update the population density (per eval pt)
UPDATE foodmap_censustract
SET pop_density = population/no_eval_pts;
-- Query to link the EvalPts with the CensusTracts
UPDATE foodmap_evaluationpoint
SET ct_geoid = Q.geoid
FROM
(
SELECT A.id as id, B.geoid as geoid
FROM (
SELECT id, location
FROM foodmap_evaluationpoint
) AS A
LEFT JOIN (
SELECT geoid, geom
FROM foodmap_censustract
) AS B
ON ST_Contains(B.geom, A.location)
) AS Q
WHERE foodmap_evaluationpoint.id = Q.id;
-- Delete census tracts outside of the targeted region
DELETE FROM foodmap_censustract WHERE no_eval_pts IS NULL;
-- Update EvaluationPoints with population and income from CensusTracts
UPDATE foodmap_evaluationpoint
SET population = pop_density,
income = income
FROM foodmap_censustract WHERE foodmap_censustract.geoid = foodmap_evaluationpoint.ct_geoid;
-- Count local crimes
UPDATE foodmap_evaluationpoint
SET crime_count_local = Q.counter
FROM
(
SELECT B.id, count(*) as counter
FROM (
SELECT location
FROM foodmap_crime
) AS A
LEFT JOIN (
SELECT id, poly_pts
FROM foodmap_evaluationpoint
) AS B
ON ST_Contains(B.poly_pts, A.location)
GROUP BY B.id
) AS Q
WHERE foodmap_evaluationpoint.id = Q.id;
-- Count neighborhood crimes
UPDATE foodmap_evaluationpoint
SET crime_count_neighborhood = Q.counter
FROM
(
SELECT B.id, count(*) as counter
FROM (
SELECT location
FROM foodmap_crime
) AS A
LEFT JOIN (
SELECT id, bigpoly_pts
FROM foodmap_evaluationpoint
) AS B
ON ST_Contains(B.bigpoly_pts, A.location)
GROUP BY B.id
) AS Q
WHERE foodmap_evaluationpoint.id = Q.id;
-- Add evaluation point ID to the restaurants
UPDATE foodmap_restaurant
SET eval_pt_id = Q.id
FROM
(
SELECT B.id, A.rest_id
FROM (
SELECT location, id as rest_id
FROM foodmap_restaurant
) AS A
LEFT JOIN (
SELECT id, poly_pts
FROM foodmap_evaluationpoint
) AS B
ON ST_Contains(B.poly_pts, A.location)
) AS Q
WHERE foodmap_restaurant.id=Q.rest_id;
-- Remove evaluation point that has no restaurant in its vicinity
DELETE FROM foodmap_evaluationpoint
WHERE foodmap_evaluationpoint.id NOT IN (
SELECT foodmap_restaurant.eval_pt_id
FROM foodmap_restaurant
WHERE foodmap_restaurant.eval_pt_id IS NOT NULL
);
-- Normalize Crime Count (1/2)
UPDATE foodmap_evaluationpoint
SET crime_count_local = crime_count_local/(population),
crime_count_neighborhood = crime_count_neighborhood/(8*population) -- approximate population of the neighborhood
WHERE population>0;
-- Normalize Crime Count (2/2)
UPDATE foodmap_evaluationpoint
SET crime_count_local = (select (avg(crime_count_local)) from foodmap_evaluationpoint Where population>0),
crime_count_neighborhood = (select (avg(crime_count_neighborhood)) from foodmap_evaluationpoint Where population>0)
Where population=0;
|
/**********************************************************************
* This file is part of ADempiere Business Suite *
* http://www.adempiere.org *
* *
* Copyright (C) Trifon Trifonov. *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Trifon Trifonov (trifonnt@users.sourceforge.net) *
* *
***********************************************************************
*
* Title.........:
* Description...: Returns
* Test..........: SELECT nextBusinessDay(now(), 11); =>
* SELECT nextBusinessDay('2002-07-04', 11); => 2002-07-05
* SELECT nextBusinessDay('2002-07-05', 11); => 2002-07-05
* SELECT nextBusinessDay('2002-07-06', 11); => 2002-07-08
* SELECT nextBusinessDay('2002-07-07', 11); => 2002-07-08
* SELECT nextBusinessDay('2002-07-08', 11); => 2002-07-08
*
* Converted to MySQL..: by Trifon Trifonov
************************************************************************/
-- ## Drop statement
DROP FUNCTION IF EXISTS nextBusinessDay;
DELIMITER $$
-- ## Create statement
CREATE FUNCTION nextBusinessDay (
p_Date DATE,
p_AD_Client_ID DECIMAL(10, 0)
)
RETURNS DATE
DETERMINISTIC
BEGIN
DECLARE v_nextDate DATE DEFAULT trunc(p_Date, null);
DECLARE v_offset DECIMAL(20, 10) DEFAULT 0;
DECLARE v_Saturday DECIMAL(10, 0) DEFAULT DayOfWeek('2000-01-01');
DECLARE v_Sunday DECIMAL(10, 0);
DECLARE v_isHoliday BOOLEAN DEFAULT TRUE;
-- Declare 'curNbd_' variables to read in each record from the cursor
DECLARE curNbd_Date1 DATE;
-- Declare variables used just for cursor and loop control
DECLARE done BOOL DEFAULT FALSE;
-- Declare the cursor
DECLARE curNbd CURSOR FOR
SELECT nbd.Date1
FROM C_NonBusinessDay nbd
WHERE nbd.AD_Client_ID=p_AD_Client_ID
AND nbd.IsActive ='Y'
AND nbd.Date1 >= v_nextDate
ORDER BY nbd.Date1;
-- Declare 'handlers' for exceptions
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = TRUE;
-- SELECT IF(v_Saturday = 7, 1, v_Saturday + 1);
SET v_Sunday = CASE v_Saturday
WHEN 7 THEN 1
ELSE (v_Saturday + 1)
END;
firstLoop: LOOP
SELECT CASE DayOfWeek(v_nextDate)
WHEN v_Saturday THEN 2
WHEN v_Sunday THEN 1
ELSE 0
END
INTO v_offset;
SET v_nextDate = v_nextDate + v_offset;
SET v_isHoliday = false;
OPEN curNbd;
innerLoop: LOOP
FETCH curNbd INTO curNbd_Date1;
IF done THEN
CLOSE curNbd;
LEAVE innerLoop;
END IF;
IF v_nextDate <> trunc(curNbd_Date1, null) THEN
LEAVE innerLoop;
END IF;
SET v_nextDate = v_nextDate + 1;
SET v_isHoliday = true;
END LOOP innerLoop;
IF v_isHoliday=false THEN
LEAVE firstLoop;
END IF;
end LOOP firstLoop;
--
return v_nextDate;
END$$
DELIMITER ; |
create schema canary;
create table canary.users (
firstname varchar(20) not null,
lastname varchar(20) not null,
username varchar (20) not null,
user_pass varchar(128) not null,
register_date date,
birthday date,
biography varchar(64),
primary key (username)
);
create table canary.ava(
username varchar(20) not null,
ava_con varchar (256) not null,
send_date datetime not null DEFAULT CURRENT_TIMESTAMP,
parrent int,
ID int not null AUTO_INCREMENT,
primary key(ID) ,
foreign key (username) references users(username),
foreign key (parrent) references ava(ID)
);
create table canary.messages(
ID int not null auto_increment,
type_con int not null,
sender varchar(20) not null,
reciever varchar(20) not null,
pm varchar(256),
ava_id int,
send_date datetime not null DEFAULT CURRENT_TIMESTAMP,
primary key(ID),
foreign key(ava_id) references ava(ID),
foreign key(sender) references users(username),
foreign key(reciever) references users(username)
);
create table canary.hashtag(
content char(6) not null,
primary key (content)
);
create table canary.logintime(
id int not null auto_increment,
username varchar(20),
login_time datetime not null DEFAULT CURRENT_TIMESTAMP,
primary key(id),
foreign key (username) references users(username)
);
create table canary.followings (
follower varchar(20) not null,
followed varchar(20)not null,
foreign key (follower) references users(username),
foreign key (followed) references users(username)
);
create table canary.blocks(
blocker varchar(20) not null,
blocked varchar(20) not null,
foreign key (blocker) references users(username),
foreign key (blocked) references users(username)
);
create table canary.ava_hash(
ava_id int not null,
hashtag varchar(6) not null,
foreign key (hashtag) references hashtag(content),
foreign key (ava_id) references ava(ID)
);
create table canary.likes(
username varchar(20),
ava_id int,
foreign key(username) references users(username),
foreign key(ava_id) references ava(ID)
);
create table canary.ava_username_id(
username varchar(20) not null,
id int not null,
send_date datetime not null,
foreign key (username) references users(username),
foreign key (id) references ava(id)
);
create table canary.log_register (
username varchar(20) not null,
register_date date not null,
foreign key(username) references users(username)
);
create trigger canary.log_registerr
after insert on canary.users
for each row
insert into canary.log_register values(new.username,new.register_date);
create trigger canary.ava_username_idd
after insert on canary.ava
for each row
insert into canary.ava_username_id(username,id,send_date)
SELECT username,id,send_date FROM canary.ava
ORDER BY id DESC
LIMIT 1;
delimiter //
create procedure canary.register ( in firstname varchar(20),in lastname varchar(20),in username varchar(20),in user_pass varchar(128),in birthday date, in biography varchar(64))
begin
insert into canary.users values(firstname,lastname,username,sha1(user_pass) ,now(),birthday,biography);
insert into logintime (username) values (username);
end;
//
create procedure canary.login (in username3 varchar(20),in user_pass2 varchar(128))
begin
call canary.last_login(@username2);
if username3 in (select username from users)and sha1(user_pass2) in (select user_pass from users where username3=users.username) and username3 <> @username2
then
insert into logintime (username) values (username3);
end if;
end;
//
create procedure canary.user_logins (in username2 varchar(20))
begin
SELECT login_time FROM canary.logintime
where username=username2
order by id desc;
end;
//
create procedure canary.send_ava (in ava_con2 varchar(256))
begin
insert into ava(username,ava_con)
select username,ava_con2
from logintime
ORDER BY id DESC
LIMIT 1;
end;
//
create procedure canary.find_personal_ava()
begin
set @username2=(SELECT username FROM logintime
ORDER BY id DESC
LIMIT 1 );
select id,ava_con from ava where username=@username2;
end;
//
create procedure canary.follow_action(in tofollow varchar(20))
begin
call canary.last_login(@username2);
if tofollow not in(select followed from followings where follower=@username2)and tofollow <> @username2 and tofollow in (select username from users)
then
insert into followings values (@username2,tofollow);
end if;
end;
//
create procedure canary.delete_following(in todelete varchar(20))
begin
call canary.last_login(@username2);
delete from followings where follower=@username2 and followed=todelete;
end ;
//
create procedure canary.block(in blocking varchar(20))
begin
call canary.last_login(@username2);
if blocking not in(select blocked from blocks where blocker=@username2)and blocking <> @username2 and blocking in (select username from users)
then
insert into blocks values (@username2,blocking);
end if;
end;
//
create procedure canary.delete_blockings(in todelete varchar(20))
begin
call canary.last_login(@username2);
delete from blocks where blocker=@username2 and blocked=todelete;
end ;
//
create procedure canary.find_followings_ava()
begin
call canary.last_login(@username2);
select ava_con,send_date from ava
where ava.username in (select followed from followings where follower=@username2)
and ava.username not in (select blocker from blocks where blocked = @username2)
order by send_date desc;
end ;
//
create procedure canary.find_someone_ava(in someone varchar(20))
begin
call canary.last_login(@username2);
select ava_con,send_date from ava
where ava.username=someone and ava.username not in (select blocker from blocks where blocked = @username2)
order by send_date desc;
end ;
//
create procedure canary.comment_action(in comment_in varchar(256),in ava_id2 int)
begin
call canary.last_login(@username2);
set @username3=(select username from ava where ava.id=ava_id2);
insert into canary.ava(username,ava_con,send_date,parrent)
select @username2,comment_in,now(),ID
from canary.ava
where ava.id=ava_id2 and username=@username3 and @username2 not in (select blocked from canary.blocks where blocker=@username3);
end ;
//
create procedure canary.find_comments_ava(in ava_id2 int)
begin
call canary.last_login(@username2);
set @username3=(select username from ava where ava.id=ava_id2);
select ava_con,username from canary.ava where parrent=ava_id2 and
@username2 not in (select blocked from canary.blocks where blocks.blocker=@username3)and
@username2 not in (select blocked from canary.blocks inner join (select t.username from canary.ava inner join canary.ava as t on ava.parrent=t.id and ava.parrent=ava_id2) as neww
on blocks.blocker=neww.username);
end ;
//
create procedure canary.find_hashtag_ava(in hashtag2 char(6))
begin
call canary.last_login(@username2);
select ava_con,send_date,username
from ava inner join ava_hash on ava.ID=ava_hash.ava_id
where hashtag=hashtag2 and ava.username not in (select blocker from blocks where blocked=@username2)
order by send_date desc;
end ;
//
delimiter //
CREATE trigger canary.hashtags
after insert on canary.ava
for each row
begin
set @ava=(SELECT ava_con FROM ava
ORDER BY id DESC
LIMIT 1 );
set @id=(SELECT id FROM ava
ORDER BY id DESC
LIMIT 1 );
set @tosearch ='#' ;
set @no=(SELECT (CHAR_LENGTH (@ava)-CHAR_LENGTH (REPLACE(@ava,@tosearch,'')))/CHAR_LENGTH (@tosearch));
while @no > 0 do
set @hashtag1=(SELECT SUBSTRING(@ava , locate("#",@ava), 6));
if @hashtag1 not in (select * from hashtag) then
insert into hashtag values (@hashtag1);
end if;
insert into ava_hash values (@id,@hashtag1);
set @ava=(SELECT SUBSTRING(@ava , locate("#",@ava)+1, 257));
set @tosearch ='#' ;
set @no=(SELECT (CHAR_LENGTH (@ava)-CHAR_LENGTH (REPLACE(@ava,@tosearch,'')))/CHAR_LENGTH (@tosearch));
end while;
END //
delimiter //
create procedure canary.like_action(in ava_id2 int)
begin
call canary.last_login(@username2);
if @username2 not in(select blocked from blocks where blocker=@username3) and ava_id2 not in (select ava_id from likes where likes.username =@username2) then
insert into likes values(@username2,ava_id2);
end if;
end ;
//
create procedure canary.likes_count(in ava_id2 int)
begin
call canary.last_login(@username2);
set @username3=(select username from ava where ava.id=ava_id2);
if @username2 not in(select blocked from blocks where blocker=@username3) then
select coalesce(count(ava_id),0)
from likes where ava_id=ava_id2;
else
select "0";
end if;
end ;
//
create procedure canary.who_likes(in ava_id2 int)
begin
call canary.last_login(@username2);
set @username3=(select username from ava where ava.id=ava_id2);
if @username2 not in(select blocked from blocks where blocker=@username3) then
select likes.username from likes inner join ava on likes.ava_id=ava.ID
where likes.ava_id=ava_id2 and @username2 not in (select blocked from blocks where blocker=@username3) and ava.username=@username3 and
likes.username not in (select blocker from blocks inner join likes on blocks.blocker=likes.username where blocked=@username2);
else
select " ";
end if;
end ;
//
create procedure canary.trend_ava()
begin
call canary.last_login(@username2);
select ava.ava_con,count(ava_id) from likes right join ava on likes.ava_id=ava.ID
where @username2 not in (select blocked from blocks where blocker=ava.username)
group by id order by count(ava_id) desc;
end ;
create procedure canary.send_pm(in typee int,in username3 varchar(20),in pm_con2 varchar(256),in ava_id2 int)
begin
call canary.last_login(@username2);
if typee="0" and username3 <> @username2 then
insert into messages(type_con,sender,reciever,pm,ava_id)
select "0",@username2,username3,pm_con2,null
where @username2 not in (select blocked from blocks where blocker=username3);
elseif typee="1" and username3 <> @username2 then
insert into messages(type_con,sender,reciever,pm,ava_id)
select "1",@username2,username3,null,ava_id2
where @username2 not in (select blocked from blocks where blocker=username3)
and @username2 not in (select blocked from blocks inner join ava on blocks.blocker=ava.username where ava.ID=ava_id2);
end if;
end ;
//
create procedure canary.find_who_message()
begin
call canary.last_login(@username2);
select sender,send_date from (
select sender,messages.send_date as send_Date from messages where type_con="0" and reciever=@username2 union
select sender,messages.send_date from messages left outer join ava on messages.ava_id=ava.ID where type_con="1" and reciever=@username2 and ava.username
not in (select blocker from blocks inner join ava on blocks.blocker=ava.username where blocked=@username2) ) as message_new INNER JOIN
(SELECT sender as send1, MAx(send_date) AS MaxDateTime
FROM (
select sender,messages.send_date as send_Date from messages where type_con="0" and reciever=@username2 union
select sender,messages.send_date from messages left outer join ava on messages.ava_id=ava.ID where type_con="1" and reciever=@username2 and ava.username
not in (select blocker from blocks inner join ava on blocks.blocker=ava.username where blocked=@username2) ) as message_new2
GROUP BY sender)as groupedtt
ON message_new.sender = groupedtt.send1
AND message_new.send_date = groupedtt.MaxDateTime
order by send_date desc;
end ;
//
create procedure canary.find_someone_messages(in username3 varchar(20))
begin
call canary.last_login(@username2);
(select pm,messages.ava_id,messages.send_date from messages where type_con="0" and reciever=@username2 and sender=username3 union
select pm,messages.ava_id,messages.send_date from messages left outer join ava on messages.ava_id=ava.ID where type_con="1" and reciever=@username2 and sender=username3 and ava.username
not in (select blocker from blocks inner join ava on blocks.blocker=ava.username where blocked=@username2))
order by send_date desc;
end ;
create procedure canary.last_login (out username2 varchar(20))
begin
SELECT username into username2 FROM logintime
ORDER BY id DESC
LIMIT 1 ;
end;
// |
Create Procedure Sp_Recd_CLOCRNOTECount
As
Begin
select Count(*) NoOFCLOCRNOTE From RecdDoc_CLOCrNote Where Isnull(Status,0) = 1
Update RecdDoc_CLOCrNote Set Status = 32 Where Isnull(Status,0) = 1
End
|
#display users with no subscription
select id, username
from j25_users as a
WHERE NOT EXISTS
(
SELECT * FROM j25_cbsubs_subscriptions as b
WHERE a.id = b.user_id
) |
SELECT * FROM Users
SELECT * FROM Roles
SELECT * FROM UserRoles
SELECT * FROM Users WHERE UserId IN (1,2,3,4,95,97,177)
SET IDENTITY_INSERT Roles ON
INSERT INTO Roles (RoleId, Name, [Permissions], IsActive) Values
(2, 'Регистри', 'registerRotsi#access,registerExaminations#access', 1)
SET IDENTITY_INSERT Roles OFF
SET IDENTITY_INSERT Roles ON
INSERT INTO Roles (RoleId, Name, [Permissions], IsActive) Values
(3, 'Деловодна', N'ems#access', 1)
SET IDENTITY_INSERT Roles OFF
|
Create Function mERP_FN_get_DSPMetric_Params_AUTOPOST(@DSTypeID Int)
Returns @Result Table(ParamType nvarchar(50),PMProductName nvarchar(500),
MaxPoints nvarchar(50),ParamID int,ParamFocusLevel int,ParameterType int,DSTypeid int,OrderBy int)
As
Begin
insert into @Result
Select Distinct ParamMas.ParamType,
ParamFocus.PMProductName As ParamFocus,
Case ParamMas.ID When 3 Then Cast(ParamDet.MaxPoints as nVarchar(50)) Else '' End MaxPoints,
ParamDet.ParamID, --ParamFocus.FocusID,
Case IsNull(isFocusParameter,0) When 0 Then 0 Else ParamFocus.ProdCat_Level End ParamFocusLevel, Paramdet.ParameterType,ParamDet.DSTypeid,ParamMas.OrderBy
From tbl_mERP_PMParamType ParamMas, tbl_mERP_PMParam ParamDet, tbl_mERP_PMParamFocus ParamFocus
Where ParamMas.ID = ParamDet.ParameterType
And ParamDet.ParamID = ParamFocus.ParamID
And ParamDet.DSTypeID = @DSTypeID
Order by ParamMas.OrderBy --, Case IsNull(isFocusParameter,0) When 0 Then 0 Else ParamFocus.FocusID End
Return
End
|
EXEC dbo.deploy_seed_calendar
EXEC dbo.deploy_seed_conference
EXEC dbo.deploy_seed_contact
EXEC dbo.deploy_seed_field
EXEC dbo.deploy_seed_home_field
EXEC dbo.deploy_seed_league
EXEC dbo.deploy_seed_permit
EXEC dbo.deploy_seed_team
EXEC dbo.deploy_seed_team_off_day
EXEC dbo.deploy_seed_fixed_matchup |
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Mar 24, 2017 at 06:56 PM
-- Server version: 10.1.10-MariaDB
-- PHP Version: 5.6.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `kuwait_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `kudb_employees`
--
CREATE TABLE `kudb_employees` (
`id` int(11) UNSIGNED NOT NULL,
`firstName` varchar(100) DEFAULT NULL,
`lastName` varchar(100) DEFAULT NULL,
`gender` enum('male','female') DEFAULT NULL,
`address` varchar(200) DEFAULT NULL,
`dob` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `kudb_employees`
--
INSERT INTO `kudb_employees` (`id`, `firstName`, `lastName`, `gender`, `address`, `dob`) VALUES
(1, 'Airi', 'Satou', 'female', 'Tokyo', '1964-03-04'),
(2, 'Garrett', 'Winters', 'male', 'Tokyo', '1988-09-02'),
(3, 'John', 'Doe', 'male', 'Kansas', '1972-11-06'),
(4, 'Tatyana', 'Fitzpatrick', 'female', 'Londond', '1989-01-01'),
(5, 'Quinnd', 'Flynn', 'male', 'Edinburgh', '1977-03-24'),
(8, 'mohammed', 'shafeek', 'male', 'nil', '1977-03-10'),
(9, 'Suresh', 'CS', 'male', 'Sample man', '1977-03-12'),
(10, 'Sanu', 'mon', 'female', 'nilcxc', '1977-03-10');
-- --------------------------------------------------------
--
-- Table structure for table `kudb_users`
--
CREATE TABLE `kudb_users` (
`id` int(11) UNSIGNED NOT NULL,
`username` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`gender` enum('Male','Female') COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`status` tinyint(1) UNSIGNED NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `kudb_users`
--
INSERT INTO `kudb_users` (`id`, `username`, `email`, `password`, `gender`, `phone`, `created`, `modified`, `status`) VALUES
(1, 'shafeek', 'shafeek@sampledomain.in', '805c97123983fea2daf886f82db0bfa2', 'Male', '8956235689', '2017-03-10 16:25:20', '2017-03-15 19:00:21', 1),
(2, 'shafeek-2', 'shafeek2@sampledomain.in', '458d30a10e02e79752f7b3d58a39314c', 'Male', '8956235682', '2017-03-10 16:25:20', '2017-03-15 18:57:43', 1);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `kudb_employees`
--
ALTER TABLE `kudb_employees`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `kudb_users`
--
ALTER TABLE `kudb_users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`),
ADD UNIQUE KEY `email` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `kudb_employees`
--
ALTER TABLE `kudb_employees`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `kudb_users`
--
ALTER TABLE `kudb_users`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
/*!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 */;
|
SELECT city, count(city) FROM station
GROUP BY city
ORDER BY count(city) ASC
|
CREATE OR REPLACE VIEW rv_pp_mrp AS
SELECT
mrp.pp_mrp_id,
mrp.ad_client_id,
mrp.ad_org_id,
mrp.created,
mrp.createdby,
mrp.isactive,
mrp.isavailable,
mrp.updated,
mrp.updatedby,
pp.ismps,
mrp.name,
mrp.description,
mrp.c_order_id,
mrp.c_orderline_id,
mrp.dateOrdered,
mrp.dateConfirm,
mrp.datePromised,
mrp.dateStartSchedule,
mrp.dateFinishSchedule,
mrp.dateStart,
mrp.dateSimulation,
mrp.docStatus,
mrp.m_forecast_id,
mrp.m_forecastline_id,
mrp.value,
mrp.m_product_id,
mrp.m_requisition_id,
mrp.m_requisitionline_id,
mrp.m_warehouse_id,
mrp.pp_order_id,
mrp.pp_order_bomline_id,
mrp.dd_order_id,
mrp.dd_orderline_id,
mrp.qty,
mrp.s_resource_id,
mrp.planner_id,
mrp.priority,
mrp.ordertype,
mrp.typemrp,
p.LowLevel,
mrp.C_BPartner_ID,
mrp.version,
documentNo(mrp.pp_mrp_id) AS documentNo
FROM pp_mrp mrp
INNER JOIN M_Product p ON (mrp.M_Product_ID = p.M_Product_ID)
LEFT JOIN pp_product_planning pp ON (pp.m_product_id = mrp.m_product_id AND mrp.m_warehouse_id = pp.m_warehouse_id)
WHERE mrp.Qty<>0
UNION
SELECT
0 ,
pp.ad_client_id,
pp.ad_org_id,
pp.created,
pp.createdby,
pp.isactive,
'Y', -- mrp.isavailable
pp.updated,
pp.updatedby,
pp.ismps,
null, -- name
null, -- description
null, -- mrp.c_order_id
null, -- mrp.c_orderline_id
now(), -- mrp.dateordered,
now(), -- mrp.dateconfirm,
now(), -- mrp.datepromised,
now(), -- mrp.datestartschedule,
now(), -- mrp.datefinishschedule,
now(), -- mrp.datestart,
now(), -- mrp.datesimulation,
'CO', -- mrp.docstatus,
null, -- mrp.m_forecast_id,
null, -- mrp.m_forecastline_id,
null, -- mrp.value,
pp.m_product_id,
null, -- mrp.m_requisition_id,
null, -- mrp.m_requisitionline_id,
pp.m_warehouse_id,
null, -- mrp.pp_order_id,
null, -- pp_order_bomline_id
null, -- mrp.dd_order_id,
null, -- mrp.dd_orderline_id,
pp.safetystock - bomQtyOnHand(pp.M_Product_ID, pp.M_Warehouse_ID, 0) AS qty, -- mrp.qty,
pp.s_resource_id,
null, -- planner_id
null, -- mrp.priority,
'STK', -- mrp.ordertype,
'D' , -- mrp.typemrp,
p.LowLevel,
null, -- C_BPartner_ID
null AS version,
'Safety Stock' -- documentNo(mrp.pp_mrp_id) AS documentNo
FROM PP_Product_Planning pp
INNER JOIN M_Product p ON (pp.M_Product_ID = p.M_Product_ID)
WHERE bomQtyOnHand(pp.M_Product_ID,pp.M_Warehouse_ID, 0) < pp.safetystock
;
|
CREATE OR REPLACE PUBLIC SYNONYM eng_mbi_pkg FOR orient.eng_mbi_pkg; |
GENERATE HTML {e.Id, e.Name, e.salary} @ {insert} FROM employee e
|
/*
Update this file using this command:
grep -RihoP 'table .+(?=\()' --exclude drop* | awk '{print "DROP TABLE IF EXISTS", $NF, "CASCADE;"}'
*/
DROP TABLE IF EXISTS CourseAreas CASCADE;
DROP TABLE IF EXISTS CourseOfferings CASCADE;
DROP TABLE IF EXISTS CoursePackages CASCADE;
DROP TABLE IF EXISTS Courses CASCADE;
DROP TABLE IF EXISTS Customers CASCADE;
DROP TABLE IF EXISTS CreditCards CASCADE;
DROP TABLE IF EXISTS Employees CASCADE;
DROP TABLE IF EXISTS PartTimeEmployees CASCADE;
DROP TABLE IF EXISTS FullTimeEmployees CASCADE;
DROP TABLE IF EXISTS Managers CASCADE;
DROP TABLE IF EXISTS Administrators CASCADE;
DROP TABLE IF EXISTS Instructors CASCADE;
DROP TABLE IF EXISTS PartTimeInstructors CASCADE;
DROP TABLE IF EXISTS FullTimeInstructors CASCADE;
DROP TABLE IF EXISTS Owns CASCADE;
DROP TABLE IF EXISTS Buys CASCADE;
DROP TABLE IF EXISTS Redeems CASCADE;
DROP TABLE IF EXISTS Registers CASCADE;
DROP TABLE IF EXISTS PaySlips CASCADE;
DROP TABLE IF EXISTS Rooms CASCADE;
DROP TABLE IF EXISTS Sessions CASCADE;
DROP TABLE IF EXISTS Cancels CASCADE;
DROP TABLE IF EXISTS Specializes CASCADE;
|
CREATE TABLE departments (
dep_no VARCHAR(10) NOT NULL,
dept_name VARCHAR(20) NOT NULL,
PRIMARY KEY (dep_no)
);
CREATE TABLE employees (
emp_no INT NOT NULL,
birth_date DATE NOT NULL,
first_name VARCHAR(14) NOT NULL,
last_name VARCHAR(16) NOT NULL,
gender VARCHAR(1) NOT NULL,
hire_date DATE NOT NULL,
PRIMARY KEY (emp_no)
);
CREATE TABLE dept_emp (
emp_no INT NOT NULL,
dept_no VARCHAR(10) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
FOREIGN KEY (emp_no) REFERENCES employees(emp_no),
FOREIGN KEY (dept_no) REFERENCES departments(dep_no)
);
CREATE TABLE dept_manager (
dept_no VARCHAR(10) NOT NULL,
emp_no INT NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
FOREIGN KEY (emp_no) REFERENCES employees(emp_no),
FOREIGN KEY (dept_no) REFERENCES departments(dep_no)
);
CREATE TABLE salaries (
emp_no INT NOT NULL,
salary INT NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
FOREIGN KEY (emp_no) REFERENCES employees(emp_no)
);
CREATE TABLE titles (
emp_no INT NOT NULL,
title VARCHAR(20) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
FOREIGN KEY (emp_no) REFERENCES employees(emp_no)
);
-- List the following details of each employee: employee number, last name, first name, gender, and salary.
SELECT employees.emp_no, employees.first_name, employees.last_name, employees.gender, salaries.salary
FROM salaries
INNER JOIN employees ON
employees.emp_no=salaries.emp_no;
-- List employees who were hired in 1986.
SELECT *
FROM employees
WHERE employees.hire_date BETWEEN '$1986-01-01' AND '$1986-12-31'
-- List the manager of each department with the following information: department number, department name, the manager's employee number, last name, first name, and start and end employment dates.
SELECT employees.first_name, employees.last_name, departments.dept_name, dept_manager.dept_no, dept_manager.emp_no, dept_manager.from_date, dept_manager.to_date
FROM employees
INNER JOIN dept_manager ON employees.emp_no = dept_manager.emp_no
INNER JOIN departments ON dept_manager.dept_no = departments.dep_no
-- List the department of each employee with the following information: employee number, last name, first name, and department name.
SELECT employees.first_name, employees.last_name, departments.dept_name, dept_emp.emp_no
FROM employees
INNER JOIN dept_emp ON employees.emp_no = dept_emp.emp_no
INNER JOIN departments ON dept_emp.dept_no = departments.dep_no
-- List all employees whose first name is "Hercules" and last names begin with "B."
SELECT *
FROM employees
WHERE employees.first_name = 'Hercules' AND employees.last_name LIKE 'B%'
-- List all employees in the Sales department, including their employee number, last name, first name, and department name.
SELECT employees.first_name, employees.last_name, departments.dept_name, dept_emp.emp_no
FROM employees
INNER JOIN dept_emp ON employees.emp_no = dept_emp.emp_no
INNER JOIN departments ON dept_emp.dept_no = departments.dep_no
WHERE departments.dept_name = 'Sales'
-- List all employees in the Sales and Development departments, including their employee number, last name, first name, and department name.
SELECT employees.first_name, employees.last_name, departments.dept_name, dept_emp.emp_no
FROM employees
INNER JOIN dept_emp ON employees.emp_no = dept_emp.emp_no
INNER JOIN departments ON dept_emp.dept_no = departments.dep_no
WHERE departments.dept_name = 'Sales' OR departments.dept_name = 'Development'
-- In descending order, list the frequency count of employee last names, i.e., how many employees share each last name.
SELECT employees.last_name, COUNT(employees.last_name)
FROM employees
GROUP BY employees.last_name
ORDER BY COUNT(employees.last_name) DESC |
ALTER TABLE GEPARAME
ADD CD_TP_PESSOA_MEDICO NUMBER(6);
ALTER TABLE GEPARAME
ADD CONSTRAINT FK_GEPARAME_GETIPOPE_MED FOREIGN KEY (CD_TP_PESSOA_MEDICO)
REFERENCES GETIPOPE(CD_TP_PESSOA);
create index FK_GEPARAME_GETIPOPE_MED_ix on geparame(cd_tp_pessoa_medico)
tablespace indices_tablespace;
ALTER TABLE GEPARAME
ADD CD_TP_PESSOA_PACIENTE NUMBER(6);
ALTER TABLE GEPARAME
ADD CONSTRAINT FK_GEPARAME_GETIPOPE_PAC FOREIGN KEY (CD_TP_PESSOA_PACIENTE)
REFERENCES GETIPOPE(CD_TP_PESSOA);
create index FK_GEPARAME_GETIPOPE_PAC_ix on geparame(cd_tp_pessoa_paciente)
tablespace indices_tablespace;
ALTER TABLE GEPARAME
ADD CD_PESSOA_MEDICO_PADRAO NUMBER(6);
ALTER TABLE GEPARAME
ADD CONSTRAINT FK_GEPARAME_GEPESSOA_MED FOREIGN KEY (CD_PESSOA_MEDICO_PADRAO)
REFERENCES GEPESSOA(CD_PESSOA);
create index FK_GEPARAME_GEPESSOA_MED_ix on geparame(cd_pessoa_medico_padrao)
tablespace indices_tablespace;
|
-- phpMyAdmin SQL Dump
-- version 4.9.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Tempo de geração: 11-Nov-2020 às 20:24
-- Versão do servidor: 10.3.16-MariaDB
-- versão do PHP: 7.3.23
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 */;
--
-- Banco de dados: `id15354623_bancofilmes`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `filme`
--
CREATE TABLE `filme` (
`idfilme` int(4) NOT NULL,
`nomeFilme` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`idadeIndicativa` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`descricaoFilme` text COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Extraindo dados da tabela `filme`
--
INSERT INTO `filme` (`idfilme`, `nomeFilme`, `idadeIndicativa`, `descricaoFilme`) VALUES
(1, 'Vovó... Zona', '12 Anos', 'Um agente durão do FBI chega ao extremo para ficar na pista de um ladrão de bancos violento que fugiu da prisão. Enquanto se disfarça de avó obesa com uma língua afiada, ele é forçado a usar todas as suas habilidades, desde cozinhar a levar as crianças para a igreja local.');
--
-- Índices para tabelas despejadas
--
--
-- Índices para tabela `filme`
--
ALTER TABLE `filme`
ADD PRIMARY KEY (`idfilme`);
--
-- AUTO_INCREMENT de tabelas despejadas
--
--
-- AUTO_INCREMENT de tabela `filme`
--
ALTER TABLE `filme`
MODIFY `idfilme` int(4) 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 */;
|
/* 6. website 데이터베이스에 있는 회원정보를 수정하는 쿼리문을 작성하세요. */
update user set
user_pw = '1234',
user_email = '1234@naver.com',
user_nick = 'a123',
user_add = '서울특별시'
where user_id = 'a123';
select * from user;
|
DROP PROCEDURE `MLP_LOGIN` ;
DELIMITER //
CREATE DEFINER = `myspac17`@`localhost` PROCEDURE `MLP_LOGIN`
(
IN IN_EMAIL VARCHAR(50),
IN IN_PWD VARCHAR(50),
OUT OUT_RTN_CD INT,
OUT OUT_RTN_MSG VARCHAR(100),
OUT OUT_RTN_ROWS INT
)
NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER
BEGIN
DECLARE USR_ID INT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
@p1 = RETURNED_SQLSTATE, @p2 = MESSAGE_TEXT;
SET OUT_RTN_CD= @p1;
SET OUT_RTN_ROWS=0;
SET OUT_RTN_MSG= @p2;
END ;
SELECT COUNT(*),ID INTO OUT_RTN_ROWS , USR_ID FROM USR
WHERE EMAIL=IN_EMAIL AND PWDHASH=MD5(IN_PWD);
IF OUT_RTN_ROWS=1
THEN
SET OUT_RTN_CD= 0;
SET OUT_RTN_ROWS=USR_ID;
SET OUT_RTN_MSG= "Login successful";
ELSE
SET OUT_RTN_CD= -1;
SET OUT_RTN_MSG= "Invalid Credentials! Please try again";
END IF ;
END ;
//
DELIMITER;
|
select sum(`c1`), `c2`
from `empty`
group by `c2` |
create table register (
user_id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
user_name varchar(200) not null,
user_email varchar(200) not null UNIQUE,
user_password varchar(30) not null,
user_description varchar(300),
user_phone varchar(20)
)
create table data_user (
register_id UUID PRIMARY KEY DEFAULT uuid_generate_v4 (),
user_id uuid,
earnings text[],
losses text[],
bitcoin varchar(500),
following text[],
follower text[],
FOREIGN KEY (user_id) REFERENCES register (user_id)
)
-- Install generate guide postgresql
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; |
CREATE TABLE `auth`(
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`email` VARCHAR(255) NOT NULL,
`password_hash` TEXT NOT NULL,
`user_id` INT NOT NULL,
`tokens` JSON NULL COMMENT '[
{
\"token\": \"\",
\"ip\": \"\",
\"expire_at\": \"\",
\"sign\": \"\"
}
]'
);
ALTER TABLE
`auth` ADD UNIQUE `auth_email_unique`(`email`);
ALTER TABLE
`auth` ADD INDEX `auth_user_id_index`(`user_id`);
CREATE TABLE `users`(
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`fullname` JSON NOT NULL COMMENT '{
\"lastname\": \"\",
\"firstname\": \"\",
\"patronymic\": \"\"
}',
`location` JSON NOT NULL COMMENT '{
\"countryName\": \"\",
\"stateOrProvinceName\": \"\",
\"localityName\": \"\"
}',
`organization` JSON NOT NULL COMMENT '{
\"organizationName\": \"\",
\"organizationalUnitName\": \"\"
}',
`role` INT NOT NULL COMMENT '1 - Администратор системы;
2 - Администратор зоны (назначаемый);
3 - Обычный пользователь с подписями.'
);
CREATE TABLE `signatures`(
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`dn` JSON NOT NULL,
`path` TEXT NOT NULL,
`create_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`creater_id` INT NOT NULL,
`owner_id` INT NOT NULL,
`zone_id` INT NULL,
`passphrase` TEXT NOT NULL,
`valid_to` VARCHAR(255) NOT NULL,
`is_revoked` INT(1) NOT NULL DEFAULT 0
);
ALTER TABLE
`signatures` ADD INDEX `signatures_creater_id_index`(`creater_id`);
ALTER TABLE
`signatures` ADD INDEX `signatures_owner_id_index`(`owner_id`);
ALTER TABLE
`signatures` ADD INDEX `signatures_zone_id_index`(`zone_id`);
CREATE TABLE `log_of_signs`(
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`sign_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`signer_id` INT NOT NULL,
`sign_id` INT NOT NULL,
`filename` TEXT NOT NULL
);
ALTER TABLE
`log_of_signs` ADD INDEX `log_of_signs_signer_id_index`(`signer_id`);
ALTER TABLE
`log_of_signs` ADD INDEX `log_of_signs_sign_id_index`(`sign_id`);
CREATE TABLE `zones`(
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`dn` JSON NOT NULL,
`creater_id` INT NOT NULL,
`admin_id` INT NOT NULL,
`signature_id` INT NOT NULL
);
ALTER TABLE
`zones` ADD UNIQUE `zones_name_unique`(`name`);
ALTER TABLE
`zones` ADD INDEX `zones_creater_id_index`(`creater_id`);
ALTER TABLE
`zones` ADD INDEX `zones_admin_id_index`(`admin_id`);
ALTER TABLE
`zones` ADD INDEX `zones_signature_id_index`(`signature_id`);
ALTER TABLE
`signatures` ADD CONSTRAINT `signatures_creater_id_foreign` FOREIGN KEY(`creater_id`) REFERENCES `users`(`id`);
ALTER TABLE
`auth` ADD CONSTRAINT `auth_user_id_foreign` FOREIGN KEY(`user_id`) REFERENCES `users`(`id`);
ALTER TABLE
`signatures` ADD CONSTRAINT `signatures_owner_id_foreign` FOREIGN KEY(`owner_id`) REFERENCES `users`(`id`);
ALTER TABLE
`log_of_signs` ADD CONSTRAINT `log_of_signs_signer_id_foreign` FOREIGN KEY(`signer_id`) REFERENCES `users`(`id`);
ALTER TABLE
`zones` ADD CONSTRAINT `zones_creater_id_foreign` FOREIGN KEY(`creater_id`) REFERENCES `users`(`id`);
ALTER TABLE
`zones` ADD CONSTRAINT `zones_admin_id_foreign` FOREIGN KEY(`admin_id`) REFERENCES `users`(`id`);
ALTER TABLE
`log_of_signs` ADD CONSTRAINT `log_of_signs_sign_id_foreign` FOREIGN KEY(`sign_id`) REFERENCES `signatures`(`id`);
ALTER TABLE
`zones` ADD CONSTRAINT `zones_signature_id_foreign` FOREIGN KEY(`signature_id`) REFERENCES `signatures`(`id`);
ALTER TABLE
`signatures` ADD CONSTRAINT `signatures_zone_id_foreign` FOREIGN KEY(`zone_id`) REFERENCES `zones`(`id`); |
DELIMITER $$
DROP FUNCTION IF EXISTS __tfmt__FMSingle$$
CREATE FUNCTION __tfmt__FMSingle (rawTime int)
RETURNS varchar(50) DETERMINISTIC
BEGIN
RETURN CONCAT(rawTime);
END$$
DROP FUNCTION IF EXISTS __tfmt__FMAverage$$
CREATE FUNCTION __tfmt__FMAverage (rawTime int)
RETURNS varchar(50) DETERMINISTIC
BEGIN
RETURN CONCAT(rawTime DIV 100, ".", LPAD(CONCAT(rawTime % 100), 2, "0"));
END$$
DROP FUNCTION IF EXISTS __tfmt__normalTime$$
CREATE FUNCTION __tfmt__normalTime (rawTime int)
RETURNS varchar(40) DETERMINISTIC
BEGIN
DECLARE ret CHAR(40);
SET ret = CONCAT((rawTime DIV 100) % 60, ".", LPAD(CONCAT(rawTime % 100), 2, "0"));
SET ret = IF(rawTime >= 6000, CONCAT((rawTime DIV 6000) % 60, ":", LPAD(ret, 5, "0")), ret);
SET ret = IF(rawTime >= 360000, CONCAT(rawTime DIV 360000, ":", LPAD(ret, 8, "0")), ret);
RETURN ret;
END$$
DROP FUNCTION IF EXISTS __tfmt__MBimpl$$
CREATE FUNCTION __tfmt__MBimpl (solved int, attempted int, timeInSeconds int)
RETURNS varchar(50) DETERMINISTIC
BEGIN
DECLARE timeString CHAR(40);
SET timeString = __tfmt__normalTime(timeInSeconds * 100);
RETURN CONCAT(solved, "/", attempted, " ", SUBSTRING(timeString, 1, LENGTH(timeString) - 3));
END$$
DROP FUNCTION IF EXISTS __tfmt__MBF$$
CREATE FUNCTION __tfmt__MBF (rawTime int)
RETURNS varchar(50) DETERMINISTIC
BEGIN
DECLARE difference INT;
DECLARE timeInSeconds INT;
DECLARE missed INT;
SET difference = 99 - (rawTime DIV 10000000);
SET timeInSeconds = (rawTime % 10000000) DIV 100;
SET missed = rawTime % 100;
RETURN __tfmt__MBimpl (difference + missed, difference + missed + missed, timeInSeconds);
END$$
DROP FUNCTION IF EXISTS __tfmt__MBO$$
CREATE FUNCTION __tfmt__MBO (rawTime int)
RETURNS varchar(50) DETERMINISTIC
BEGIN
DECLARE solved INT;
DECLARE attempted INT;
DECLARE timeInSeconds INT;
SET solved = 99 - (rawTime DIV 10000000) % 100;
SET attempted = (rawTime DIV 100000) % 100;
SET timeInSeconds = (rawTime % 100000);
RETURN __tfmt__MBimpl (solved, attempted, timeInSeconds);
END$$
DROP FUNCTION IF EXISTS tfmt$$
CREATE FUNCTION tfmt (rawTime int, eventId varchar(50))
RETURNS varchar(50) DETERMINISTIC
BEGIN
RETURN CASE
WHEN rawTime = -1 THEN
"DNF"
WHEN rawTime = -2 THEN
"DNS"
WHEN rawTime = 0 THEN
""
WHEN eventId = "333fm" AND rawTime < 1000 THEN
__tfmt__FMSingle(rawTime)
WHEN eventId = "333fm" AND rawTime >= 1000 THEN
__tfmt__FMAverage(rawTime)
WHEN eventId = "333mbf" THEN
__tfmt__MBF(rawTime)
WHEN eventId = "333mbo" THEN
__tfmt__MBO(rawTime)
ELSE
__tfmt__normalTime(rawTime)
END;
END$$
DELIMITER ;
|
SET SERVEROUTPUT ON;
DECLARE
TYPE vehiculo IS RECORD ( -- Definimos el tipo de dato llamado vehiculo
marca nvarchar2(100),
modelo nvarchar2(100),
puertas number
);
mazda vehiculo;
toyota vehiculo;
-- Procedimiento de impresion
PROCEDURE imprimir_vehiculo( vh vehiculo )
IS
BEGIN
dbms_output.put_line( vh.marca );
dbms_output.put_line( vh.modelo );
dbms_output.put_line( vh.puertas );
END;
-- Fin procedimiento de imprecion
BEGIN
mazda.marca := 'Mazda';
mazda.modelo := 'Mazda 3';
mazda.puertas := 4;
toyota.marca := 'Toyota';
toyota.modelo := 'Prado';
toyota.puertas := 5;
imprimir_vehiculo( mazda );
imprimir_vehiculo( toyota );
END;
/ |
use BIGGYM;
-- 01
select
concat(per.FIRST_NAME, ' ', per.LAST_NAME, ' (aka ', prf.NAME, ')') PERSON,
round((datediff(curdate(), per.BIRTH_DATE) / 365),0) AGE,
prf.ID PROFILEid
from
PERSON per,
PROFILE prf
where
prf.PERSONid = per.ID
order by
per.BIRTH_DATE asc
;
-- 02
select
concat(per.FIRST_NAME, ' ', per.LAST_NAME, ' (aka ', prf.NAME, ')') PERSON,
round((datediff(curdate(), per.BIRTH_DATE) / 365),0) AGE,
plan.NAME PLAN_NAME,
plan.C_CREATE DATE_PLAN_WAS_REGISTERED,
plan.ID PLANid
from
PERSON per,
PROFILE prf,
TRAINING_PLAN plan
where
prf.PERSONid = per.ID
and
prf.ID = plan.PROFILEid
order by
per.BIRTH_DATE asc
;
-- 03
select
concat(per.FIRST_NAME, ' ', per.LAST_NAME, ' (aka ', prf.NAME, ')') PERSON,
round((datediff(curdate(), per.BIRTH_DATE) / 365),0) AGE,
plan.NAME PLAN_NAME,
plan.ID PLAN_ID,
plan.C_CREATE DATE_PLAN_WAS_REGISTERED,
def.ID DEFINITION_ID,
exc.BODY_PART,
exc.NAME
from
PERSON per,
PROFILE prf,
TRAINING_PLAN plan,
TRAINING_PLAN_DEFINITION def,
EXERCISE exc
where
prf.PERSONid = per.ID
and
prf.ID = plan.PROFILEid
and
plan.ID = def.PLANid
and
def.EXERCISEid = exc.ID
order by
per.BIRTH_DATE asc,
exc.BODY_PART asc
;
-- 04
select
concat(per.FIRST_NAME, ' ', per.LAST_NAME, ' (aka ', prf.NAME, ')') PERSON,
round((datediff(curdate(), per.BIRTH_DATE) / 365),0) AGE,
plan.NAME PLAN_NAME,
prg.C_CREATE TRAINING_DATE,
exc.BODY_PART,
exc.NAME,
concat(prg.SET_01_WEIGHT, 'kg', ' x', prg.SET_01_REPS) SET01,
concat(prg.SET_02_WEIGHT, 'kg', ' x', prg.SET_02_REPS) SET02,
concat(prg.SET_03_WEIGHT, 'kg', ' x', prg.SET_03_REPS) SET03,
(prg.SET_01_WEIGHT * prg.SET_01_REPS) +
(prg.SET_02_WEIGHT * prg.SET_02_REPS) +
(prg.SET_03_WEIGHT * prg.SET_03_REPS) TOTAL_KG,
(prg.SET_01_REPS) +
(prg.SET_02_REPS) +
(prg.SET_03_REPS) TOTAL_REPS,
round(
(
(prg.SET_01_WEIGHT * prg.SET_01_REPS) +
(prg.SET_02_WEIGHT * prg.SET_02_REPS) +
(prg.SET_03_WEIGHT * prg.SET_03_REPS)
)
/
(
(prg.SET_01_REPS) +
(prg.SET_02_REPS) +
(prg.SET_03_REPS)
)
,1) AVG_WEIGHT_PER_REP
from
PERSON per,
PROFILE prf,
TRAINING_PLAN plan,
TRAINING_PLAN_DEFINITION def,
EXERCISE exc,
PROGRESS prg
where
prf.PERSONid = per.ID
and
prf.ID = plan.PROFILEid
and
plan.ID = def.PLANid
and
def.EXERCISEid = exc.ID
and
def.ID = prg.DEFINITIONid
order by
PERSON asc,
exc.BODY_PART asc,
prg.C_CREATE asc
;
|
-- 문제1) EMPLOYEES 테이블에서 King의 정보를 소문자로 검색하고 사원번호,
-- 성명, 담당업무(소문자로),부서번호를 출력하라.
SELECT employee_id, first_name, lower(job_id), department_id
FROM employees
WHERE LOWER(last_name) LIKE LOWER('king');
-- 문제2) EMPLOYEES 테이블에서 King의 정보를 대문자로 검색하고 사원번호,
-- 성명, 담당업무(대문자로),부서번호를 출력하라.
SELECT employee_id, first_name, UPPER(job_id), department_id
FROM employees
WHERE UPPER(last_name) LIKE UPPER('king');
-- 문제3) DEPARTMENTS 테이블에서 부서번호와 부서이름, 부서이름과 위치번호를 합하여 출력하도록 하라.
SELECT department_id || ' ' ||department_name, department_name || ' ' || location_id
-- 동일한 구문 : CONCAT(department_id, department_name), AT(department_name, location_id)
FROM departments;
--문제4) EMPLOYEES 테이블에서 이름의 첫 글자가 ‘K’ 보다 크고 ‘Y’보다 적은
-- 사원의 정보를 사원번호, 이름, 업무, 급여, 부서번호를 출력하라.
-- 단 이름순으로 정렬하여라. **
SELECT employee_id, last_name, job_id, salary, department_id
FROM employees
WHERE SUBSTR(last_name, 1, 1) > 'K' AND SUBSTR(last_name, 1, 1) < 'Y'
ORDER BY last_name;
--문제5) EMPLOYEES 테이블에서 20번 부서 중 이름의 길이 및 급여의 자릿수를
--사원번호, 이름, 이름의 자릿수, 급여, 급여의 자릿수를 출력하라.
SELECT employee_id, last_name, LENGTH(LAST_NAME), salary, LENGTH(salary)
FROM employees
WHERE department_id = 20;
-- 문제6) EMPLOYEES 테이블에서 이름 중 ‘e’자의 위치를 출력하라.
SELECT INSTRB(last_name,'e') as "e location"
FROM employees;
-- 문제7) 다음의 쿼리를 실행하고 결과를 분석하라. ****
SELECT ROUND(4567.678),ROUND(4567.678,0), -- 4568, 4568
ROUND(4567.678,2),ROUND(4567.678,-2) -- 4567.68, 4600
FROM dual;
-- 문제8) EMPLOYEES 테이블에서 부서번호가 80인 사람의 급여를 30으로 나눈
--나머지를 구하여 출력하라.
SELECT MOD(salary, 30)
FROM employees
WHERE department_id = 80;
-- 문제9) EMPLOYEES 테이블에서 30번 부서 중 이름과 담당 업무를 연결하여출력하여라. 단 담당 업무를 한 줄 아래로 출력하라.
-- 보이기엔 한줄처럼 보이지만 그리드를 더블 클릭하면 개행 되었다는 것을 확인할 수 있습니다.
SELECT last_name || CHR(10) || job_id
FROM employees
WHERE department_id = 30;
-- 문제10) EMPLOYEES 테이블에서 현재까지 근무일 수가 몇주 몇일 인가를 출력하여라. 단 근무 일수가 많은 사람 순으로 출력하여라.
SELECT last_name, TRUNC((SYSDATE - hire_date)/7,0) 주, ROUND(MOD((SYSDATE - hire_date),7),0) 일
FROM employees
ORDER BY SYSDATE - hire_date DESC;
-- 문제11) EMPLOYEES 테이블에서 부서 50에서 급여 앞에 $를 삽입하고 3자리마다 ,를 출력하라
SELECT to_char(salary,'$999,999,999')
FROM employees
WHERE department_id = 50;
|
CREATE USER 'pucsd'@'localhost' IDENTIFIED BY 'pucsd';
CREATE DATABASE pucsdStudents;
GRANT ALL PRIVILEGES ON pucsdStudents . * TO 'pucsd'@'localhost';
use pucsdStudents;
create table studentData ( Name varchar(30) not null, Rollno int, Address varchar(50), Mobile_No numeric(10) not null, PAN_No varchar(8), primary key (Rollno) );
insert into studentData values('Mrunal Mandvekar', '18130', 'Rajur', '1234567890', 'ASDG9880');
insert into studentData values('Prachi Thakur', '18140', 'pune', '6718427389', 'ABHG9770');
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.