text stringlengths 6 9.38M |
|---|
■問題文
所属部署テーブル(depart)にない所属部署に属する社員を社員テーブル(employee)から抽出し、
所属部署コードを「Z99(未登録)」に変更しましょう。
以下の空欄を埋めて、SQL命令を完成させてください。
UPDATE
employee
SET
[空欄①]
WHERE
depart_id
[空欄②]
(
SELECT
[空欄③]
FROM
depart
)
;
■実行文
# 社員テーブルを更新する
UPDATE
employee
# 所属部署コードを「Z99(未登録)」に変更
SET
depart_id='Z99'
# 所属部署テーブル(depart)にない所属部署を更新する
WHERE
depart_id
NOT IN
(
SELECT
depart_id
FROM
depart
)
;
■返却値
mysql> # 社員テーブルを更新する
mysql> UPDATE
-> employee
-> # 所属部署コードを「Z99(未登録)」に変更
-> SET
-> depart_id='Z99'
-> # 所属部署テーブル(depart)にない所属部署を更新する
-> WHERE
-> depart_id
-> NOT IN
-> (
-> SELECT
-> depart_id
-> FROM
-> depart
-> )
-> ;
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0
【Before】
mysql> select s_id,depart_id from employee where depart_id not in (select depart_id from depart);
+---------+-----------+
| s_id | depart_id |
+---------+-----------+
| NI00001 | B01 |
| NI00002 | B01 |
+---------+-----------+
2 rows in set (0.03 sec)
【After】
mysql> select s_id,depart_id from employee where depart_id not in (select depart_id from depart);
+---------+-----------+
| s_id | depart_id |
+---------+-----------+
| NI00001 | Z99 |
| NI00002 | Z99 |
+---------+-----------+
2 rows in set (0.00 sec) |
-- CREATE DATABASE galileo;
CREATE EXTENSION postgis;
CREATE TABLE users (
user_id SERIAL PRIMARY KEY,
username varchar(50) UNIQUE,
password varchar(50),
first_name varchar(50),
last_name varchar(50),
email varchar(50)
);
CREATE TABLE spots (
spot_id SERIAL PRIMARY KEY,
host_id integer,
lat decimal,
long decimal,
address varchar(100),
type varchar(50),
price integer,
photo_url text,
geom GEOMETRY(Point, 4326)
);
CREATE TABLE bookings (
booking_id SERIAL PRIMARY KEY,
spot_id integer,
renter_id integer,
start_time bigint,
end_time bigint
);
CREATE INDEX spots_gix ON spots USING GIST (geom);
-- Add Fake Spot Data
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (1, 37.761980, -122.502070, '1323 42nd Ave, San Francisco, CA 94122', 'driveway', 5, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.761980 -122.502070)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (1, 37.761840, -122.502060, '1329 42nd Ave, San Francisco, CA 94122', 'driveway', 15, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.761840 -122.502060)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.762565959993495, -122.50153009990579, '4055 Irving St, San Francisco, CA 94122', 'driveway', 14, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.762565959993495 -122.50153009990579)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.762592178167665, -122.5063187612811, '4500 Irving St, San Francisco, CA 94122', 'driveway', 18, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.762592178167665 -122.5063187612811)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.76076090904784, -122.50437955942958, '3930 Judah St, San Francisco, CA 94122', 'street', 5, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.76076090904784 -122.50437955942958)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.76154124385957, -122.50194411366749, '1360 43rd Ave, San Francisco, CA 94122', 'street', 11, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.76154124385957 -122.50194411366749)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.75821628178477, -122.50155787553204, '1530 43rd Ave, San Francisco, CA 94122', 'lot', 19, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.75821628178477 -122.50155787553204)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.75686759386426, -122.502298165213, '3655 Lawton St, San Francisco, CA 94122', 'street', 21, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.75686759386426 -122.502298165213)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.75538644246041, -122.50336076285619, '3701 Noriega St, San Francisco, CA 94122', 'garage', 14, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.75538644246041 -122.50336076285619)');
INSERT INTO spots (host_id, lat, long, address, type, price, photo_url, geom) VALUES (2, 37.73330556691958, -122.50517183059404, 'Sloat Blvd & Upper Great Hwy, San Francisco, CA 94132', 'lot', 35, 'https://images.newscientist.com/wp-content/uploads/2013/10/mg22029415.600-1_800.jpg?width=778', 'POINT(37.73330556691958 -122.50517183059404)');
-- Normal search query
-- SELECT spot_id, host_id, lat, long, address, type, price, photo_url, ST_AsText(geom) AS geom FROM spots;
-- Actual distance between location1 and location 2 is around 550m. Here we take location1's coordinates as our centre. And we find all locations within 600m of this central location.
-- SELECT spot_id, address
-- FROM spots
-- WHERE ST_DWithin(
-- geom,
-- ST_GeomFromText('POINT(41.3954 2.162)', 4326)::geography,
-- 600
-- ); |
# import EditedThreads_Sample400.csv first
# retrieve all posts in threads
SELECT t.PostId as PostId, ParentId
FROM `sotorrent-extension.sample_400.EditedThreads_Sample400` s
JOIN `sotorrent-org.2019_03_17.Threads` t
ON s.PostId = t.ParentId;
=> Sample400_Posts
SELECT COUNT(*)
FROM `sotorrent-extension.sample_400.Sample400_Posts`;
=> 1,128
SELECT COUNT(DISTINCT PostId)
FROM `sotorrent-extension.sample_400.Sample400_Posts`
WHERE PostId = ParentId;
=> 399 (one thread deleted in the meantime)
# retrieve content of text blocks
SELECT PostId, ParentId, PostHistoryId, STRING_AGG(Content, "
") as TextBlockContent
FROM (
SELECT pbv.PostId AS PostId, ParentId, PostHistoryId, Content
FROM `sotorrent-extension.sample_400.Sample400_Posts` s
JOIN `sotorrent-org.2019_03_17.PostBlockVersion` pbv
ON s.PostId = pbv.PostId AND pbv.PostBlockTypeId = 1
ORDER BY PostId ASC, ParentId ASC, PostHistoryId ASC, LocalId ASC
)
GROUP BY PostId, ParentId, PostHistoryId;
=> Sample400_Posts_TextBlocks
SELECT COUNT(*)
FROM `sotorrent-extension.sample_400.Sample400_Posts_TextBlocks`;
=> 2,049
# retrieve content of comments
SELECT s.PostId AS PostId, ParentId, c.Id AS CommentId, Text AS CommentContent
FROM `sotorrent-extension.sample_400.Sample400_Posts` s
JOIN `sotorrent-org.2019_03_17.Comments` c
ON s.PostId = c.PostId
ORDER BY PostId ASC, ParentId ASC, CommentId ASC;
=> Sample400_Posts_Comments
SELECT COUNT(*)
FROM `sotorrent-extension.sample_400.Sample400_Posts_Comments`;
=> 2,255
|
-- asm_copyblock.sql
-- does not dump blocks to hex, but dumps to a datafile format
-- How to dump or extract a raw block from a file stored in ASM diskgroup (Doc ID 603962.1)
-- local: sqlplus / as sysasm
-- remote: sqlplus sys/password@//hostname/+ASM1 as sysasm
-- file will be on the db/asm server
declare
v_AsmFilename varchar2(4000);
v_FsFilename varchar2(4000);
v_offstart number;
v_numblks number;
v_filetype number;
v_filesize number;
v_lbks number;
v_typename varchar2(4000);
v_pblksize number;
v_handle number;
begin
dbms_output.enable(500000);
v_AsmFilename := '&ASM_File_Name';
v_offstart := '&block_to_extract';
v_numblks := '&number_of_blocks_to_extract';
v_FsFilename := '&FileSystem_File_Name';
dbms_diskgroup.getfileattr(v_AsmFilename,v_filetype,v_filesize,v_lbks);
dbms_diskgroup.open(v_AsmFilename,'r',v_filetype,v_lbks,v_handle,v_pblksize,v_filesize);
dbms_diskgroup.close(v_handle);
select
decode
(
v_filetype
,1,'Control File'
,2,'Data File'
,3,'Online Log File'
,4,'Archive Log'
,5,'Trace File'
,6,'Temporary File'
,7,'Not Used'
,8,'Not Used'
,9,'Backup Piece'
,10,'Incremental Backup Piece'
,11,'Archive Backup Piece'
,12,'Data File Copy'
,13,'Spfile'
,14,'Disaster Recovery Configuration'
,15,'Storage Manager Disk'
,16,'Change Tracking File'
,17,'Flashback Log File', 18,'DataPump Dump File'
,19,'Cross Platform Converted File'
,20,'Autobackup'
,21,'Any OS file'
,22,'Block Dump File', 23,'CSS Voting File'
,24,'CRS'
) into v_typename
from dual;
dbms_output.put_line('File: '||v_AsmFilename); dbms_output.new_line;
dbms_output.put_line('Type: '||v_filetype||' '||v_typename); dbms_output.new_line;
dbms_output.put_line('Size (in logical blocks): '||v_filesize); dbms_output.new_line;
dbms_output.put_line('Logical Block Size: '||v_lbks); dbms_output.new_line;
dbms_output.put_line('Physical Block Size: '||v_pblksize); dbms_output.new_line;
dbms_diskgroup.patchfile(v_AsmFilename,v_filetype,v_lbks,v_offstart,0,v_numblks,v_FsFilename,v_filetype,1,1);
end;
/
|
SELECT
SUM(season = 2014 and ((homeTeamId = 1003 and homeTeamScore > visitingTeamScore)
or (visitingTeamId = 1003 and homeTeamScore < visitingTeamScore))) AS Victories,
SUM(season = 2014 and ((homeTeamId = 1003 and homeTeamScore < visitingTeamScore)
or (visitingTeamId = 1003 and homeTeamScore > visitingTeamScore))) AS Defeats
FROM csf_scheduleresults
|
INSERT INTO persona
(id,
username,
nombre,
celular,
email)
VALUES
(:id,
:username,
:nombre,
:celular,
:email); |
CREATE TABLE IF NOT EXISTS `login_tokens` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`token` char(32) NOT NULL,
`duration` varchar(32) NOT NULL,
`used` tinyint(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL,
`expires` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `tmp_emails` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`email` varchar(256) DEFAULT NULL,
`code` varchar(50) DEFAULT NULL,
`created` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fb_id` bigint(100) DEFAULT NULL,
`fb_access_token` text,
`twt_id` bigint(100) DEFAULT NULL,
`twt_access_token` text,
`twt_access_secret` text,
`ldn_id` varchar(100) DEFAULT NULL,
`user_group_id` varchar(256) DEFAULT NULL,
`username` varchar(100) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`salt` varchar(100) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`first_name` varchar(100) DEFAULT NULL,
`last_name` varchar(100) DEFAULT NULL,
`active` varchar(3) DEFAULT '0',
`email_verified` int(1) NOT NULL,
`last_login` datetime DEFAULT NULL,
`by_admin` int(1) NOT NULL DEFAULT '0',
`ip_address` varchar(50) DEFAULT NULL,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user` (`username`),
KEY `mail` (`email`),
KEY `users_FKIndex1` (`user_group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `users` (`id`, `fb_id`, `fb_access_token`, `twt_id`, `twt_access_token`, `twt_access_secret`, `ldn_id`, `user_group_id`, `username`, `password`, `salt`, `email`, `first_name`, `last_name`, `active`, `email_verified`, `last_login`, `by_admin`, `ip_address`, `created`, `modified`) VALUES
(1, NULL, NULL, NULL, NULL, NULL, NULL, '1', 'admin', 'b2aae31278a1f3a911f84497a7182ee0', '6adf262cff5454313b6f65800a6c9859', 'admin@admin.com', 'Admin', '', '1', 1, '2012-04-14 10:11:52', 0, '', now(), now());
CREATE TABLE IF NOT EXISTS `user_activities` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`useragent` varchar(256) DEFAULT NULL,
`user_id` int(10) DEFAULT NULL,
`last_action` int(10) DEFAULT NULL,
`last_url` text,
`logout_time` int(10) DEFAULT NULL,
`user_browser` text,
`ip_address` varchar(50) DEFAULT NULL,
`logout` int(11) NOT NULL DEFAULT '0',
`deleted` int(1) NOT NULL DEFAULT '0',
`status` int(1) NOT NULL DEFAULT '0',
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `user_details` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user_id` int(10) DEFAULT NULL,
`gender` varchar(10) DEFAULT NULL,
`photo` text,
`bday` date DEFAULT NULL,
`location` varchar(256) DEFAULT NULL,
`marital_status` varchar(20) DEFAULT NULL,
`cellphone` varchar(15) DEFAULT NULL,
`web_page` text,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `user_details` (`id`, `user_id`, `gender`, `photo`, `bday`, `location`, `marital_status`, `cellphone`, `web_page`, `created`, `modified`) VALUES
(1, 1, 'male', '', '1986-01-30', '', 'single', '', '', now(), now());
CREATE TABLE IF NOT EXISTS `user_groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(10) NOT NULL DEFAULT '0',
`name` varchar(100) DEFAULT NULL,
`alias_name` varchar(100) DEFAULT NULL,
`description` TEXT NULL,
`allowRegistration` int(1) NOT NULL DEFAULT '1',
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
INSERT INTO `user_groups` (`id`, `parent_id`, `name`, `alias_name`, `description`, `allowRegistration`, `created`, `modified`) VALUES
(1, 0, 'Admin', 'Admin', NULL, 0, now(), now()),
(2, 0, 'User', 'User', NULL, 1, now(), now()),
(3, 0, 'Guest', 'Guest', NULL, 0, now(), now());
CREATE TABLE IF NOT EXISTS `user_group_permissions` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_group_id` int(10) unsigned NOT NULL,
`controller` varchar(50) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`action` varchar(100) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`allowed` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=170 ;
INSERT INTO `user_group_permissions` (`id`, `user_group_id`, `controller`, `action`, `allowed`) VALUES
(1, 1, 'Pages', 'display', 1),
(2, 2, 'Pages', 'display', 1),
(3, 3, 'Pages', 'display', 1),
(4, 1, 'UserGroupPermissions', 'index', 1),
(5, 2, 'UserGroupPermissions', 'index', 0),
(6, 3, 'UserGroupPermissions', 'index', 0),
(7, 1, 'UserGroups', 'index', 1),
(8, 2, 'UserGroups', 'index', 0),
(9, 3, 'UserGroups', 'index', 0),
(10, 1, 'UserGroups', 'addGroup', 1),
(11, 2, 'UserGroups', 'addGroup', 0),
(12, 3, 'UserGroups', 'addGroup', 0),
(13, 1, 'UserGroups', 'editGroup', 1),
(14, 2, 'UserGroups', 'editGroup', 0),
(15, 3, 'UserGroups', 'editGroup', 0),
(16, 1, 'UserGroups', 'deleteGroup', 1),
(17, 2, 'UserGroups', 'deleteGroup', 0),
(18, 3, 'UserGroups', 'deleteGroup', 0),
(19, 1, 'UserSettings', 'index', 1),
(20, 2, 'UserSettings', 'index', 0),
(21, 3, 'UserSettings', 'index', 0),
(22, 1, 'UserSettings', 'editSetting', 1),
(23, 2, 'UserSettings', 'editSetting', 0),
(24, 3, 'UserSettings', 'editSetting', 0),
(25, 1, 'Users', 'index', 1),
(26, 2, 'Users', 'index', 0),
(27, 3, 'Users', 'index', 0),
(28, 1, 'Users', 'online', 1),
(29, 2, 'Users', 'online', 0),
(30, 3, 'Users', 'online', 0),
(31, 1, 'Users', 'viewUser', 1),
(32, 2, 'Users', 'viewUser', 0),
(33, 3, 'Users', 'viewUser', 0),
(34, 1, 'Users', 'myprofile', 0),
(35, 2, 'Users', 'myprofile', 1),
(36, 3, 'Users', 'myprofile', 0),
(37, 1, 'Users', 'editProfile', 1),
(38, 2, 'Users', 'editProfile', 1),
(39, 3, 'Users', 'editProfile', 0),
(40, 1, 'Users', 'login', 1),
(41, 2, 'Users', 'login', 1),
(42, 3, 'Users', 'login', 1),
(43, 1, 'Users', 'logout', 1),
(44, 2, 'Users', 'logout', 1),
(45, 3, 'Users', 'logout', 1),
(46, 1, 'Users', 'register', 1),
(47, 2, 'Users', 'register', 1),
(48, 3, 'Users', 'register', 1),
(49, 1, 'Users', 'changePassword', 1),
(50, 2, 'Users', 'changePassword', 1),
(51, 3, 'Users', 'changePassword', 0),
(52, 1, 'Users', 'changeUserPassword', 1),
(53, 2, 'Users', 'changeUserPassword', 0),
(54, 3, 'Users', 'changeUserPassword', 0),
(55, 1, 'Users', 'addUser', 1),
(56, 2, 'Users', 'addUser', 0),
(57, 3, 'Users', 'addUser', 0),
(58, 1, 'Users', 'editUser', 1),
(59, 2, 'Users', 'editUser', 0),
(60, 3, 'Users', 'editUser', 0),
(61, 1, 'Users', 'deleteUser', 1),
(62, 2, 'Users', 'deleteUser', 0),
(63, 3, 'Users', 'deleteUser', 0),
(64, 1, 'Users', 'deleteAccount', 0),
(65, 2, 'Users', 'deleteAccount', 1),
(66, 3, 'Users', 'deleteAccount', 0),
(67, 1, 'Users', 'logoutUser', 1),
(68, 2, 'Users', 'logoutUser', 0),
(69, 3, 'Users', 'logoutUser', 0),
(70, 1, 'Users', 'makeInactive', 1),
(71, 2, 'Users', 'makeInactive', 0),
(72, 3, 'Users', 'makeInactive', 0),
(73, 1, 'Users', 'dashboard', 1),
(74, 2, 'Users', 'dashboard', 1),
(75, 3, 'Users', 'dashboard', 1),
(76, 1, 'Users', 'makeActiveInactive', 1),
(77, 2, 'Users', 'makeActiveInactive', 0),
(78, 3, 'Users', 'makeActiveInactive', 0),
(79, 1, 'Users', 'verifyEmail', 1),
(80, 2, 'Users', 'verifyEmail', 0),
(81, 3, 'Users', 'verifyEmail', 0),
(82, 1, 'Users', 'accessDenied', 1),
(83, 2, 'Users', 'accessDenied', 1),
(84, 3, 'Users', 'accessDenied', 0),
(85, 1, 'Users', 'userVerification', 1),
(86, 2, 'Users', 'userVerification', 1),
(87, 3, 'Users', 'userVerification', 1),
(88, 1, 'Users', 'forgotPassword', 1),
(89, 2, 'Users', 'forgotPassword', 1),
(90, 3, 'Users', 'forgotPassword', 1),
(91, 1, 'Users', 'emailVerification', 1),
(92, 2, 'Users', 'emailVerification', 1),
(93, 3, 'Users', 'emailVerification', 1),
(94, 1, 'Users', 'activatePassword', 1),
(95, 2, 'Users', 'activatePassword', 1),
(96, 3, 'Users', 'activatePassword', 1),
(97, 1, 'UserGroupPermissions', 'update', 1),
(98, 2, 'UserGroupPermissions', 'update', 0),
(99, 3, 'UserGroupPermissions', 'update', 0),
(100, 1, 'Users', 'deleteCache', 1),
(101, 2, 'Users', 'deleteCache', 0),
(102, 3, 'Users', 'deleteCache', 0),
(103, 1, 'Autocomplete', 'fetch', 1),
(104, 2, 'Autocomplete', 'fetch', 1),
(105, 3, 'Autocomplete', 'fetch', 1),
(106, 1, 'Users', 'viewUserPermissions', 1),
(107, 2, 'Users', 'viewUserPermissions', 0),
(108, 3, 'Users', 'viewUserPermissions', 0),
(109, 1, 'Contents', 'index', 1),
(110, 2, 'Contents', 'index', 0),
(111, 3, 'Contents', 'index', 0),
(112, 1, 'Contents', 'addPage', 1),
(113, 2, 'Contents', 'addPage', 0),
(114, 3, 'Contents', 'addPage', 0),
(115, 1, 'Contents', 'editPage', 1),
(116, 2, 'Contents', 'editPage', 0),
(117, 3, 'Contents', 'editPage', 0),
(118, 1, 'Contents', 'viewPage', 1),
(119, 2, 'Contents', 'viewPage', 0),
(120, 3, 'Contents', 'viewPage', 0),
(121, 1, 'Contents', 'deletePage', 1),
(122, 2, 'Contents', 'deletePage', 0),
(123, 3, 'Contents', 'deletePage', 0),
(124, 1, 'Contents', 'content', 1),
(125, 2, 'Contents', 'content', 1),
(126, 3, 'Contents', 'content', 1),
(127, 1, 'UserContacts', 'index', 1),
(128, 2, 'UserContacts', 'index', 0),
(129, 3, 'UserContacts', 'index', 0),
(130, 1, 'UserContacts', 'contactUs', 1),
(131, 2, 'UserContacts', 'contactUs', 1),
(132, 3, 'UserContacts', 'contactUs', 1),
(133, 1, 'Users', 'ajaxLoginRedirect', 1),
(134, 2, 'Users', 'ajaxLoginRedirect', 1),
(135, 3, 'Users', 'ajaxLoginRedirect', 1),
(136, 1, 'Users', 'viewProfile', 1),
(137, 2, 'Users', 'viewProfile', 1),
(138, 3, 'Users', 'viewProfile', 1),
(139, 1, 'Users', 'sendMails', 1),
(140, 2, 'Users', 'sendMails', 0),
(141, 3, 'Users', 'sendMails', 0),
(142, 1, 'Users', 'searchEmails', 1),
(143, 2, 'Users', 'searchEmails', 0),
(144, 3, 'Users', 'searchEmails', 0),
(145, 1, 'UserEmails', 'index', 1),
(146, 1, 'UserEmails', 'send', 1),
(147, 1, 'UserEmails', 'sendToUser', 1),
(148, 1, 'UserEmails', 'sendReply', 1),
(149, 1, 'UserEmails', 'view', 1),
(150, 1, 'UserGroupPermissions', 'subPermissions', 1),
(151, 1, 'UserGroupPermissions', 'getPermissions', 1),
(152, 1, 'UserGroupPermissions', 'permissionGroupMatrix', 1),
(153, 1, 'UserGroupPermissions', 'permissionSubGroupMatrix', 1),
(154, 1, 'UserGroupPermissions', 'changePermission', 1),
(155, 1, 'Users', 'indexSearch', 1),
(156, 1, 'UserEmailSignatures', 'index', 1),
(157, 1, 'UserEmailSignatures', 'add', 1),
(158, 1, 'UserEmailSignatures', 'edit', 1),
(159, 1, 'UserEmailSignatures', 'delete', 1),
(160, 1, 'UserEmailTemplates', 'index', 1),
(161, 1, 'UserEmailTemplates', 'add', 1),
(162, 1, 'UserEmailTemplates', 'edit', 1),
(163, 1, 'UserEmailTemplates', 'delete', 1),
(164, 1, 'UserSettings', 'cakelog', 1),
(165, 1, 'UserSettings', 'cakelogbackup', 1),
(166, 1, 'UserSettings', 'cakelogdelete', 1),
(167, 1, 'UserSettings', 'cakelogempty', 1),
(168, 1, 'Users', 'addMultipleUsers', 1),
(169, 1, 'Users', 'uploadCsv', 1);
CREATE TABLE IF NOT EXISTS `user_settings` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(256) DEFAULT NULL,
`name_public` text,
`value` text,
`type` varchar(50) DEFAULT NULL,
`category` varchar(20) DEFAULT 'OTHER',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=53 ;
INSERT INTO `user_settings` (`id`, `name`, `name_public`, `value`, `type`, `category`) VALUES
(1, 'defaultTimeZone', 'Enter default time zone identifier', 'America/New_York', 'input', 'OTHER'),
(2, 'siteName', 'Enter Your Site Name', 'User Management Plugin', 'input', 'OTHER'),
(3, 'siteRegistration', 'New Registration is allowed or not', '1', 'checkbox', 'USER'),
(4, 'allowDeleteAccount', 'Allow users to delete account', '0', 'checkbox', 'USER'),
(5, 'sendRegistrationMail', 'Send Registration Mail After User Registered', '1', 'checkbox', 'EMAIL'),
(6, 'sendPasswordChangeMail', 'Send Password Change Mail After User changed password', '1', 'checkbox', 'EMAIL'),
(7, 'emailVerification', 'Want to verify user''s email address?', '1', 'checkbox', 'EMAIL'),
(8, 'emailFromAddress', 'Enter email by which emails will be send.', 'example@example.com', 'input', 'EMAIL'),
(9, 'emailFromName', 'Enter Email From Name', 'User Management Plugin', 'input', 'EMAIL'),
(10, 'allowChangeUsername', 'Do you want to allow users to change their username?', '0', 'checkbox', 'USER'),
(11, 'bannedUsernames', 'Set banned usernames comma separated(no space, no quotes)', 'Administrator, SuperAdmin', 'input', 'USER'),
(12, 'useRecaptcha', 'Do you want to add captcha support on registration form, contact us form, login form in case bad logins, forgot password page, email verification page? Please note we have separate settings for all pages to Add or Remove captcha.', '0', 'checkbox', 'RECAPTCHA'),
(13, 'privateKeyFromRecaptcha', 'Enter private key for Recaptcha from google', '', 'input', 'RECAPTCHA'),
(14, 'publicKeyFromRecaptcha', 'Enter public key for recaptcha from google', '', 'input', 'RECAPTCHA'),
(15, 'loginRedirectUrl', 'Enter URL where user will be redirected after login ', '/dashboard', 'input', 'OTHER'),
(16, 'logoutRedirectUrl', 'Enter URL where user will be redirected after logout', '/login', 'input', 'OTHER'),
(17, 'permissions', 'Do you Want to enable permissions for users?', '1', 'checkbox', 'PERMISSION'),
(18, 'adminPermissions', 'Do you want to check permissions for Admin?', '0', 'checkbox', 'PERMISSION'),
(19, 'defaultGroupId', 'Enter default group id for user registration', '2', 'input', 'GROUP'),
(20, 'adminGroupId', 'Enter Admin Group Id', '1', 'input', 'GROUP'),
(21, 'guestGroupId', 'Enter Guest Group Id', '3', 'input', 'GROUP'),
(22, 'useFacebookLogin', 'Want to use Facebook Connect on your site?', '0', 'checkbox', 'FACEBOOK'),
(23, 'facebookAppId', 'Facebook Application Id', '', 'input', 'FACEBOOK'),
(24, 'facebookSecret', 'Facebook Application Secret Code', '', 'input', 'FACEBOOK'),
(25, 'facebookScope', 'Facebook Permissions', 'user_status, publish_stream, email', 'input', 'FACEBOOK'),
(26, 'useTwitterLogin', 'Want to use Twitter Connect on your site?', '0', 'checkbox', 'TWITTER'),
(27, 'twitterConsumerKey', 'Twitter Consumer Key', '', 'input', 'TWITTER'),
(28, 'twitterConsumerSecret', 'Twitter Consumer Secret', '', 'input', 'TWITTER'),
(29, 'useGmailLogin', 'Want to use Gmail Connect on your site?', '1', 'checkbox', 'GOOGLE'),
(30, 'useYahooLogin', 'Want to use Yahoo Connect on your site?', '1', 'checkbox', 'YAHOO'),
(31, 'useLinkedinLogin', 'Want to use Linkedin Connect on your site?', '0', 'checkbox', 'LINKEDIN'),
(32, 'linkedinApiKey', 'Linkedin Api Key', '', 'input', 'LINKEDIN'),
(33, 'linkedinSecretKey', 'Linkedin Secret Key', '', 'input', 'LINKEDIN'),
(34, 'useFoursquareLogin', 'Want to use Foursquare Connect on your site?', '0', 'checkbox', 'FOURSQUARE'),
(35, 'foursquareClientId', 'Foursquare Client Id', '', 'input', 'FOURSQUARE'),
(36, 'foursquareClientSecret', 'Foursquare Client Secret', '', 'input', 'FOURSQUARE'),
(37, 'viewOnlineUserTime', 'You can view online users and guest from last few minutes, set time in minutes ', '30', 'input', 'USER'),
(38, 'useHttps', 'Do you want to HTTPS for whole site?', '0', 'checkbox', 'OTHER'),
(39, 'httpsUrls', 'You can set selected urls for HTTPS (e.g. users/login, users/register)', NULL, 'input', 'OTHER'),
(40, 'imgDir', 'Enter Image directory name where users profile photos will be uploaded. This directory should be in webroot/img directory', 'umphotos', 'input', 'OTHER'),
(41, 'QRDN', 'Increase this number by 1 every time if you made any changes in CSS or JS file', '12345678', 'input', 'OTHER'),
(42, 'cookieName', 'Please enter cookie name for your site which is used to login user automatically for remember me functionality', 'UMPremiumCookie', 'input', 'OTHER'),
(43, 'adminEmailAddress', 'Admin Email address for emails', '', 'input', 'EMAIL'),
(44, 'useRecaptchaOnLogin', 'Do you want to add captcha support on login form in case bad logins? For this feature you must have Captcha setting ON with valid private and public keys.', '1', 'checkbox', 'RECAPTCHA'),
(45, 'badLoginAllowCount', 'Set number of allowed bad logins. for e.g. 5 or 10. For this feature you must have Captcha setting ON with valid private and public keys.', '5', 'input', 'RECAPTCHA'),
(46, 'useRecaptchaOnRegistration', 'Do you want to add captcha support on registration form? For this feature you must have Captcha setting ON with valid private and public keys.', '1', 'checkbox', 'RECAPTCHA'),
(47, 'useRecaptchaOnForgotPassword', 'Do you want to add captcha support on forgot password page? For this feature you must have Captcha setting ON with valid private and public keys.', '1', 'checkbox', 'RECAPTCHA'),
(48, 'useRecaptchaOnEmailVerification', 'Do you want to add captcha support on email verification page? For this feature you must have Captcha setting ON with valid private and public keys.', '1', 'checkbox', 'RECAPTCHA'),
(49, 'useRememberMe', 'Set true/false if you want to add/remove remember me feature on login page', '1', 'checkbox', 'USER'),
(50, 'allowUserMultipleLogin', 'Do you want to allow multiple logins with same user account for users(not admin)?', '1', 'checkbox', 'USER'),
(51, 'allowAdminMultipleLogin', 'Do you want to allow multiple logins with same user account for admin(not users)?', '1', 'checkbox', 'USER'),
(52, 'loginIdleTime', 'Set max idle time in minutes for user. This idle time will be used when multiple logins are not allowed for same user account. If max idle time reached since user last activity on site then anyone can login with same account in other browser and idle user will be logged out.', '10', 'input', 'USER'),
(53, 'gmailApiKey', 'Google Api Key', '', 'input', 'GOOGLE'),
(54, 'gmailClientId', 'Google Client Id', '', 'input', 'GOOGLE'),
(55, 'gmailClientSecret', 'Google Client Secret', '', 'input', 'GOOGLE');
CREATE TABLE IF NOT EXISTS `contents` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`page_name` text,
`url_name` text,
`page_content` text,
`page_title` text,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `user_contacts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(10) DEFAULT NULL,
`name` varchar(100) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`requirement` text,
`reply_message` text,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `user_emails` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`type` varchar(20) DEFAULT NULL,
`user_group_id` varchar(256) DEFAULT NULL,
`cc_to` text,
`from_name` varchar(200) DEFAULT NULL,
`from_email` varchar(200) DEFAULT NULL,
`subject` varchar(500) NOT NULL,
`message` text NOT NULL,
`sent_by` int(10) DEFAULT NULL,
`is_email_sent` int(1) NOT NULL DEFAULT '0',
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `user_email_recipients` (
`id` int(100) NOT NULL AUTO_INCREMENT,
`user_email_id` int(10) NOT NULL,
`user_id` int(10) DEFAULT NULL,
`email_address` varchar(100) NOT NULL,
`is_email_sent` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `user_email_templates` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`template_name` varchar(100) NOT NULL,
`header` text,
`footer` text,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `user_email_signatures` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`signature_name` varchar(100) NOT NULL,
`signature` text,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; |
SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `#__deallab_addresses`;
CREATE TABLE `#__deallab_addresses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deal_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL,
`ordering` int(11) NOT NULL,
`lat` varchar(30) NOT NULL DEFAULT '',
`lng` varchar(30) NOT NULL DEFAULT '',
`info` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `deal` (`deal_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_callbacks`;
CREATE TABLE `#__deallab_callbacks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL,
`status` tinyint(1) NOT NULL,
`manual` tinyint(1) NOT NULL DEFAULT '0',
`info` varchar(255) NOT NULL,
`cdate` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_categories`;
CREATE TABLE `#__deallab_categories` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL,
`ordering` int(11) NOT NULL,
`state` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_cities`;
CREATE TABLE `#__deallab_cities` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL,
`ordering` int(11) NOT NULL,
`state` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_coupons`;
CREATE TABLE `#__deallab_coupons` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deal_id` int(11) NOT NULL,
`order_id` int(11) NOT NULL,
`code` varchar(16) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0',
`cdate` datetime NOT NULL,
`pdf` varchar(64) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_customfields`;
CREATE TABLE `#__deallab_customfields` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deal_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '',
`value` text NOT NULL,
`ordering` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `deal_id` (`deal_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_deal_categories`;
CREATE TABLE `#__deallab_deal_categories` (
`deal_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
PRIMARY KEY (`deal_id`,`category_id`),
KEY `deal_id` (`deal_id`),
KEY `category_id` (`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
DROP TABLE IF EXISTS `#__deallab_deal_cities`;
CREATE TABLE `#__deallab_deal_cities` (
`city_id` int(11) NOT NULL,
`deal_id` int(11) NOT NULL,
PRIMARY KEY (`city_id`,`deal_id`),
KEY `deal_id` (`deal_id`),
KEY `city_id` (`city_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
DROP TABLE IF EXISTS `#__deallab_deals`;
CREATE TABLE `#__deallab_deals` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL,
`description` mediumtext,
`min_coupons` int(11) NOT NULL,
`fb_comment` tinyint(1) NOT NULL DEFAULT '0',
`fb_like` tinyint(1) NOT NULL DEFAULT '0',
`g_plus` tinyint(1) NOT NULL DEFAULT '0',
`friend_buy` tinyint(1) NOT NULL DEFAULT '0',
`ordering` int(11) NOT NULL,
`publish_up` datetime NOT NULL,
`publish_down` datetime NOT NULL,
`cpn_valid_from` datetime NOT NULL,
`cpn_valid_till` datetime NOT NULL,
`checked_out` int(11) NOT NULL,
`checked_out_time` datetime NOT NULL,
`use_shipping` tinyint(1) NOT NULL DEFAULT '0',
`price_type` tinyint(1) NOT NULL,
`shipping` text,
`merchant_title` varchar(64) NOT NULL,
`merchant_email` varchar(64) NOT NULL,
`options` text NOT NULL,
`state` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_images`;
CREATE TABLE `#__deallab_images` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deal_id` int(11) NOT NULL,
`original` varchar(255) NOT NULL,
`ordering` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `deal_id` (`deal_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_orders`;
CREATE TABLE `#__deallab_orders` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deal_id` int(11) NOT NULL,
`option_id` int(11) NOT NULL,
`address_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL DEFAULT '0',
`email` varchar(64) NOT NULL,
`details` text,
`notes` text,
`amount` double NOT NULL,
`currency` varchar(5) NOT NULL,
`shipping` tinyint(1) NOT NULL DEFAULT '0',
`status` tinyint(1) NOT NULL DEFAULT '0',
`gateway` varchar(64) NOT NULL,
`mail_sent` tinyint(1) NOT NULL DEFAULT '0',
`cdate` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `#__deallab_prices`;
CREATE TABLE `#__deallab_prices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deal_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`price` double NOT NULL,
`value` double NOT NULL,
`max_coupons` int(11) NOT NULL,
`ordering` int(11) NOT NULL,
`published` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `deal_id` (`deal_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; |
CREATE TABLE Ordered (
OrderId INTEGER NOT NULL,
WhenMade TIMESTAMP NOT NULL,
Customer INTEGER NOT NULL,
WayIssued VARCHAR(20),
PaymentBy VARCHAR(20) NOT NULL,
TotalPrice DECIMAL(6,2) NOT NULL,
CONSTRAINT pk_order PRIMARY KEY (OrderId),
CONSTRAINT fk_ordercustomer FOREIGN KEY (Customer)
REFERENCES Customer
);
|
create table tblRubriek(
rubriekNummer int not null,
rubriekNaam varchar(100) not null,
parentRubriek int null,
volgnr int not null,
constraint pk_tblRubriek primary key (rubriekNummer),
constraint fk_rubriek_rubriek foreign key (parentRubriek) references tblRubriek(rubriekNummer),
constraint ck_rubrieknummer_volgnr check (rubriekNummer = volgnr)
)
create table tblVoorwerp(
voorwerpNummer bigint not null,
titel varchar(50) not null,
beschrijving varchar(max) not null,
startPrijs numeric(11,2) not null,
betaalWijze varchar(16) not null,
betalingsInstructie varchar(max) null,
plaatsnaam varchar(60) not null,
land varchar (50) not null,
looptijd int not null,
looptijdBeginDag date not null,
looptijdBeginTijdstip time not null,
verzendkosten numeric(5,2) null,
verzendInstructie varchar(max) null,
verkoper varchar(20) not null,
koper varchar(20) null,
looptijdEindeDag date not null,
looptijdEindeTijdstip time not null,
veilingGesloten bit not null,
verkoopPrijs numeric (11,2) null,
constraint pk_tblVoorwerp primary key(voorwerpnummer)
)
create table tblVoorwerpRubriek(
voorwerpNummer bigint not null,
rubriekNummer int not null,
constraint pk_tblVoorwerpRubriek primary key (voorwerpNummer,rubriekNummer),
constraint fk_tblVoorwerpRubriek_voorwerpNummer foreign key (voorwerpNummer) references tblVoorwerp(voorwerpNummer),
constraint fk_tblVoorwerpRubriek_rubriekNummer foreign key (rubriekNummer) references tblRubriek(rubriekNummer)
)
create table tblBod(
voorwerpNummer bigint not null,
bodBedrag numeric(11,2) not null,
gebruiker varchar(20) not null,
bodDag date not null,
bodTijdstip time not null,
constraint pk_tblBod primary key (voorwerpNummer,bodBedrag),
constraint fk_tblBod_voorwerpNummer foreign key (voorwerpNummer) references tblVoorwerp(voorwerpNummer)
/*constraint fk_tblBod_gebruikersNaam foreign key (gebruikersNaam) references tblGebruiker(gebruikersNaam) */
)
insert into tblVoorwerp values
(8,'Aston Martin DB11','Hele mooie waggie jonguh',1000000.20,'PayPal','gimme da money','Loo','Nederland','5','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/30/2018','14:48:00.0000',0,null)
(1,'Aston Martin Vulcan','Hele mooie waggie jonguh',2000000.20,'PayPal','gimme da money','Loo','Nederland','5','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/30/2018','14:48:00.0000',0,null),
(2,'Diploma HBO-ICT','bespaat jezelf 4 jaar',1.50,'PayPal','gimme da money','Loo','Nederland','3','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/29/2018','14:48:00.0000',0,null),
(3,'MBO-Nivea4','Deze diploma heb je niks an',100,'PayPal','gimme da money','Loo','Nederland','5','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/30/2018','14:48:00.0000',0,null),
(4,'Turbocharged Fiets','Ow fiets is nooit meer zelfde',800,'PayPal','gimme da money','Loo','Nederland','3','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/29/2018','14:48:00.0000',0,null),
(5,'Supercharged BMX','Kannie leg op t kerkhof, Wilnie leg d''r''naost',500,'PayPal','gimme da money','Loo','Nederland','5','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/30/2018','14:48:00.0000',0,null),
(6,'Viagra pil','Dan hej de schaopn ant drietn an',0.50,'PayPal','gimme da money','Loo','Nederland','3','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/29/2018','14:48:00.0000',0,null)
select * from tblRubriek where parentRubriek = 9800
insert into tblVoorwerpRubriek values
(8,9801),
(1,9801)
insert into tblVoorwerp values
(3,'gesdaw HBO-ICT','bespaat jezelf 4 jaar',1.50,'PayPal','gimme da money','Loo','Nederland','3','4/26/2018','14:48:00.0000',3.50,'in da box',20,20,'4/29/2018','14:48:00.0000',0,null)
insert into tblbod values
(1,9000000.00,'Dinosaurus-Dex','4/27/2018','14:48:00.0000'),
(2,3.21,'Dinosaurus-Dex','4/27/2018','14:48:00.0000'),
(2,4.32,'LEEEROOOOOY-roy','4/27/2018','14:48:00.0000'),
(3,200,'Dinosaurus-Dex','4/27/2018','14:48:00.0000'),
(4,1250,'Dinosaurus-Dex','4/27/2018','14:48:00.0000'),
(5,800,'Dinosaurus-Dex','4/27/2018','14:48:00.0000'),
(5,801,'LEEEROOOOOY-roy','4/27/2018','14:48:00.0000'),
(6,100,'Luuk-Lucky','4/27/2018','14:48:00.0000')
|
CREATE TABLE itemmodel
(
id NUMBER NOT NULL,
make VARCHAR(255),
model VARCHAR(255),
year VARCHAR(255),
createdate DATE,
lastupdatedate DATE,
status VARCHAR(255)
);
ALTER TABLE itemmodel ADD (
CONSTRAINT item_pk PRIMARY KEY (id));
CREATE SEQUENCE item_seq START WITH 1; |
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2017/12/7 10:06:20 */
/*==============================================================*/
drop table if exists DE_ORGANIZATION;
drop table if exists DE_REC_FILE;
drop table if exists DE_REC_FILE_SIGN;
drop table if exists DE_SEND_FILE;
drop table if exists DE_SUPERVISE;
/*==============================================================*/
/* Table: DE_ORGANIZATION */
/*==============================================================*/
create table DE_ORGANIZATION
(
PK_ORGANIZATION int(11) not null auto_increment comment '主键',
DICT_ORG_CATEGORY varchar(32) not null comment '机构类别,字典表:局领导、局直各单位、各分局县(市)区公安局',
ORG_COMPANY varchar(32) not null comment '机构单位:驻局纪检组、警务督察支队、办公室、指挥中心、政治部、边防支队、消防支队、警务队等等',
CREATE_BY_ID int comment '本条记录系统用户创建者ID',
CREATE_BY_TIME datetime comment '本条记录系统用户创建时间',
UPDATE_BY_ID int comment '本条记录系统用户修改者ID',
UPDATE_BY_TIME datetime comment '本条记录系统用户修改时间',
IS_VALID tinyint not null default 1 comment '删除状态位(1有效,0无效,作废的时候表示无效)',
primary key (PK_ORGANIZATION)
);
alter table DE_ORGANIZATION comment '机构表';
/*==============================================================*/
/* Table: DE_REC_FILE */
/*==============================================================*/
create table DE_REC_FILE
(
PK_REC_FILE int(11) not null auto_increment comment '主键',
DICT_FILE_SOURCE varchar(32) not null comment '文件来源,字典表:公安系统、外部系统、办公室内部收文、局直单位呈报',
DICT_FILE_CATEGORY varchar(32) not null comment '文件类别,字典表:公文件、机要件、挂号信件、普通信件',
DICT_REC_COMPANY varchar(32) not null comment '来文单位,字典表:公安部、省公安厅、市委、市政府、市委政法委、市委办公厅、市政府办公厅、市委政法委办公厅、市综治办、市委组织部、市纪委',
REC_DATE date not null comment '收文日期,格式yyyyMMdd',
REC_NO varchar(32) not null comment '收文号:流水号,自动生成',
FILE_CODE varchar(64) comment '文号,比如闽公宗(2017)051号',
FILE_TITLE varchar(256) not null comment '文件标题',
DICT_DENSE varchar(32) not null comment '密级,字典表:非密、秘密、机密、绝密、内部文件',
DENSE_CODE varchar(64) comment '密级编号,只有当选项是秘密或机密或绝密时,才出现密级编号,密级编号不是必填项,也可以填无',
DICT_GRADE varchar(32) comment '等级,字典表:普通,加急,平急,特提',
FILE_CNT int comment '文件数量',
HANDLE_PRES date comment '办理时效,如果选择了日期,则在超时后自动显示红色,同时用户可以手动点击已办结,然后不显示红色',
IS_DISPATCH tinyint comment '1是0否',
IS_HANDLE tinyint comment '是否办结:1是0否,',
IS_PROPOSED tinyint comment '是否拟办:1是0否',
IS_NEED_FEEDBACK tinyint comment '是否需办理反馈(1是0否)',
PROPOSED_COMMENTS varchar(2000) comment '拟办意见',
LEADER_INS varchar(2000) comment '领导批示',
DIRECTOR_OPER tinyint comment '1局长批示、2局长圈阅',
SIGN_UP_STATUS tinyint comment '签收状态:1已签收,0未完成签收',
ATTACHMENT varchar(2000) comment '附件',
MEMO varchar(2000) comment '备注',
CREATE_BY_ID int comment '本条记录系统用户创建者ID',
CREATE_BY_TIME datetime comment '本条记录系统用户创建时间',
UPDATE_BY_ID int comment '本条记录系统用户修改者ID',
UPDATE_BY_TIME datetime comment '本条记录系统用户修改时间',
IS_VALID tinyint not null default 1 comment '删除状态位(1有效,0无效,作废的时候表示无效)',
primary key (PK_REC_FILE)
);
alter table DE_REC_FILE comment '收文表';
/*==============================================================*/
/* Table: DE_REC_FILE_SIGN */
/*==============================================================*/
create table DE_REC_FILE_SIGN
(
PK_REC_FILE_SIGN int(11) not null auto_increment comment '主键',
FK_REC_FILE int(11) not null comment 'FK收文表',
FK_ORGANIZATION int(11) not null comment 'FK机构表,适用于收文管理(公安系统)和(外部系统)(局直单位呈报)',
SIGN_UP_OTHER varchar(128) comment '签收单位(其他)',
SIGN_UP varchar(32) comment '签收人',
SIGN_TIME datetime comment '签收时间',
MEMO varchar(2000) comment '备注',
CREATE_BY_ID int comment '本条记录系统用户创建者ID',
CREATE_BY_TIME datetime comment '本条记录系统用户创建时间',
UPDATE_BY_ID int comment '本条记录系统用户修改者ID',
UPDATE_BY_TIME datetime comment '本条记录系统用户修改时间',
IS_VALID tinyint not null default 1 comment '删除状态位(1有效,0无效,作废的时候表示无效)',
primary key (PK_REC_FILE_SIGN)
);
alter table DE_REC_FILE_SIGN comment '收文签收表';
/*==============================================================*/
/* Table: DE_SEND_FILE */
/*==============================================================*/
create table DE_SEND_FILE
(
PK_SEND_FILE int(11) not null auto_increment comment '主键',
DICT_FILE_CATEGORY varchar(32) not null comment '文件类别,字典表:公文件、机要件、挂号信件、普通信件',
FILE_TITLE varchar(256) not null comment '文件标题',
SEND_COMPANYS varchar(256) not null comment '发送单位:存放机构单位主键,多个以,分隔',
SEND_COMPANYS_OTHER varchar(64) comment '发送单位(其他)',
SEND_DATE date not null comment '发文日期,格式yyyyMMdd',
SEND_NO varchar(32) not null comment '发文号:流水号,自动生成',
FILE_CODE varchar(64) comment '文号,比如闽公宗(2017)051号',
DICT_DENSE varchar(32) comment '密级,字典表:非密、秘密、机密、绝密、内部文件',
DENSE_CODE varchar(64) comment '密级编号,只有当选项是秘密或机密或绝密时,才出现密级编号,密级编号不是必填项,也可以填无',
MEMO varchar(2000) comment '备注',
CREATE_BY_ID int comment '本条记录系统用户创建者ID',
CREATE_BY_TIME datetime comment '本条记录系统用户创建时间',
UPDATE_BY_ID int comment '本条记录系统用户修改者ID',
UPDATE_BY_TIME datetime comment '本条记录系统用户修改时间',
IS_VALID tinyint not null default 1 comment '删除状态位(1有效,0无效,作废的时候表示无效)',
primary key (PK_SEND_FILE)
);
alter table DE_SEND_FILE comment '发文表';
/*==============================================================*/
/* Table: DE_SUPERVISE */
/*==============================================================*/
create table DE_SUPERVISE
(
PK_SUPERVISE int(11) not null auto_increment comment '主键',
CREATE_BY_ID int comment '本条记录系统用户创建者ID',
CREATE_BY_TIME datetime comment '本条记录系统用户创建时间',
UPDATE_BY_ID int comment '本条记录系统用户修改者ID',
UPDATE_BY_TIME datetime comment '本条记录系统用户修改时间',
IS_VALID tinyint not null default 1 comment '删除状态位(1有效,0无效,作废的时候表示无效)',
primary key (PK_SUPERVISE)
);
alter table DE_SUPERVISE comment '督办表';
|
-- estados
INSERT INTO `estados`(`estado`) VALUES ('abierto');
INSERT INTO `estados`(`estado`) VALUES ('cerrado');
-- objeto
INSERT INTO `objetos`(`objeto`) VALUES ('nuevo');
INSERT INTO `objetos`(`objeto`) VALUES ('existente');
-- tipologías
INSERT INTO `tipologias`(`tipologia`) VALUES ('Vivienda Unifamiliar');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Vivienda Colectica');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Equipamientos Comerciales');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Equipamientos Culturales');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Equipamientos Educativos');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Equipamientos Industriales');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Obras Especiales');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Instalación Electríca');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Instalación Gas');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Instalación Agua, Cloaca');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Instalación Contra Incendios');
INSERT INTO `tipologias`(`tipologia`) VALUES ('Ascensores');
-- tipos tareas
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Anteproyecto');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Proyecto');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Dirección de Obra');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Relevamiento');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Remodelación');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Plan regulador');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Peritaje');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Representación técnica');
INSERT INTO `tipos_tareas`(`tipo_tarea`) VALUES ('Tasación');
-- condiciones
|
create or replace view v1_zb003_csmx_xm as
(
----预算&业务处.应用
select "JSDE103","JSDE104","JSDE931","DE156","CZDE951","CZDE181","DE186","DE011","DE062",
"DE042","DE084","CZDE119","JSDE802",
bc_hd_zfjs.GetZcxmmcByDm(a.de011,a.de022,a.JSDE802) as jsde821,
"JSDE118","JSDE108","DE151","CZDE182","JSDE901",
"CZDE901","DE001","JSDE909","JSDE007","JSDE008","JSDE009","JSDE028","JSDE029",
"JSDE940",to_char(JSDE999,'yyyy-mm-dd HH24:mi:ss') as JSDE999,"JSDE983","JSDE984",
"JSDE041","CZDE016","JSDE011","JSDE012","CZDE183","CZDE015","JSDE117","DE022","CZDE938","CZDE188","CZDE189",
jsde014, "DE181","HDDE998","JSDE955","HDDE268","HDDE269","HDDE270","HDDE271","HDDE273",
a."HDDE272",--专项转移支付金额
a."HDDE274",--一般转移支付金额
nvl(b."SYJE",0) as syje,djje,
"TZJE","ZTSYJE","KYJE", bc_hd_zbtzs.GetzbbhByid('JSDE104',a.jsde104) as lybh,
---(select lybh from v_zb003_yly v where a.JSDE104 = v.JSDE104) as lybh,
de181+tzje-nvl(a."SYJE",0)-djje as jyje
from v1_zb003 a,(select jsde104 as jsde104old ,sum(de181) as syje from zb009 group by jsde104) b
where a.JSDE011 in (0,1,2) and a.JSDE104 = b.jsde104old(+)
and not exists
(select 1 from v_bz011_jxkp dd where a.DE011=dd.de011 and a.jsde802=dd.xmdm)
);
|
CREATE OR ALTER PROCEDURE GET_SUBROUNDS
(
LAST_SUBROUND_ID VARCHAR(32)
)
RETURNS
(
SUBROUND_ID VARCHAR(32)
)
AS
DECLARE TIRAGE_ID VARCHAR(32);
DECLARE ROUND_NUM INTEGER;
BEGIN
SELECT TIRAGE_ID, ROUND_NUM
FROM SUBROUNDS
WHERE SUBROUND_ID=:LAST_SUBROUND_ID
INTO :TIRAGE_ID, :ROUND_NUM;
FOR SELECT SUBROUND_ID
FROM SUBROUNDS
WHERE TIRAGE_ID=:TIRAGE_ID
AND ROUND_NUM=:ROUND_NUM
ORDER BY PRIORITY
INTO :SUBROUND_ID DO BEGIN
IF (SUBROUND_ID=LAST_SUBROUND_ID) THEN
BREAK;
SUSPEND;
END
END |
/*!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 `1337xtorrents`
--
DROP TABLE IF EXISTS `1337xtorrents`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `1337xtorrents` (
`1337x_id` int(11) unsigned NOT NULL,
`category` tinyint(1) unsigned NOT NULL DEFAULT '0',
`titlename` mediumtext NOT NULL,
`hash` varchar(255) NOT NULL,
`format_type` varchar(256) DEFAULT NULL,
`language` varchar(256) DEFAULT NULL,
`size` varchar(16) DEFAULT NULL,
`seeds` smallint(5) unsigned NOT NULL,
`leeches` smallint(5) unsigned NOT NULL,
`uploader` varchar(256) DEFAULT NULL,
`uploaded` varchar(256) DEFAULT NULL,
`checked` varchar(256) DEFAULT NULL,
`downloads` smallint(5) unsigned NOT NULL,
`links` mediumtext NOT NULL,
`images` mediumtext NOT NULL,
`imdbmatch` varchar(255) NOT NULL DEFAULT '0',
PRIMARY KEY (`1337x_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `1337xtorrents`
--
LOCK TABLES `1337xtorrents` WRITE;
/*!40000 ALTER TABLE `1337xtorrents` DISABLE KEYS */;
/*!40000 ALTER TABLE `1337xtorrents` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `search_results`
--
DROP TABLE IF EXISTS `search_results`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `search_results` (
`summary_id` int(11) unsigned NOT NULL,
`imdb` varchar(255) NOT NULL DEFAULT '0',
`1337x_id` int(11) unsigned NOT NULL,
`link` mediumtext NOT NULL,
`seeds` smallint(5) unsigned NOT NULL,
`leeches` smallint(5) unsigned NOT NULL,
`category` tinyint(1) unsigned NOT NULL DEFAULT '0',
`downloaded` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`imdb`,`1337x_id`),
KEY `summary_id` (`summary_id`),
CONSTRAINT `search_results_ibfk_1` FOREIGN KEY (`summary_id`) REFERENCES `search_summary` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `search_results`
--
LOCK TABLES `search_results` WRITE;
/*!40000 ALTER TABLE `search_results` DISABLE KEYS */;
/*!40000 ALTER TABLE `search_results` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `search_summary`
--
DROP TABLE IF EXISTS `search_summary`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `search_summary` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`imdb` varchar(255) NOT NULL DEFAULT '0',
`totalPages` mediumint(8) unsigned NOT NULL DEFAULT '0',
`activePages` mediumint(8) unsigned NOT NULL DEFAULT '0',
`totalTorrents` mediumint(8) unsigned NOT NULL DEFAULT '0',
`activeTorrents` mediumint(8) unsigned NOT NULL DEFAULT '0',
`last_checked` datetime DEFAULT NULL,
`category` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `imdb` (`imdb`)
) ENGINE=InnoDB AUTO_INCREMENT=12936 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `search_summary`
--
LOCK TABLES `search_summary` WRITE;
/*!40000 ALTER TABLE `search_summary` DISABLE KEYS */;
/*!40000 ALTER TABLE `search_summary` 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 */;
|
ALTER TABLE #__md_member ADD `soudbow_subscriber` BOOLEAN NOT NULL DEFAULT FALSE AFTER `accept_privicy_policy`;
ALTER TABLE #__md_member_history ADD `soudbow_subscriber` BOOLEAN NOT NULL DEFAULT FALSE AFTER `accept_privicy_policy`;
ALTER TABLE #__md_member ADD `can_publish_name` BOOLEAN NULL AFTER `soudbow_subscriber`;
ALTER TABLE #__md_member_history ADD `can_publish_name` BOOLEAN NULL AFTER `soudbow_subscriber`;
|
ALTER TABLE `m_product_loan`
CHANGE COLUMN `principal_threshold_for_last_instalment` `principal_threshold_for_last_installment` DECIMAL(5,2) NOT NULL DEFAULT '50.00' AFTER `hold_guarantee_funds`;
|
//database administrator information can be changed in application/config/database.php file
//If IDENTIFIED BY PASSWORD is encrypted, the decrypted version is rrslocal
GRANT ALL PRIVILEGES ON *.* TO 'rrs'@'localhost' IDENTIFIED BY PASSWORD '*2189A97957C6F439F6573778049ADA52276F0BAB' WITH GRANT OPTION;
//below is all you need for database creation and table information
CREATE DATABASE restaurant_reservation_system;
DROP DATABASE restaurant_reservation_system;
CREATE TABLE admin (
adminid INT NOT NULL AUTO_INCREMENT,
adminUsername VARCHAR(255) NOT NULL,
adminPassword VARCHAR(255) NOT NULL,
CONSTRAINT admin_PK PRIMARY KEY(adminid)
);
//insert this query for creating an admin for the RRS site
//the password is 12345
//When creating new user, remember to encrypt password using $this->encryption->encrypt(''); and generate a password and copy it to the query below
//The reason for this is so that when the system runs, it will recognise the encryption sequence and decrypt it properly when checking in Login_model.php
INSERT INTO admin (adminid, adminUsername, adminPassword)
VALUES (1, 'Admin', 'f0a87e06d6b0ae8d31a9b9d3a0d06c4610979b611be0d109762bfc990308c8981b7f1b7f089159cde864a254d1a64bfeebb4217164286fe126a68f1cf555058227dAxn8vefFzUgpddILIjiPaFlnT4+vpyOhQ1NXehEY=');
DROP TABLE admin;
//Customer Table
CREATE TABLE customer (
customerid INT NOT NULL AUTO_INCREMENT,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
phonenumber VARCHAR(20) NOT NULL,
CONSTRAINT admin_PK PRIMARY KEY(customerid)
);
DROP TABLE customer;
//City Table
CREATE TABLE city (
cityid INT NOT NULL AUTO_INCREMENT,
city VARCHAR(255) NOT NULL,
CONSTRAINT city_PK PRIMARY KEY (cityid)
);
INSERT INTO city (city)
VALUES ('HongKong');
INSERT INTO city (city)
VALUES ('NewYork');
INSERT INTO city (city)
VALUES ('Paris');
DROP TABLE city;
//Restaurant Table
CREATE TABLE restaurant (
restaurantid INT NOT NULL AUTO_INCREMENT,
cityid INT NOT NULL,
restaurantname VARCHAR(255) NOT NULL,
description VARCHAR(255),
timeavailable TIME(2),
timeend TIME(2),
CONSTRAINT restaurant_PK PRIMARY KEY (restaurantid),
CONSTRAINT city_FK FOREIGN KEY (cityid) REFERENCES city(cityid)
);
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (1, 'HK_Res_1', 'Chinese Street Food', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (1, 'HK_Res_2', 'Michelin Star Restaurant', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (1, 'HK_Res_3', 'Jumbo Kingdom', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (2, 'NY_Res_1', 'Indian Restaurant', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (2, 'NY_Res_2', 'Southern Hospitality', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (2, 'NY_Res_3', 'Balthazar', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (3, 'Paris_Res_1', 'Pizza Palace', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (3, 'Paris_Res_2', 'Entrecoteone', '09:00', '22:00');
INSERT INTO restaurant (cityid, restaurantname, description, timeavailable, timeend)
VALUES (3, 'Paris_Res_3', 'Entrecotetwo', '09:00', '22:00');
DROP TABLE restaurant;
//Tables table
CREATE TABLE tables (
tableid INT NOT NULL AUTO_INCREMENT,
restaurantid INT NOT NULL,
tableno VARCHAR(10) NOT NULL,
tablecapacity VARCHAR(10) NOT NULL,
CONSTRAINT tables_PK PRIMARY KEY (tableid),
CONSTRAINT restaurantid_FK FOREIGN KEY (restaurantid) REFERENCES restaurant(restaurantid)
);
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (1, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (2, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (3, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (4, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (5, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (6, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (7, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (8, '9', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '1', '3');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '2', '5');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '3', '7');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '4', '9');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '5', '11');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '6', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '7', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '8', '13');
INSERT INTO tables (restaurantid, tableno, tablecapacity)
VALUES (9, '9', '13');
DROP TABLE tables;
//reserveredtables table
CREATE TABLE reservedtables (
restableid INT NOT NULL AUTO_INCREMENT,
restaurantid INT NOT NULL,
tableid INT NOT NULL,
tableno VARCHAR(10) NOT NULL,
numberofpeople VARCHAR(255) NOT NULL,
dates DATE NOT NULL,
times TIME(2) NOT NULL,
CONSTRAINT reservedtables_PK PRIMARY KEY (restableid),
CONSTRAINT restaurantssid_FK FOREIGN KEY (restaurantid) REFERENCES restaurant(restaurantid),
CONSTRAINT tableid_FK FOREIGN KEY (tableid) REFERENCES tables(tableid)
);
DROP TABLE reservedtables;
//Date table
CREATE TABLE dates (
dateid INT NOT NULL AUTO_INCREMENT,
restaurantid INT NOT NULL,
dates DATE NOT NULL,
CONSTRAINT date_PK PRIMARY KEY (dateid),
CONSTRAINT restaurantsid_FK FOREIGN KEY (restaurantid) REFERENCES restaurant(restaurantid)
);
DROP TABLE dates;
//DatesFull table
CREATE TABLE datesfull (
dateid INT NOT NULL AUTO_INCREMENT,
restaurantid INT NOT NULL,
datesfull DATE NOT NULL,
CONSTRAINT datesfull_PK PRIMARY KEY (dateid),
CONSTRAINT restaurantsssid_FK FOREIGN KEY (restaurantid) REFERENCES restaurant(restaurantid)
);
DROP TABLE datesfull;
//Booking table
CREATE TABLE booking (
bookingid INT NOT NULL AUTO_INCREMENT,
customerid INT NOT NULL,
restableid INT NOT NULL,
CONSTRAINT booking_PK PRIMARY KEY (bookingid),
CONSTRAINT customer_FK FOREIGN KEY (customerid) REFERENCES customer(customerid),
CONSTRAINT restables_FK FOREIGN KEY (restableid) REFERENCES reservedtables(restableid)
);
DROP TABLE booking;
|
-- Mongo
insert into volume
(id, app, docker, services_id)
values ( 1, './mongo-init.js', '/docker-entrypoint-initdb.d/mongo-init.js:ro', 2 );
-- Aapche
insert into volume
(id, app, docker, services_id)
values ( 2, './htdocs/', '/usr/local/apache2/htdocs/', 4 );
insert into volume
(id, app, docker, services_id)
values ( 3, './.htaccess', '/usr/local/apache2/htdocs/.htaccess', 4 );
insert into volume
(id, app, docker, services_id)
values ( 4, './httpd.conf', '/usr/local/apache2/conf/httpd.conf', 4 );
-- Postgres
insert into volume
(id, app, docker, services_id)
values ( 5, './docker-data/postgres/init-00.sql', '/docker-entrypoint-initdb.d/init-00.sql', 1 );
-- Elasticsearch
insert into volume
(id, app, docker, services_id)
values ( 6, './docker-data/elasticsearch/config/elasticsearch.yml', '/usr/share/elasticsearch/config/elasticsearch.yml:ro', 8 );
-- Kibana
insert into volume
(id, app, docker, services_id)
values ( 7, './docker-data/kibana/config/kibana.yml', '/usr/share/kibana/config/kibana.yml:ro', 9 );
-- Kafka
insert into volume
(id, app, docker, services_id)
values ( 8, '/var/run/docker.sock', '/var/run/docker.sock', 12 );
|
/*
Navicat MySQL Data Transfer
Source Server : local
Source Server Version : 50550
Source Host : localhost:3306
Source Database : bbs
Target Server Type : MYSQL
Target Server Version : 50550
File Encoding : 65001
Date: 2017-04-20 15:35:23
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t_board
-- ----------------------------
DROP TABLE IF EXISTS `t_board`;
CREATE TABLE `t_board` (
`board_id` int(11) NOT NULL DEFAULT '0',
`board_name` varchar(255) NOT NULL COMMENT '板块名称',
`board_desc` varchar(255) NOT NULL COMMENT '板块描述',
`topic_num` int(11) NOT NULL COMMENT '板块主题数',
PRIMARY KEY (`board_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_board
-- ----------------------------
-- ----------------------------
-- Table structure for t_board_manager
-- ----------------------------
DROP TABLE IF EXISTS `t_board_manager`;
CREATE TABLE `t_board_manager` (
`board_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`board_id`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_board_manager
-- ----------------------------
-- ----------------------------
-- Table structure for t_login_log
-- ----------------------------
DROP TABLE IF EXISTS `t_login_log`;
CREATE TABLE `t_login_log` (
`login_log_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`ip` varchar(255) DEFAULT NULL,
`login_time` datetime DEFAULT NULL,
PRIMARY KEY (`login_log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_login_log
-- ----------------------------
-- ----------------------------
-- Table structure for t_post
-- ----------------------------
DROP TABLE IF EXISTS `t_post`;
CREATE TABLE `t_post` (
`post_id` int(11) NOT NULL,
`board_id` int(11) NOT NULL,
`topic_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`post_type` tinyint(4) NOT NULL DEFAULT '2' COMMENT '帖子类型 1:主题帖;2回复帖',
`post_title` varchar(50) NOT NULL COMMENT '贴子标题',
`post_text` text NOT NULL COMMENT '贴子内容',
`createtime` datetime NOT NULL,
PRIMARY KEY (`post_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_post
-- ----------------------------
-- ----------------------------
-- Table structure for t_topic
-- ----------------------------
DROP TABLE IF EXISTS `t_topic`;
CREATE TABLE `t_topic` (
`topic_id` int(11) NOT NULL,
`board_id` int(11) NOT NULL,
`topic_title` varchar(255) NOT NULL,
`user_id` int(11) NOT NULL,
`create_time` datetime NOT NULL COMMENT '创建时间',
`last_post` datetime DEFAULT NULL COMMENT '最后回复时间',
`topic_view` int(11) NOT NULL DEFAULT '0' COMMENT '浏览次数',
`topic_replies` int(11) NOT NULL DEFAULT '0' COMMENT '回复次数',
`digest` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否精品 0:非精品;1:精品',
PRIMARY KEY (`topic_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_topic
-- ----------------------------
-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户id',
`user_name` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`user_type` tinyint(4) DEFAULT '1' COMMENT '用户类型 1:普通会员 2:版块管理员 3:论坛管理员',
`locked` tinyint(4) DEFAULT '0' COMMENT '是否被锁定',
`credit` int(11) DEFAULT '0',
`lastvisit` datetime DEFAULT NULL COMMENT '上次登录时间',
`lastip` varchar(255) DEFAULT NULL COMMENT '上次登录地址',
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_user
-- ----------------------------
|
CREATE TABLE TASK (
TASK_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 ,INCREMENT BY 756),
TASK_STATUS VARCHAR(255),
TASK_TYPE VARCHAR(255),
PROVIDER_PERSON_ID INTEGER,
PARENT_TASK_ID INTEGER,
CLIENT_PERSON_ID INTEGER,
TASK_NAME VARCHAR(255),
TASK_DESC VARCHAR(255),
TASK_DURATION INTEGER,
SENSED_DATA_FILE_LOCATION VARCHAR(255),
ACCELEROMETER VARCHAR(255),
GPS VARCHAR(255),
CAMERA VARCHAR(255),
MIC VARCHAR(255),
WIFI VARCHAR(255),
BLUETOOTH VARCHAR(255),
MAGNETOMETER VARCHAR(255),
PROXIMITYSENSOR VARCHAR(255),
AMBIENTLIGHTSENSOR VARCHAR(255),
TASK_ACCEPTED_TIME TIMESTAMP,
TASK_COMPLETION_TIME TIMESTAMP,
TASK_EXPIRATION_TIME TIMESTAMP,
TASK_CREATED_TIME TIMESTAMP,
CLIENT_PAY DOUBLE
);
CREATE INDEX SQL110805224911920 ON TASK (null);
CREATE UNIQUE INDEX SQL110805224911100 ON TASK (null);
ALTER TABLE TASK ADD CONSTRAINT SQL110805224911100 PRIMARY KEY (TASK_ID);
ALTER TABLE TASK ADD CONSTRAINT TASKCLIENTPERSONID FOREIGN KEY (CLIENT_PERSON_ID)
REFERENCES PEOPLE (PERSON_ID);
|
-- MySQL Script generated by MySQL Workbench
-- Tue Oct 26 10:26:26 2021
-- 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 db_totalservicos
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema db_totalservicos
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `db_totalservicos` DEFAULT CHARACTER SET utf8 ;
USE `db_totalservicos` ;
-- -----------------------------------------------------
-- Table `db_totalservicos`.`tb_agendamento`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `db_totalservicos`.`tb_agendamento` (
`id_agendamento` INT NOT NULL AUTO_INCREMENT,
`dt_agendamento` DATE NOT NULL,
`hr_agendamento` TIME NOT NULL,
`nm_cliente` VARCHAR(150) NOT NULL,
`telefone` VARCHAR(14) NOT NULL,
`observacao` VARCHAR(200) NOT NULL,
`endereco` VARCHAR(200) NOT NULL,
`cidade` VARCHAR(30) NOT NULL,
`estado` VARCHAR(20) NOT NULL,
`cep` VARCHAR(10) NOT NULL,
`servico` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id_agendamento`))
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
DROP SCHEMA IF EXISTS `farmacy` ;
CREATE SCHEMA IF NOT EXISTS `farmacy`;
CREATE TABLE `farmacy`.`medication` (
`id` INT NOT NULL auto_increment,
`name` VARCHAR(45) NULL,
`ingredients` VARCHAR(45) NULL,
`manufacturer` VARCHAR(45) NULL,
`quantity` INT NULL,
`price` DECIMAL(5,2) NULL,
PRIMARY KEY (`id`));
CREATE TABLE `farmacy`.`employee` (
`username` VARCHAR(45) NOT NULL,
`password` VARCHAR(45) NULL,
PRIMARY KEY (`username`));
|
set schema 'testy';
insert into pracownicy VALUES (27,'Kruk','Adam','15/12/1989','PK101','kierownik',2200.00);
insert into pracownicy VALUES (270,'Kowalik','Artur','13/12/1988','PK101','analityk',2400.00);
insert into pracownicy VALUES (72,'Kowalik','Adam','15/11/1989','PR202','kierownik',2600.00);
insert into pracownicy VALUES (720,'Kowalik','Amadeusz','17/12/1988','PK101','analityk',3200.00);
insert into pracownicy VALUES (707,'Kukulka','Antoni','15/12/1999','PH101','robotnik',1600.00);
insert into pracownicy VALUES (207,'Kowal','Alojzy','15/10/1998','PH101','robotnik',2000.00);
insert into pracownicy VALUES (77,'Kowalus','Adam','12/11/1998','PH101','kierownik',5400.00);
insert into pracownicy VALUES (1010,'Kawula','Alojzy','15/11/1998','PK101','robotnik',2500.00);
insert into dzialy VALUES ('PH101','Handlowy','Marki',77);
insert into dzialy VALUES ('PR202','Projektowy','Olecko',27);
insert into dzialy VALUES ('PK101','Personalny','Niwka',72);
|
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50045
Source Host : localhost:3306
Source Database : sep
Target Server Type : MYSQL
Target Server Version : 50045
File Encoding : 65001
Date: 2010-12-30 14:10:56
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `bsam_color_threshold`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_color_threshold`;
CREATE TABLE `bsam_color_threshold` (
`id` int(11) NOT NULL auto_increment,
`color` varchar(10) NOT NULL,
`value` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_color_threshold
-- ----------------------------
INSERT INTO `bsam_color_threshold` VALUES ('1', 'green', '20');
INSERT INTO `bsam_color_threshold` VALUES ('2', 'yellow', '60');
-- ----------------------------
-- Table structure for `bsam_machine`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_machine`;
CREATE TABLE `bsam_machine` (
`id` int(11) NOT NULL auto_increment,
`description` varchar(255) default NULL,
`ip` varchar(100) NOT NULL,
`machine_cabinet_name` varchar(255) default NULL,
`machine_name` varchar(100) default NULL,
`machine_room_name` varchar(255) default NULL,
`parent_type` varchar(100) default NULL,
`security_area_name` varchar(255) default NULL,
`weight` int(11) NOT NULL,
`security_area_id` int(11) default NULL,
`machine_cabinet_id` int(11) default NULL,
`machine_room_id` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `FK4375A645D9F71468` (`machine_cabinet_id`),
KEY `FK4375A64596112CEC` (`machine_room_id`),
KEY `FK4375A6452ED71EC8` (`security_area_id`),
CONSTRAINT `FK4375A645D9F71468` FOREIGN KEY (`machine_cabinet_id`) REFERENCES `bsam_machine_cabinet` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK4375A6452ED71EC8` FOREIGN KEY (`security_area_id`) REFERENCES `ismp_domain` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK4375A64596112CEC` FOREIGN KEY (`machine_room_id`) REFERENCES `bsam_machine_room` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_machine
-- ----------------------------
-- ----------------------------
-- Table structure for `bsam_machine_cabinet`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_machine_cabinet`;
CREATE TABLE `bsam_machine_cabinet` (
`id` int(11) NOT NULL auto_increment,
`description` varchar(255) default NULL,
`machine_cabinet_name` varchar(100) NOT NULL,
`machine_room_name` varchar(255) default NULL,
`machine_room_id` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `FK1969A5E96112CEC` (`machine_room_id`),
CONSTRAINT `FK1969A5E96112CEC` FOREIGN KEY (`machine_room_id`) REFERENCES `bsam_machine_room` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_machine_cabinet
-- ----------------------------
-- ----------------------------
-- Table structure for `bsam_machine_room`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_machine_room`;
CREATE TABLE `bsam_machine_room` (
`id` int(11) NOT NULL auto_increment,
`description` varchar(255) default NULL,
`machine_room_name` varchar(100) NOT NULL,
`security_area_name` varchar(255) default NULL,
`security_area_id` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `FK5D50B6952ED71EC8` (`security_area_id`),
CONSTRAINT `FK5D50B6952ED71EC8` FOREIGN KEY (`security_area_id`) REFERENCES `ismp_domain` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_machine_room
-- ----------------------------
-- ----------------------------
-- Table structure for `bsam_machine_situation`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_machine_situation`;
CREATE TABLE `bsam_machine_situation` (
`id` int(11) NOT NULL auto_increment,
`attack_threat` float default NULL,
`invalid_connection` float default NULL,
`ip` varchar(100) NOT NULL,
`time` datetime NOT NULL,
`virus_condition` float default NULL,
`whole_situation` float default NULL,
`machine_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK45A3A88411F7FDFD` (`machine_id`),
CONSTRAINT `FK45A3A88411F7FDFD` FOREIGN KEY (`machine_id`) REFERENCES `bsam_machine` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_machine_situation
-- ----------------------------
-- ----------------------------
-- Table structure for `bsam_machinecabinet_situation`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_machinecabinet_situation`;
CREATE TABLE `bsam_machinecabinet_situation` (
`id` int(11) NOT NULL auto_increment,
`attack_threat` float default NULL,
`invalid_connection` float default NULL,
`machine_cabinet_name` varchar(100) NOT NULL,
`time` datetime NOT NULL,
`virus_condition` float default NULL,
`whole_situation` float default NULL,
`machine_cabinet_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK5CEEB532D9F71468` (`machine_cabinet_id`),
CONSTRAINT `FK5CEEB532D9F71468` FOREIGN KEY (`machine_cabinet_id`) REFERENCES `bsam_machine_cabinet` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_machinecabinet_situation
-- ----------------------------
-- ----------------------------
-- Table structure for `bsam_machineroom_situation`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_machineroom_situation`;
CREATE TABLE `bsam_machineroom_situation` (
`id` int(11) NOT NULL auto_increment,
`attack_threat` float default NULL,
`invalid_connection` float default NULL,
`machine_room_name` varchar(100) NOT NULL,
`time` datetime NOT NULL,
`virus_condition` float default NULL,
`whole_situation` float default NULL,
`machine_room_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK6F9A891F96112CEC` (`machine_room_id`),
CONSTRAINT `FK6F9A891F96112CEC` FOREIGN KEY (`machine_room_id`) REFERENCES `bsam_machine_room` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_machineroom_situation
-- ----------------------------
-- ----------------------------
-- Table structure for `bsam_securityarea_situation`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_securityarea_situation`;
CREATE TABLE `bsam_securityarea_situation` (
`id` int(11) NOT NULL auto_increment,
`attack_threat` float default NULL,
`invalid_connection` float default NULL,
`security_area_name` varchar(100) NOT NULL,
`time` datetime NOT NULL,
`virus_condition` float default NULL,
`whole_situation` float default NULL,
`security_area_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKD95A024E2ED71EC8` (`security_area_id`),
CONSTRAINT `FKD95A024E2ED71EC8` FOREIGN KEY (`security_area_id`) REFERENCES `ismp_domain` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bsam_securityarea_situation
-- ----------------------------
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50045
Source Host : localhost:3306
Source Database : sep
Target Server Type : MYSQL
Target Server Version : 50045
File Encoding : 65001
Date: 2011-03-08 10:43:52
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `bsam_situation_event`
-- ----------------------------
DROP TABLE IF EXISTS `bsam_situation_event`;
CREATE TABLE `bsam_situation_event` (
`id` int(11) unsigned NOT NULL auto_increment COMMENT 'id',
`time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '态势产生时间',
`event_id` mediumtext COMMENT '事件的id',
`srcmod` varchar(100) default NULL COMMENT '事件的产生模块',
`event_log_time` timestamp NOT NULL default '0000-00-00 00:00:00' COMMENT '事件的记录时间',
`event_old_time` timestamp NOT NULL default '0000-00-00 00:00:00' COMMENT '事件的原始时间',
`event_ip` varchar(100) default NULL COMMENT '事件的目的IP',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9925 DEFAULT CHARSET=utf8 COMMENT='态势对应事件表(常)';
|
SELECT ProductAW.Name, CustomerAW.CompanyName FROM ProductAW
LEFT JOIN ProductModel ON (ProductAW.ProductModelID = ProductModel.ProductModelID)
RIGHT JOIN SalesOrderDetail ON (ProductAW.ProductID = SalesOrderDetail.ProductID)
RIGHT JOIN SalesOrderHeader ON (SalesOrderDetail.SalesOrderID = SalesOrderHeader.SalesOrderID)
RIGHT JOIN CustomerAW ON (SalesOrderHeader.CustomerID = CustomerAW.CustomerID)
WHERE ProductModel.Name = "Racing Socks"; |
CREATE USER taskeradmin;
CREATE DATABASE tasker;
GRANT ALL PRIVILEGES ON DATABASE tasker TO taskeradmin;
|
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Creato il: Nov 17, 2019 alle 17:44
-- Versione del server: 10.1.41-MariaDB-cll-lve
-- Versione PHP: 7.2.7
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: `hnlzewad_edmdeathplaylistmachine`
--
DELIMITER $$
--
-- Funzioni
--
CREATE DEFINER=`hnlzewad`@`localhost` FUNCTION `LastMonday` () RETURNS DATETIME RETURN DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY)$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Struttura della tabella `added_tracks`
--
CREATE TABLE `added_tracks` (
`idAdd` int(11) NOT NULL,
`idUser` int(11) NOT NULL,
`trackUri` varchar(60) NOT NULL,
`datetime` datetime NOT NULL,
`duplicated` tinyint(1) DEFAULT NULL,
`removed` tinyint(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Struttura della tabella `user`
--
CREATE TABLE `user` (
`idUser` int(11) UNSIGNED NOT NULL,
`username` varchar(16) NOT NULL,
`password` varchar(256) NOT NULL,
`email` varchar(50) NOT NULL,
`countryCode` varchar(5) NOT NULL,
`telephone` varchar(10) NOT NULL,
`accessToken` varchar(256) DEFAULT NULL,
`refreshToken` varchar(256) DEFAULT NULL,
`admin` tinyint(1) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=latin1;
--
-- Indici per le tabelle scaricate
--
--
-- Indici per le tabelle `added_tracks`
--
ALTER TABLE `added_tracks`
ADD PRIMARY KEY (`idAdd`);
--
-- Indici per le tabelle `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`idUser`),
ADD UNIQUE KEY `username` (`username`,`email`);
--
-- AUTO_INCREMENT per le tabelle scaricate
--
--
-- AUTO_INCREMENT per la tabella `added_tracks`
--
ALTER TABLE `added_tracks`
MODIFY `idAdd` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=101;
--
-- AUTO_INCREMENT per la tabella `user`
--
ALTER TABLE `user`
MODIFY `idUser` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
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 */;
|
DROP TABLE IF EXISTS metode_bayar;
CREATE TABLE `metode_bayar` (
`id` int(11) NOT NULL AUTO_INCREMENT KEY,
`metode_bayar` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO metode_bayar (id, metode_bayar) values
(1, 'TUNAI LEWAT KASIR'),
(2, 'GOPAY'),
(3, 'OVO'),
(4, 'TRANSFER BANK'),
(5, 'DANA'),
(6, 'KARTU DEBIT'),
(7, 'VIRTUAL ACCOUNT BCA'),
(8, 'QRiS'),
(9, 'ALFAMART'),
(10, 'INDOMART') |
CREATE DATABASE Bamazon;
CREATE TABLE products;
DROP TABLE products;
USE bamazon;
CREATE TABLE Products(
ItemID INTEGER AUTO_INCREMENT PRIMARY KEY,
ProductName VARCHAR(30),
DepartmentName VARCHAR(30),
Price DOUBLE(10,2),
StockQuantity INTEGER);
-- Seed Items into Database
INSERT INTO Products(ProductName, DepartmentName, Price, StockQuantity)
VALUES ("Eggs", "grocery", 1.99, 12),
("Milk", "grocery", 2.99, 24),
("PS3", "electronics", 299.99, 5),
("Xbox 360", "electronics", 1479.99, 7),
("iPad", "electronics", 399.99, 18),
("Bicycle", "sporting goods", 599.99, 2),
("Football", "sporting goods", 9.99, 49),
("50 Shades of Grey", "books", 9.99, 69),
("Game of Thrones", "books", 19.99, 33),
("Fight Club", "books", 11.99, 6),
("FightClub", "dvds", 13.99, 36),
("Office Space", "dvds", 9.99, 21),
("Dark Side of the Moon", "music", 11.55, 15),
("Butter", "grocery", 2.99, 12),
("Tomato Sauce", "grocery", 2.99, 24),
("Switch", "electronics", 299.99, 5),
("PC", "electronics", 1479.99, 7),
("Galaxy S8", "electronics", 399.99, 18),
("Roller Blades", "sporting goods", 599.99, 2),
("BasketBall", "sporting goods", 9.99, 49),
("Hero With a Thousand Faces", "books", 9.99, 69),
("Harry Potter", "books", 19.99, 33),
("Ready Player One", "books", 11.99, 6),
("Ready Player One", "dvds", 13.99, 36),
("Avengers", "dvds", 9.99, 21),
("The Low End Theory", "music", 11.55, 15);
-- View Database Entries
SELECT * FROM Products;
-- ============================ Second Table ============================
CREATE TABLE Departments(
DepartmentID INTEGER AUTO_INCREMENT PRIMARY KEY,
DepartmentName VARCHAR(30),
OverHeadCosts DOUBLE(10,2),
TotalSales DOUBLE(10,2));
-- Seed Departments into Database
INSERT INTO Departments(DepartmentName, OverHeadCosts, TotalSales)
VALUES ("grocery", 10500.00, -10000.00), -- More fun stuff (refunds for days!) ;)
("electronics", 25000.00, 0.00),
("sporting goods", 15000.00, 0.00),
("books", 5000.00, 0.00),
("dvds", 20000.00, 0.00),
("music", 7500.00, 0.00);
-- View Database Entries
SELECT * FROM Departments;
|
CREATE Procedure sp_update_DivisionName (@BrandID nvarchar(20),
@NewName nvarchar(128))
As
Update Brand Set Brandname = @NewName
Where BrandID = @BrandID
|
-- MySQL dump 10.13 Distrib 5.6.24, for Win32 (x86)
--
-- Host: 127.0.0.1 Database: sc-manager
-- ------------------------------------------------------
-- Server version 5.5.5-10.4.8-MariaDB
/*!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 `produtos`
--
DROP TABLE IF EXISTS `produtos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `produtos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(45) NOT NULL,
`precoCusto` varchar(45) NOT NULL,
`precoVenda` varchar(45) NOT NULL,
`precoPromocional` varchar(45) DEFAULT NULL,
`novidade` tinyint(4) DEFAULT NULL,
`promocao` tinyint(4) DEFAULT NULL,
`quantity` int(11) NOT NULL,
`productImage` varchar(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
UNIQUE KEY `nome_UNIQUE` (`nome`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `produtos`
--
LOCK TABLES `produtos` WRITE;
/*!40000 ALTER TABLE `produtos` DISABLE KEYS */;
INSERT INTO `produtos` VALUES (4,'Camisa Chronic 1','30,00','60,00',NULL,NULL,NULL,15,''),(5,'Shoulder Bag 2','15,00','30,00',NULL,NULL,NULL,20,'');
/*!40000 ALTER TABLE `produtos` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`usuario` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`senha` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (1,'caua','caua.rules@hotmail.com','202cb962ac59075b964b07152d234b70');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-10-28 15:34:54
|
UPDATE schema_versions set schema_version = 'v3.0.0' WHERE onerow_enforcer = TRUE; |
INSERT INTO `food_users` VALUES ('1', 'hew', 'hew', '何旺');
INSERT INTO `food_users` VALUES ('2', 'wangqq', 'wangqq', '王乔乔');
|
create schema xovis;
alter schema xovis owner to xovis ;
create table xovis.xovis_status (
sensor_id character varying(36) NOT NULL,
macaddress character varying(18),
sensorgroup character varying(256),
sensorname character varying(256),
lastseen bigint,
ipaddress character varying(15),
timezone character varying(36),
devicetype character varying(10),
firmware character varying(32),
connected boolean,
countmode character varying(15),
coordinatemode character varying(10),
onpremenabled boolean,
onpremagentid smallint,
onprempushstatus boolean,
cloudenabled boolean,
cloudcountagentid smallint,
cloudsensorstatusagentid smallint,
cloudcountpushstatus boolean,
cloudsensorpushstatus boolean,
ntpenabled boolean,
ntpstatus boolean,
config character varying(16384)
);
alter table only xovis.xovis_status add constraint xovis_status_pkey PRIMARY KEY (sensor_id);
alter table xovis.xovis_status owner to xovis;
|
# Write your MySQL query statement below
select distinct l1.num as consecutivenums
from logs l1, logs l2, logs l3
where l1.id = l2.id - 1 and l2.id = l3.id -1 and l1.num = l2.num and l2.num = l3.num
# Success
# Details
# Runtime: 456 ms, faster than 91.32% of MySQL online submissions for Consecutive Numbers.
# Memory Usage: 0B, less than 100.00% of MySQL online submissions for Consecutive Numbers.
# Write your MySQL query statement below
select distinct l1.num as consecutivenums
from logs l1
join logs l2 on l1.id = l2.id - 1
join logs l3 on l1.id = l3.id - 2
where l1.num = l2.num and l2.num = l3.num
# Success
# Details
# Runtime: 574 ms, faster than 60.90% of MySQL online submissions for Consecutive Numbers.
# Memory Usage: 0B, less than 100.00% of MySQL online submissions for Consecutive Numbers.
# Write your MySQL query statement below
select distinct num as consecutivenums from
(
select num, @count := if(@pre = num, @count + 1, 1) as n, @pre := num
from logs, (select @count := 0, @pre := -1) as init
) as t where t.n >= 3
# Success
# Details
# Runtime: 426 ms, faster than 97.20% of MySQL online submissions for Consecutive Numbers.
# Memory Usage: 0B, less than 100.00% of MySQL online submissions for Consecutive Numbers.
|
CREATE OR REPLACE VIEW if_status_tid_and_cust_view AS
SELECT
tif.interface_id AS interface_id,
tif.tid_id AS tid_id,
to_char(tif.timeentered, 'MM/DD/YYYY HH24:MI:SS') AS timeentered,
to_char(tif.timeentered, 'YYYY/MM/DD HH24:MI:SS') AS sorttime,
tif.connect_attempt AS connect_attempts,
ff.name AS flag,
tif.cause AS cause,
d.name AS tid,
d.ipaddress AS ipaddress,
d.element_type_id AS element_type_id,
i.e1 AS e1,
i.e2 AS e2,
i.e3 AS e3,
i.e4 AS e4,
i.e5 AS e5,
i.name as interface,
it.namelbl AS namelbl,
f.customer_id AS customer_id,
c.name AS customer,
f.name AS facility,
f.id AS facility_id,
DECODE(f.active, 't', 'Act', 'Inact') AS facility_active,
tfm.trans_seq as trans_seq,
tfm.recv_seq as recv_seq,
e.name as element_type,
f.notes as notes
FROM
tids d,
interfaces i,
tid_interface_status tif,
tid_facility_map tfm,
facilities f,
customers c,
interface_types it,
element_types e,
flags ff
WHERE
tif.tid_id = d.id
AND ff.id = tif.flag
AND e.id = d.element_type_id
AND tif.interface_id = i.id
AND tfm.tid_id = d.id
AND tfm.interface_id = i.id
AND tfm.facility_id = f.id
AND c.id = f.customer_id
AND it.id = i.interface_type_id
;
commit; |
DROP TABLE IF EXISTS customer_deals CASCADE;
DROP TABLE IF EXISTS vendor_deals CASCADE;
DROP TABLE IF EXISTS archive CASCADE;
DROP TABLE IF EXISTS customers CASCADE;
DROP TABLE IF EXISTS vendors CASCADE;
DROP TABLE IF EXISTS users CASCADE; |
/*
Name: Before redirect
Data source: 4
Created By: Admin
Last Update At: 2016-02-05T15:00:18.472157+00:00
*/
SELECT post_prop10, page_url, post_prop72,count(*) as clicks
FROM (TABLE_QUERY(djomniture:cipomniture_djmansionglobal,'CONCAT(REPLACE(table_id,"_","-"),"-01") BETWEEN STRFTIME_UTC_USEC("{{startdate}}", "%Y-%m-01") and STRFTIME_UTC_USEC("{{enddate}}", "%Y-%m-31")'))
WHERE page_url LIKE '%from=article_page_berkshire_hathaway_widget%'
AND DATE(date_time) >= DATE('{{startdate}}')
AND DATE('{{startdate}}') >= DATE('2015-02-01')
AND DATE(date_time) <= DATE('{{enddate}}')
AND post_prop10 = ''
group by post_prop10, page_url, post_prop72,
order by clicks desc
|
select name, rentals_date from customers
join rentals on customers.id =rentals.id_customers
where rentals.rentals_date>='2016-09-01' and rentals.rentals_date<='2016-09-30'
|
SELECT * FROM streams
WHERE isapproved = 'false' AND user_id = $1 AND purchase_id IS NULL
ORDER BY
stream_id DESC |
ASSIGNMENT - 6
CREATION :
Create table Customers(CustomerID Number(1),CustomerName varchar2(20),ContactName Varchar2(20),Address Varchar2(20), City Varchar2(20), PostalCode Number(5), Country Varchar2(20));
Desc Customers;
Insertion:
SQL> Insert into Customers values(1,'Alfreds Futter','Maria Anders','Obere Str. 57','Berlin','Germany');
SQL> insert into Customers values(2,'Ana helados','Ana Trujillo','Avda. de la Constitución 2222','México D.F.','Mexico');
SQL> insert into Customers values(3,'Antonio Moreno','Antonio Moreno','Mataderos 2312','México D.F.','Mexico');
...
Create table Suppliers(SupplierID Number(1),SupplierName varchar2(20),ContactName Varchar2(20),Address Varchar2(20), City Varchar2(20), PostalCode Number(5), Country Varchar2(20));
Desc Suppliers;
Insertion:
SQL> Insert into Suppliers values(1,'Exotic Liquid','Charlotte Cooper','49 Gilbert St.','London',12209,'Germany');
SQL> insert into Suppliers values(2,'New Orleans Cajun Delights ','Shelley Burke','P.O. Box 78934','Mexico D.F.',05023,'Mexico');
SQL> insert into Suppliers values(3,'Grandma Kelly's Homestead','Regina Murphy','707 Oxford Rd.','Ann Arbor',48104,'USA');
QUERIES :
1. SELECT City FROM Customers
UNION
SELECT City FROM Suppliers
ORDER BY City;
2. SELECT City FROM Customers
UNION ALL
SELECT City FROM Suppliers
ORDER BY City;
3. SELECT City, Country FROM Customers
WHERE Country='Germany'
UNION
SELECT City, Country FROM Suppliers
WHERE Country='Germany'
ORDER BY City;
4. SELECT City, Country FROM Customers
WHERE Country='Germany'
UNION ALL
SELECT City, Country FROM Suppliers
WHERE Country='Germany'
ORDER BY City;
|
-- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Apr 25, 2021 at 09:48 AM
-- Server version: 10.3.27-MariaDB-0+deb10u1
-- PHP Version: 7.3.27-9+0~20210227.82+debian10~1.gbpa4a3d6
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `estore`
--
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE `category` (
`category_id` int(10) NOT NULL,
`category_name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `courier`
--
CREATE TABLE `courier` (
`courier_id` int(10) NOT NULL,
`courier_name` varchar(50) NOT NULL,
`courier_type` varchar(50) NOT NULL,
`courier_typePrice` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `customer`
--
CREATE TABLE `customer` (
`customer_id` int(10) NOT NULL,
`customer_name` varchar(50) NOT NULL,
`customer_gndr` int(1) NOT NULL,
`customer_address` text NOT NULL,
`customer_phone` varchar(15) NOT NULL,
`cusomer_email` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`orders_id` int(10) NOT NULL,
`customer_id` int(10) NOT NULL,
`shipping_id` int(10) NOT NULL,
`courier_AWB` varchar(50) NOT NULL,
`status` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `ordersDetail`
--
CREATE TABLE `ordersDetail` (
`id` int(10) NOT NULL,
`orders_id` int(10) NOT NULL,
`product_id` int(10) NOT NULL,
`quantity` int(2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `product`
--
CREATE TABLE `product` (
`product_id` int(10) NOT NULL,
`product_sku` varchar(10) NOT NULL,
`product_name` varchar(50) NOT NULL,
`product_desc` text NOT NULL,
`product_price` int(20) NOT NULL,
`product_stock` int(10) NOT NULL,
`product_images` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `productCategory`
--
CREATE TABLE `productCategory` (
`id` int(10) NOT NULL,
`category_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `shipping`
--
CREATE TABLE `shipping` (
`shipping` int(10) NOT NULL,
`shipping_name` varchar(100) NOT NULL,
`shipping_country` varchar(50) NOT NULL,
`shipping_province` varchar(50) NOT NULL,
`shipping_city` varchar(50) NOT NULL,
`shipping_subDistrict` varchar(50) NOT NULL,
`shipping_urbVillage` varchar(50) NOT NULL,
`shipping_postalCode` int(10) NOT NULL,
`shipping_method` int(1) NOT NULL,
`courier_id` int(10) NOT NULL,
`status` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `store`
--
CREATE TABLE `store` (
`store_id` int(10) NOT NULL,
`store_name` varchar(50) NOT NULL,
`store_address` text NOT NULL,
`store_owner` varchar(50) NOT NULL,
`store_phone` varchar(15) NOT NULL,
`store_WANumber` varchar(15) NOT NULL,
`store_TGNumber` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `transactions`
--
CREATE TABLE `transactions` (
`transactions_id` int(10) NOT NULL,
`order_id` int(10) NOT NULL,
`transaction_image` text NOT NULL,
`status` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`user_id` int(10) NOT NULL,
`user_username` varchar(10) NOT NULL,
`user_password` varchar(100) NOT NULL,
`user_role` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`category_id`);
--
-- Indexes for table `courier`
--
ALTER TABLE `courier`
ADD PRIMARY KEY (`courier_id`);
--
-- Indexes for table `customer`
--
ALTER TABLE `customer`
ADD PRIMARY KEY (`customer_id`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`orders_id`);
--
-- Indexes for table `ordersDetail`
--
ALTER TABLE `ordersDetail`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `product`
--
ALTER TABLE `product`
ADD PRIMARY KEY (`product_id`);
--
-- Indexes for table `productCategory`
--
ALTER TABLE `productCategory`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `shipping`
--
ALTER TABLE `shipping`
ADD PRIMARY KEY (`shipping`);
--
-- Indexes for table `store`
--
ALTER TABLE `store`
ADD PRIMARY KEY (`store_id`);
--
-- Indexes for table `transactions`
--
ALTER TABLE `transactions`
ADD PRIMARY KEY (`transactions_id`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`user_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `customer`
--
ALTER TABLE `customer`
MODIFY `customer_id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `store`
--
ALTER TABLE `store`
MODIFY `store_id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `user_id` int(10) 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 */;
|
SELECT ProductID, ObjectName, ModelID, Price
FROM Product INNER JOIN
ObjectName ON Product.ProductID = ObjectName.ObjectID AND Language = 'finnish'
WHERE Price >= ALL ( SELECT Price
FROM Product
);
|
--PUBLISHED BY :W.A.K HARSHANATH
--DATE :29/03/2021
--INSERT AUTHORS
insert into Author(author_id,author_name) values ( 1,'MARTIN WIKRAMASINGHE' );
insert into Author(author_id,author_name) values ( 2,'URI BONDEREV' );
insert into Author(author_id,author_name) values ( 3,'LIO THOLSTHOI' );
insert into Author(author_id,author_name) values ( 4,'MAXIM GORKI' );
insert into Author(author_id,author_name) values ( 5,'MARTIN LUTER' );
insert into Author(author_id,author_name) values ( 6,'ATHOR CONENDOIL' );
--INSERT CATEGORYS
insert into Category(category_id,category_name) values ( 1,'war' );
insert into Category(category_id,category_name) values ( 2,'adventur' );
insert into Category(category_id,category_name) values ( 3,'novel' );
insert into Category(category_id,category_name) values ( 4,'ict' );
insert into Category(category_id,category_name) values ( 5,'history' );
insert into Category(category_id,category_name) values ( 6,'statistic' );
--INSERT PUBLISHERS
insert into Publisher(publisher_id,publisher_name) values ( 1,'progress' );
insert into Publisher(publisher_id,publisher_name) values ( 2,'gunasena' );
insert into Publisher(publisher_id,publisher_name) values ( 3,'kurulu' );
--INSERT BOOKS
insert into Book(book_id,book_title,book_isbn,stock_quantity,borrow_quantity,available_quantity,publisher_id,category_id)
values ( 1,'BOOK1','ISBN1',100, 3,97,1,1);
insert into Book(book_id,book_title,book_isbn,stock_quantity,borrow_quantity,available_quantity,publisher_id,category_id)
values ( 2,'BOOK2','ISBN2',100, 2,98,1,1);
insert into Book(book_id,book_title,book_isbn,stock_quantity,borrow_quantity,available_quantity,publisher_id,category_id)
values ( 3,'BOOK3','ISBN3',100, 1,99,1,1);
insert into Book(book_id,book_title,book_isbn,stock_quantity,borrow_quantity,available_quantity,publisher_id,category_id)
values ( 4,'BOOK4','ISBN4',100, 2,98,1,1);
insert into Book(book_id,book_title,book_isbn,stock_quantity,borrow_quantity,available_quantity,publisher_id,category_id)
values ( 5,'BOOK5','ISBN5',100, 2,98,1,1);
--no one borrowed bellow book :test one
insert into Book(book_id,book_title,book_isbn,stock_quantity,borrow_quantity,available_quantity,publisher_id,category_id)
values ( 6,'BOOK6','ISBN6',100, 0,100,1,1);
--INSERT BOOK_AUTHOR
insert into author_book(book_id,author_id) values ( 1,1);
insert into author_book(book_id,author_id) values ( 1,5);
insert into author_book(book_id,author_id) values ( 1,6);
insert into author_book(book_id,author_id) values ( 2,3);
insert into author_book(book_id,author_id) values ( 3,2);
insert into author_book(book_id,author_id) values ( 4,1);
insert into author_book(book_id,author_id) values ( 5,1);
insert into author_book(book_id,author_id) values ( 1,4);
insert into author_book(book_id,author_id) values ( 2,2);
insert into author_book(book_id,author_id) values ( 3,1);
insert into author_book(book_id,author_id) values ( 4,2);
insert into author_book(book_id,author_id) values ( 5,3);
--INSERT SECTIONS
insert into Section(section_id,section_name,return_time_in_hr) values ( 1,'LENDING',336);
insert into Section(section_id,section_name,return_time_in_hr) values ( 2,'REFERENCING',6);
--INSERT BOOK_SECTION
insert into section_book(book_id,section_id) values ( 1,1);
insert into section_book(book_id,section_id) values ( 2,2);
insert into section_book(book_id,section_id) values ( 3,2);
insert into section_book(book_id,section_id) values ( 1,2);
insert into section_book(book_id,section_id) values ( 2,1);
insert into section_book(book_id,section_id) values ( 3,1);
insert into section_book(book_id,section_id) values ( 4,2);
insert into section_book(book_id,section_id) values ( 5,1);
--INSERT STUDENT
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 1,'ST1',1,0,2);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 2,'ST2',2,2,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 3,'ST3',3,0,1);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 4,'ST4',4,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 5,'ST5',5,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 6,'ST6',6,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 7,'ST7',7,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 8,'ST8',8,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 9,'ST9',9,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 10,'ST10',10,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 11,'ST11',11,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 12,'ST12',12,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 13,'ST13',13,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 14,'ST14',14,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 15,'ST15',15,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 16,'ST16',16,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 17,'ST17',17,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 18,'ST18',18,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 19,'ST19',19,0,0);
insert into Student(student_id,student_name,student_index_number,lended_book_quantity,reference_book_quantity) values ( 20,'ST120',20,0,0);
--INSERT STAFF
insert into Staff_Member(member_id,memeber_name,memeber_telephone,memeber_nic,lended_book_quantity,reference_book_quantity) values ( 1,'STF1','','123456789V',3,0);
insert into Staff_Member(member_id,memeber_name,memeber_telephone,memeber_nic,lended_book_quantity,reference_book_quantity) values ( 2,'STF2','','223456789V',0,2);
insert into Staff_Member(member_id,memeber_name,memeber_telephone,memeber_nic,lended_book_quantity,reference_book_quantity) values ( 3,'STF3','','323456789V',0,0);
insert into Staff_Member(member_id,memeber_name,memeber_telephone,memeber_nic,lended_book_quantity,reference_book_quantity) values ( 4,'STF4','','223406789V',0,0);
--INSERT REFERENCING
insert into Reference_book_operation_details(referencing_id,reference_book_issued_date,reference_book_due_date,Book_id,staff_memeber_id)
values ( 1,'2008-11-11 13:23:44','2008-11-11 13:23:44',1,2);
insert into Reference_book_operation_details(referencing_id,reference_book_issued_date,reference_book_due_date,Book_id,staff_memeber_id)
values ( 2,'2008-11-11 13:23:44','2008-11-11 13:23:44',1,2);
insert into Reference_book_operation_details(referencing_id,reference_book_issued_date,reference_book_due_date,Book_id,student_id)
values ( 3,'2008-11-11 13:23:44','2008-11-11 13:23:44',2,1);
insert into Reference_book_operation_details(referencing_id,reference_book_issued_date,reference_book_due_date,Book_id,student_id)
values ( 4,'2008-11-11 13:23:44','2008-11-11 13:23:44',2,1);
insert into Reference_book_operation_details(referencing_id,reference_book_issued_date,reference_book_due_date,Book_id,student_id)
values ( 5,'2008-11-11 13:23:44','2008-11-11 13:23:44',5,3);
--INSERT LENDING
insert into Lending_book_operation_details(lending_id,lending_book_issued_date,lending_book_due_date,Book_id,student_id)
values ( 1,'2008-11-11 13:23:44','2008-11-11 13:23:44',3,2);
insert into Lending_book_operation_details(lending_id,lending_book_issued_date,lending_book_due_date,Book_id,student_id)
values ( 2,'2008-11-11 13:23:44','2008-11-11 13:23:44',4,2);
insert into Lending_book_operation_details(lending_id,lending_book_issued_date,lending_book_due_date,Book_id,staff_memeber_id)
values ( 3,'2008-11-11 13:23:44','2008-11-11 13:23:44',5,1);
insert into Lending_book_operation_details(lending_id,lending_book_issued_date,lending_book_due_date,Book_id,staff_memeber_id)
values ( 4,'2008-11-11 13:23:44','2008-11-11 13:23:44',4,1);
insert into Lending_book_operation_details(lending_id,lending_book_issued_date,lending_book_due_date,Book_id,staff_memeber_id)
values ( 5,'2008-11-11 13:23:44','2008-11-11 13:23:44',1,1); |
DROP TABLE IF EXISTS locations;
DROP TABLE IF EXISTS student_registrations;
DROP TABLE IF EXISTS department_advisors;
DROP TABLE IF EXISTS messages;
DROP TABLE IF EXISTS course_section_schedules;
DROP TABLE IF EXISTS course_sections;
DROP TABLE IF EXISTS catalogs;
DROP TABLE IF EXISTS courses;
DROP TABLE IF EXISTS departments;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS buildings;
|
ALTER TABLE student_degree
ADD COLUMN tuition_form character varying (10);
ALTER TABLE student_degree
ADD COLUMN tuition_term character varying (10);
UPDATE student_degree
SET tuition_form = student_group.tuition_form,
tuition_term = student_group.tuition_term
FROM student_group
WHERE student_group.id = student_degree.student_group_id;
UPDATE student_degree SET tuition_form ='FULL_TIME'
WHERE tuition_form IS NULL;
UPDATE student_degree SET tuition_term = 'REGULAR'
WHERE tuition_term IS NULL;
ALTER TABLE student_degree
ALTER COLUMN tuition_form SET NOT NULL ;
ALTER TABLE student_degree
ALTER COLUMN tuition_term SET NOT NULL; |
alter table CURRENCY_CURRENCY_RATE alter column DATE_ rename to DATE___U59586 ;
alter table CURRENCY_CURRENCY_RATE alter column RATE rename to RATE__U14194 ;
alter table CURRENCY_CURRENCY_RATE alter column NAME rename to NAME__U89352 ;
alter table CURRENCY_CURRENCY_RATE alter column NUMERIC_CODE rename to NUMERIC_CODE__U61201 ;
alter table CURRENCY_CURRENCY_RATE alter column ALPHA_CODE rename to ALPHA_CODE__U07882 ;
alter table CURRENCY_CURRENCY_RATE alter column CODE rename to CODE__U01048 ;
alter table CURRENCY_CURRENCY_RATE add column BASE_CURRENCY_ID varchar(36) ;
alter table CURRENCY_CURRENCY_RATE add column SOURCE_CURRENCY varchar(100) ;
alter table CURRENCY_CURRENCY_RATE add column EXCHANGE_RATE decimal(19, 3) ;
alter table CURRENCY_CURRENCY_RATE add column EFFECTIVE_DATE date ;
alter table CURRENCY_CURRENCY_RATE add column RATE_PROVIDER varchar(255) ;
alter table CURRENCY_CURRENCY_RATE add column METHOD_ varchar(255) ;
|
-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Tempo de geração: 27-Fev-2020 às 18:57
-- Versão do servidor: 10.4.6-MariaDB
-- versão do PHP: 7.3.9
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: `syncready_database`
--
CREATE DATABASE IF NOT EXISTS `syncready_database` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `syncready_database`;
-- --------------------------------------------------------
--
-- Estrutura da tabela `alerts`
--
DROP TABLE IF EXISTS `alerts`;
CREATE TABLE `alerts` (
`pk_alerts` int(11) NOT NULL,
`uuid_alerts` varchar(255) NOT NULL DEFAULT uuid(),
`name_alerts` varchar(255) NOT NULL,
`alert_text` text DEFAULT NULL,
`created_at` datetime NOT NULL,
`until_at` datetime NOT NULL,
`Type_Of_Alert_uuid_type_of_alert` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `alerts`
--
INSERT INTO `alerts` (`pk_alerts`, `uuid_alerts`, `name_alerts`, `alert_text`, `created_at`, `until_at`, `Type_Of_Alert_uuid_type_of_alert`) VALUES
(1, '891225a8-5989-11ea-bd76-30d16bf72dc4', 'Eu sou um alerta, clique-me!', '1234567891011121314151617181920', '2020-02-27 17:49:43', '2020-02-27 17:49:43', '1e3348de-1f8a-11ea-a8e5-0242ac1d0002');
-- --------------------------------------------------------
--
-- Estrutura da tabela `companies`
--
DROP TABLE IF EXISTS `companies`;
CREATE TABLE `companies` (
`pk_companies` int(11) NOT NULL,
`uuid_company` varchar(255) NOT NULL DEFAULT uuid(),
`name` varchar(100) NOT NULL,
`company_address` varchar(100) NOT NULL,
`company_telephone` varchar(100) NOT NULL,
`company_email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `companies`
--
INSERT INTO `companies` (`pk_companies`, `uuid_company`, `name`, `company_address`, `company_telephone`, `company_email`) VALUES
(1, '1e39911a-1f8a-11ea-a8e5-0242ac1d0002', 'SyncReady', 'SyncReady - Portugal', '999999999', 'entity@syncready.pt'),
(3, 'ba588643-5988-11ea-bd76-30d16bf72dc4', 'Worten', 'Rua Fernando Lopes Graça nº17 1ºA, 2725-540 MEM MARTINS (Portugal)', '967451777', 'wortenempresas@worten.pt');
-- --------------------------------------------------------
--
-- Estrutura da tabela `datasheet`
--
DROP TABLE IF EXISTS `datasheet`;
CREATE TABLE `datasheet` (
`pk_datasheet` int(11) NOT NULL,
`uuid_datasheet` varchar(255) NOT NULL DEFAULT uuid(),
`description` text NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`designation` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `evaluations`
--
DROP TABLE IF EXISTS `evaluations`;
CREATE TABLE `evaluations` (
`pk_evaluation` int(11) NOT NULL,
`uuid_evaluation` varchar(255) NOT NULL,
`evaluation_num_stars` int(5) NOT NULL,
`evaluation_text` text NOT NULL,
`user_giver` varchar(255) NOT NULL,
`Rooms_uuid_room` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `messages`
--
DROP TABLE IF EXISTS `messages`;
CREATE TABLE `messages` (
`pk_message` int(11) NOT NULL,
`content` text NOT NULL,
`created_at` datetime NOT NULL,
`update_at` datetime NOT NULL,
`uuid_message` varchar(255) NOT NULL DEFAULT uuid(),
`Status_Message_uuid_status_message` varchar(100) NOT NULL,
`isImage` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `messages_has_users`
--
DROP TABLE IF EXISTS `messages_has_users`;
CREATE TABLE `messages_has_users` (
`Messages_uuid_message` varchar(255) NOT NULL DEFAULT uuid(),
`Users_pk_uuid` varchar(255) NOT NULL,
`Rooms_uuid_room` varchar(255) NOT NULL,
`sent_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `permissions`
--
DROP TABLE IF EXISTS `permissions`;
CREATE TABLE `permissions` (
`pk_permission` int(11) NOT NULL,
`uuid_permission` varchar(100) NOT NULL,
`permission_designation` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `rooms`
--
DROP TABLE IF EXISTS `rooms`;
CREATE TABLE `rooms` (
`pk_rooms` int(11) NOT NULL,
`uuid_room` varchar(255) NOT NULL DEFAULT uuid(),
`room_code` varchar(255) NOT NULL,
`name_room` varchar(100) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`until_at` datetime NOT NULL,
`Datasheet_uuid_datasheet` varchar(255) NOT NULL,
`image` varchar(255) DEFAULT 'default_group_image.png'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `status_message`
--
DROP TABLE IF EXISTS `status_message`;
CREATE TABLE `status_message` (
`pk_status_message` int(11) NOT NULL,
`uuid_status_message` varchar(100) NOT NULL DEFAULT uuid(),
`designation` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `status_message`
--
INSERT INTO `status_message` (`pk_status_message`, `uuid_status_message`, `designation`) VALUES
(1, '6bf609b3-3d12-11ea-993c-0242ac140002', 'Enviada'),
(2, '6bf60c15-3d12-11ea-993c-0242ac140002', 'Não enviada'),
(3, '6bf613d4-3d12-11ea-993c-0242ac140002', 'Lida'),
(4, '6bf6143c-3d12-11ea-993c-0242ac140002', 'Não Lida');
-- --------------------------------------------------------
--
-- Estrutura da tabela `status_room`
--
DROP TABLE IF EXISTS `status_room`;
CREATE TABLE `status_room` (
`pk_status_room` int(11) NOT NULL,
`uuid_status_room` varchar(45) NOT NULL,
`status_room_designation` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `tickets`
--
DROP TABLE IF EXISTS `tickets`;
CREATE TABLE `tickets` (
`pk_ticket` int(11) NOT NULL,
`uuid_ticket` varchar(100) NOT NULL DEFAULT uuid(),
`Users_pk_uuid` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`Ticket_Options_uuid_ticket_options` varchar(100) NOT NULL,
`Rooms_uuid_room` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `ticket_options`
--
DROP TABLE IF EXISTS `ticket_options`;
CREATE TABLE `ticket_options` (
`id_ticket_options` int(11) NOT NULL,
`uuid_ticket_options` varchar(100) NOT NULL,
`ticket_option_designation` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `ticket_options`
--
INSERT INTO `ticket_options` (`id_ticket_options`, `uuid_ticket_options`, `ticket_option_designation`) VALUES
(1, '1e3816e3-1f8a-11ea-a8e5-0242ac1d0002', 'Técnico pendente'),
(2, '1e381895-1f8a-11ea-a8e5-0242ac1d0002', 'Em funcionamento'),
(3, '1e381f6d-1f8a-11ea-a8e5-0242ac1d0002', 'Fechada'),
(4, '1e381fae-1f8a-11ea-a8e5-0242ac1d0002', 'Avaliada'),
(5, '1e381fcc-1f8a-11ea-a8e5-0242ac1d0002', 'Suspensa'),
(6, '1e381fe9-1f8a-11ea-a8e5-0242ac1d0002', 'Cancelada');
-- --------------------------------------------------------
--
-- Estrutura da tabela `type_of_alert`
--
DROP TABLE IF EXISTS `type_of_alert`;
CREATE TABLE `type_of_alert` (
`pk_type_of_alert` int(11) NOT NULL,
`uuid_type_of_alert` varchar(255) NOT NULL,
`type_of_alert_designation` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `type_of_alert`
--
INSERT INTO `type_of_alert` (`pk_type_of_alert`, `uuid_type_of_alert`, `type_of_alert_designation`) VALUES
(1, '1e3348de-1f8a-11ea-a8e5-0242ac1d0002', 'Informação'),
(2, '1e334b94-1f8a-11ea-a8e5-0242ac1d0002', 'Importante'),
(3, '1e3353bc-1f8a-11ea-a8e5-0242ac1d0002', 'Urgente');
-- --------------------------------------------------------
--
-- Estrutura da tabela `type_of_user`
--
DROP TABLE IF EXISTS `type_of_user`;
CREATE TABLE `type_of_user` (
`pk_type_of_user` int(11) NOT NULL,
`uuid_type_of_users` varchar(255) NOT NULL,
`type` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `type_of_user`
--
INSERT INTO `type_of_user` (`pk_type_of_user`, `uuid_type_of_users`, `type`) VALUES
(1, '1e35c91a-1f8a-11ea-a8e5-0242ac1d0002', 'Cliente'),
(2, '1e35cb49-1f8a-11ea-a8e5-0242ac1d0002', 'Técnico'),
(3, '1e35d267-1f8a-11ea-a8e5-0242ac1d0002', 'Entidade'),
(4, '1e35d2ad-1f8a-11ea-a8e5-0242ac1d0002', 'Administrador');
-- --------------------------------------------------------
--
-- Estrutura da tabela `type_of_user_has_alerts`
--
DROP TABLE IF EXISTS `type_of_user_has_alerts`;
CREATE TABLE `type_of_user_has_alerts` (
`Type_Of_User_uuid_type_of_users` varchar(255) NOT NULL,
`Alerts_uuid_alerts` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `type_of_user_has_alerts`
--
INSERT INTO `type_of_user_has_alerts` (`Type_Of_User_uuid_type_of_users`, `Alerts_uuid_alerts`) VALUES
('1e35c91a-1f8a-11ea-a8e5-0242ac1d0002', '891225a8-5989-11ea-bd76-30d16bf72dc4'),
('1e35cb49-1f8a-11ea-a8e5-0242ac1d0002', '891225a8-5989-11ea-bd76-30d16bf72dc4'),
('1e35d2ad-1f8a-11ea-a8e5-0242ac1d0002', '891225a8-5989-11ea-bd76-30d16bf72dc4');
-- --------------------------------------------------------
--
-- Estrutura da tabela `type_of_user_has_permissions`
--
DROP TABLE IF EXISTS `type_of_user_has_permissions`;
CREATE TABLE `type_of_user_has_permissions` (
`Type_Of_User_uuid_type_of_users` varchar(255) NOT NULL,
`Permissions_uuid_permission` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`pk_user` int(11) NOT NULL,
`pk_uuid` varchar(255) NOT NULL DEFAULT uuid(),
`nickname` varchar(100) NOT NULL,
`fullname` varchar(100) NOT NULL,
`address` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`telephone` varchar(100) NOT NULL,
`citizencard` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`update_at` datetime NOT NULL DEFAULT current_timestamp(),
`Type_Of_User_uuid_type_of_users` varchar(255) DEFAULT '1',
`image` varchar(255) DEFAULT 'default_user_image.png'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `users`
--
INSERT INTO `users` (`pk_user`, `pk_uuid`, `nickname`, `fullname`, `address`, `email`, `telephone`, `citizencard`, `password`, `created_at`, `update_at`, `Type_Of_User_uuid_type_of_users`, `image`) VALUES
(1, '944e4117-19f2-11ea-b615-30d16bf72dc4', 'syncready', 'SyncReady Company', 'SyncReady - Portugal', 'admin@syncready.pt', '999999999', '191994073ZV4', '63a9f0ea7bb98050796b649e85481845', '2019-12-15 22:28:03', '2019-12-15 22:28:03', '1e35d267-1f8a-11ea-a8e5-0242ac1d0002', 'default_user_image.png'),
(6, 'ba5a0c2d-5988-11ea-bd76-30d16bf72dc4', 'Worten Inc', 'Worten', 'Rua Fernando Lopes Graça nº17 1ºA, 2725-540 MEM MARTINS (Portugal)', 'wortenempresas@worten.pt', '967451777', '17069643 0 ZX7', '81a3e7f377d5346064f377c6b3e7de3e', '2020-02-27 17:43:56', '2020-02-27 17:43:56', '1e35d267-1f8a-11ea-a8e5-0242ac1d0002', 'default_user_image.png'),
(7, 'ec008be7-5988-11ea-bd76-30d16bf72dc4', 'joaquimteixeira', 'Joaquim Manuel da Silva Teixeira', 'Rua Fernando Lopes Graça nº17 1ºA, 2725-540 MEM MARTINS (Portugal)', 'joaquimteixeira@syncready.pt', '967451777', '19619360 5 ZX7', 'ef19699faddb1935b26580174e8e06fc', '2020-02-27 17:45:19', '2020-02-27 17:47:17', '1e35cb49-1f8a-11ea-a8e5-0242ac1d0002', 'default_user_image.png');
-- --------------------------------------------------------
--
-- Estrutura da tabela `users_has_companies`
--
DROP TABLE IF EXISTS `users_has_companies`;
CREATE TABLE `users_has_companies` (
`Users_pk_uuid` varchar(255) NOT NULL,
`Companies_uuid_company` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `users_has_companies`
--
INSERT INTO `users_has_companies` (`Users_pk_uuid`, `Companies_uuid_company`) VALUES
('944e4117-19f2-11ea-b615-30d16bf72dc4', '1e39911a-1f8a-11ea-a8e5-0242ac1d0002'),
('ba5a0c2d-5988-11ea-bd76-30d16bf72dc4', 'ba588643-5988-11ea-bd76-30d16bf72dc4'),
('ec008be7-5988-11ea-bd76-30d16bf72dc4', '1e39911a-1f8a-11ea-a8e5-0242ac1d0002');
-- --------------------------------------------------------
--
-- Estrutura da tabela `users_has_rooms`
--
DROP TABLE IF EXISTS `users_has_rooms`;
CREATE TABLE `users_has_rooms` (
`Users_pk_uuid` varchar(255) NOT NULL,
`Rooms_uuid_room` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Extraindo dados da tabela `users_has_rooms`
--
INSERT INTO `users_has_rooms` (`Users_pk_uuid`, `Rooms_uuid_room`) VALUES
('944e4117-19f2-11ea-b615-30d16bf72dc4', '61ea5625-5989-11ea-bd76-30d16bf72dc4');
--
-- Índices para tabelas despejadas
--
--
-- Índices para tabela `alerts`
--
ALTER TABLE `alerts`
ADD PRIMARY KEY (`pk_alerts`,`uuid_alerts`);
--
-- Índices para tabela `companies`
--
ALTER TABLE `companies`
ADD PRIMARY KEY (`pk_companies`,`uuid_company`);
--
-- Índices para tabela `datasheet`
--
ALTER TABLE `datasheet`
ADD PRIMARY KEY (`pk_datasheet`,`uuid_datasheet`),
ADD KEY `uuid_datasheet_idx1` (`uuid_datasheet`);
--
-- Índices para tabela `evaluations`
--
ALTER TABLE `evaluations`
ADD PRIMARY KEY (`pk_evaluation`,`uuid_evaluation`);
--
-- Índices para tabela `messages`
--
ALTER TABLE `messages`
ADD PRIMARY KEY (`pk_message`,`uuid_message`,`Status_Message_uuid_status_message`);
--
-- Índices para tabela `messages_has_users`
--
ALTER TABLE `messages_has_users`
ADD PRIMARY KEY (`Messages_uuid_message`,`Users_pk_uuid`);
--
-- Índices para tabela `permissions`
--
ALTER TABLE `permissions`
ADD PRIMARY KEY (`pk_permission`,`uuid_permission`);
--
-- Índices para tabela `rooms`
--
ALTER TABLE `rooms`
ADD PRIMARY KEY (`pk_rooms`,`uuid_room`,`room_code`),
ADD KEY `name_room_UNIQUE` (`name_room`);
--
-- Índices para tabela `status_message`
--
ALTER TABLE `status_message`
ADD PRIMARY KEY (`pk_status_message`,`uuid_status_message`),
ADD KEY `uuid_status_message_idx` (`uuid_status_message`);
--
-- Índices para tabela `status_room`
--
ALTER TABLE `status_room`
ADD PRIMARY KEY (`pk_status_room`,`uuid_status_room`),
ADD KEY `status_room_idx` (`status_room_designation`);
--
-- Índices para tabela `tickets`
--
ALTER TABLE `tickets`
ADD PRIMARY KEY (`pk_ticket`,`uuid_ticket`);
--
-- Índices para tabela `ticket_options`
--
ALTER TABLE `ticket_options`
ADD PRIMARY KEY (`id_ticket_options`,`uuid_ticket_options`);
--
-- Índices para tabela `type_of_alert`
--
ALTER TABLE `type_of_alert`
ADD PRIMARY KEY (`pk_type_of_alert`,`uuid_type_of_alert`);
--
-- Índices para tabela `type_of_user`
--
ALTER TABLE `type_of_user`
ADD PRIMARY KEY (`pk_type_of_user`,`uuid_type_of_users`);
--
-- Índices para tabela `type_of_user_has_alerts`
--
ALTER TABLE `type_of_user_has_alerts`
ADD PRIMARY KEY (`Type_Of_User_uuid_type_of_users`,`Alerts_uuid_alerts`);
--
-- Índices para tabela `type_of_user_has_permissions`
--
ALTER TABLE `type_of_user_has_permissions`
ADD PRIMARY KEY (`Type_Of_User_uuid_type_of_users`,`Permissions_uuid_permission`);
--
-- Índices para tabela `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`pk_user`,`pk_uuid`),
ADD UNIQUE KEY `pk_uuid_UNIQUE` (`pk_uuid`);
--
-- Índices para tabela `users_has_companies`
--
ALTER TABLE `users_has_companies`
ADD PRIMARY KEY (`Users_pk_uuid`,`Companies_uuid_company`);
--
-- Índices para tabela `users_has_rooms`
--
ALTER TABLE `users_has_rooms`
ADD PRIMARY KEY (`Users_pk_uuid`,`Rooms_uuid_room`);
--
-- AUTO_INCREMENT de tabelas despejadas
--
--
-- AUTO_INCREMENT de tabela `alerts`
--
ALTER TABLE `alerts`
MODIFY `pk_alerts` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `companies`
--
ALTER TABLE `companies`
MODIFY `pk_companies` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `datasheet`
--
ALTER TABLE `datasheet`
MODIFY `pk_datasheet` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `evaluations`
--
ALTER TABLE `evaluations`
MODIFY `pk_evaluation` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de tabela `messages`
--
ALTER TABLE `messages`
MODIFY `pk_message` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de tabela `rooms`
--
ALTER TABLE `rooms`
MODIFY `pk_rooms` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `status_message`
--
ALTER TABLE `status_message`
MODIFY `pk_status_message` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `status_room`
--
ALTER TABLE `status_room`
MODIFY `pk_status_room` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de tabela `tickets`
--
ALTER TABLE `tickets`
MODIFY `pk_ticket` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `ticket_options`
--
ALTER TABLE `ticket_options`
MODIFY `id_ticket_options` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `type_of_alert`
--
ALTER TABLE `type_of_alert`
MODIFY `pk_type_of_alert` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `type_of_user`
--
ALTER TABLE `type_of_user`
MODIFY `pk_type_of_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT de tabela `users`
--
ALTER TABLE `users`
MODIFY `pk_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
Create Procedure sp_han_FreeOrderDetails (@OrderNumber as nvarchar(50), @Order_Detail_Id as int)
as
Select SD.[ORDERNUMBER], SD.[FreeProductCode], SD.[FreeItemQty] "FQty"
,IsNull(u.[UOM], 0) 'UOM_ID', IsNull(u.[Description], '') 'UOM_Desc'
,IsNull(i.Product_Code, '') 'Item_Code'
,IsNull(i.UOM, 0) 'Item_UOM'
,IsNull(i.UOM1, 0) 'Item_UOM1'
,IsNull(i.UOM2, 0) 'Item_UOM2'
,IsNull(i.TrackPKD, 0) 'Item_TrackPKD'
,IsNull(i.CategoryID, 0) 'Item_CategoryID'
,IsNull(ic.Track_Inventory, 0) 'Item_TrackInventory'
,IsNull(ic.Price_Option, 0) 'Item_PriceOption'
,IsNull(batch.Batch_Number, '') 'Batch_Number'
,IsNull(batch.Item_Code, '') 'Batch_Itemexists'
,'Item_Converter' = IsNull((Case When u.[UOM] = i.UOM1 Then IsNull(UOM1_Conversion, 1)
When u.[UOM] = i.UOM2 Then IsNull(UOM2_Conversion, 1) Else 1 End), 1)
,[FREE PERCENTAGE] 'Discount'
,FreeVALUE 'DiscountValue'
From Scheme_Details SD
Left Outer Join Items i On i.Product_Code = SD.[FreeProductCode]
Left Outer Join ItemCategories ic On i.CategoryID = ic.Categoryid
Left Outer Join UOM u On u.UOM = SD.[FreeitemUOMID]
Left Outer Join
(Select b.Product_Code 'Item_Code', b.Batch_Number, b.SalePrice,
IsNull(b.TaxSuffered, 0) TaxSuffered, IsNull(b.ecp , 0) ecp, IsNull(b.PTS,0) PTS,
IsNull(b.PTR,0) PTR, IsNull(b.Company_Price,0) Company_Price,
IsNull(b.ApplicableOn,0) ApplicableOn, IsNull(b.Partofpercentage,0) Partofpercentage
From Batch_Products b
Where b.Product_Code in (Select Distinct d.[FreeProductCode] From Scheme_Details d
Where d.[ORDERNUMBER] = @OrderNumber)
And b.batch_code = (Select top 1 bc.batch_Code
From batch_products bc Where bc.Product_Code = b.Product_Code
And bc.Quantity > 0 And IsNull(bc.Damage, 0) = 0
And IsNull(bc.Expiry, getdate()) >= getdate()
Order By IsNull(bc.Free, 0) desc, bc.Batch_Code)) batch
On batch.Item_Code = SD.[FreeProductCode]
Where SD.[ORDERNUMBER] = @OrderNumber and SD.Order_Detail_ID = @Order_Detail_ID
and Isnull(SD.SchemeID, 0) = 0 and Isnull([FREE PERCENTAGE], 0) = 0 and Isnull(FreeVALUE, 0) = 0
Order by SD.ORDER_DETAIL_ID, SD.OrderNumber, SD.OrderedProductCode
|
INSERT INTO user(ID, NAME, PASSWORD, SALT, MOBILE) VALUES (1, 'tom', 'cat', 'xxx', '18112345678');
|
USE burgers_db;
INSERT INTO burgers (burger_name, devoured) VALUES ("double cheeseburger", true),
("triple cheeseburger", true), ("animal style burger", true); |
create or replace view v1_hdjh004_zball_bak as
(
select f."CZDE397",f."DE011",f."DE007",f."CZDE420",f."JSDE221",f."DE181",f."JSDE053",f."CZDE391",f."JSDE901",f."JSDE940",
f."DE042",f."JSDE955",f."DE151",f."DE001",f."JSDE909",f."CZDE388",f."CZDE387",f."DE390",f."DE382",f."DE384",f."JSDE220",f."DE281",
f."CZDE954",f."DE052",f."JSDE960",f."JSDE961",f."CZDE095",nvl(f."CZDE053",0) czde053,f."CZDE054",f."JSDE041",f."JSDE039",f."JSDE012",f."JSDE016",
f."CZDE057",f."JSDE214",f."DE062",f."CZDE938",f."JSDE068",f."JSDE019",f."JSDE014",f."CZDE940",f."CZDE941",f."JSDE090",f."JSDE999",f."DE022",
f."JSDE007",f."DE102",f.de101,f.de102||f."DE101" as xmdmmc,f."CZDE126",f."DE046",f."DE050",f."CZDE061",f."DE192",f."HDDE149",
nvl(f."HDDE150",0) hdde150,f."CZDED34",nvl(f."HDDE151",0) hdde151,nvl(f."HDDE152",0) hdde152,
f."JSDE963",f.jsde964,f.jsde965,nvl(f.HDDE157,0) hdde157,to_char(f.CZDE402,'yyyy-mm-dd') CZDE402,nvl(f.czde015,0) czde015,f.czde425,f.czde435,f.czde438,
f.hdde170,f.hdde171,
case
when nvl(f.hdde170,0) <> 0 then 1--资质项
when nvl(f.hdde171,0) <> 0 then 2--预采项
else 0
end tslx,
/* (select sum(a.de181) from zb010 a,zb006 b where jsde013=25 and a.jsde107 = b.jsde107 and a.jsde115 = f.czde397
and b.de186 like '1%') as czbzje,
(select sum(a.de181) from zb010 a,zb006 b where jsde013=25 and a.jsde107 = b.jsde107 and a.jsde115 = f.czde397
and b.de186 like '9%') as yswje,*/
nvl((select sum(SYJE) from v1_hdcgzbjhb where de186 like '1%' and czde397 = f.czde397),0) as czbzje,
nvl((select sum(SYJE) from v1_hdcgzbjhb where de186 like '9%' and czde397 = f.czde397),0) as yswje,
(select sum(a.de181) from hdjh005 a where a.czde397 = f.czde397 and a.czde056 = 0) as qtzj,
(select jsde121 from zb099 b where b.jsde117='HDJH004' and f.czde397=b.jsde125) FJ,
(select zbbh from v1_hdjh004_zbbh a where a.czde397 = f.czde397) as tzdbh,
(select sum(a.de181) from hdcg005 a where a.czde397 = f.czde397) as cgzbje,--中标金额
to_char((select distinct min(jsde318) from hdcg005 a where a.czde397 = f.czde397),'yyyy-mm-dd') as SCZBSJ--首次中标时间
from hdjh004 f )
;
|
update dblloguers l
inner join (select
sum(round((d.preu / 7) * d.dias,2)) as monto, d.`ID LLOGUER` as id
from migracioncasacaliente.detalllloguer d
group by d.`ID LLOGUER`) d on l.idlloguer = d.id
set l.total = d.monto |
whenever sqlerror exit failure;
-- droper tabeller og seksvenser om de eksisterer fra før.
set echo off
declare
type varchar2_arr is varray(6) of varchar2(100);
drop_table_arr varchar2_arr := varchar2_arr('drop table dk_p.sbs_fagsak cascade constraints purge'
,'drop table dk_p.sbs_behandling cascade constraints purge'
,'drop sequence dk_p.seq_sbs_fagsak'
,'drop sequence dk_p.seq_sbs_behandling'
);
begin
for i in 1..drop_table_arr.count loop
begin
execute immediate drop_table_arr(i);
exception
when others then
if sqlcode not in (-942,-2289) then
raise;
end if;
end;
end loop;
end;
/
set echo on
create sequence dk_p.seq_sbs_fagsak cache 100;
create sequence dk_p.seq_sbs_behandling cache 100;
-- Tabell som inneholder behandlingshode
create table dk_p.sbs_fagsak(
pk_sbs_fagsak number(38) not null
,lk_sbs_fagsak_t varchar2(40) not null
,lk_sbs_fagsak varchar2(40) not null
,lk_aktoer varchar2(20)
,fk_person1 number(38) not null
,fagsak_kode varchar(40)
,fagsak_under_kode varchar(40)
,status_kode varchar(40)
,saksnummer_kode varchar(40)
,opprettet_trans_tid timestamp(6)
,inngang_tid timestamp(6)
,funksjonell_tid timestamp(6)
,data_opphav varchar(40) not null
,lastet_session varchar(40) not null
,lastet_dato timestamp(6)
,oppdatert_dato timestamp(6)
,kildesystem varchar(40) not null
) column store compress for query high
partition by list (kildesystem)
(
partition fpsak
values ('FPSAK'),
partition melosys
values ('MELOSYS'),
partition infotrygd
values ('INFOTRYGD'),
partition other
values (default)
)
;
create unique index dk_p.pk_sbs_fagsak on dk_p.sbs_fagsak (lk_sbs_fagsak, kildesystem) local;
alter table dk_p.sbs_fagsak add constraint pk_sbs_fagsak primary key (lk_sbs_fagsak, kildesystem) rely using index dk_p.pk_sbs_fagsak;
grant select on dk_p.sbs_fagsak to dvh_dk_p_ro_role;
grant insert, update, delete on dk_p.sbs_fagsak to dvh_dk_p_rw_role;
-- Tabell som inneholder behandling
create table dk_p.sbs_behandling(
pk_sbs_behandling number(38) not null
,lk_sbs_fagsak varchar(40)
,lk_sbs_behandling_t varchar(40)
,lk_sbs_behandling varchar(40)
,lk_sbs_behandling_relatert varchar(40)
,lk_sbs_behandling_vedtak varchar(40)
,lk_org_enhet_inngang varchar(40)
,lk_org_enhet_avsluttet varchar(40)
,lk_org_enhet_naavarende varchar2(40)
,fk_ek_org_node_inngang number(38) not null
,fk_ek_org_node_avsluttet number(38) not null
,fk_ek_org_node_naavarende number(38)
,fk_sbs_fagsak number(38) not null
,fk_behandling_status number(38) not null
,fk_sak_resultat number(38) not null
,fk_sak_type number(38) not null
,fk_utenlandstilsnitt_fin number(38) not null
,behandling_kode varchar(100)
,behandling_status_kode varchar(40)
,resultat_kode varchar(40)
,sak_type_kode varchar(100)
,opprettet_trans_tid timestamp(6)
,funksjonell_tid timestamp(6)
,inngang_tid timestamp(6)
,mottatt_tid timestamp(6)
,registrert_tid timestamp(6)
,dato_for_uttak timestamp(6)
,innstilt_klage_tid timestamp(6)
,innstilt_vedtak_tid timestamp(6)
,avsluttet_tid timestamp(6)
,inngang_saksbehandler varchar(40)
,avsluttet_saksbehandler varchar(40)
,avsluttet_beslutter varchar(40)
,avsluttet_flagg number(1) not null
,totrinn_flagg number(1) not null
,slettet_flagg number(1) not null
,data_opphav varchar(40) not null
,lastet_session varchar(40) not null
,lastet_dato timestamp(6)
,oppdatert_dato timestamp(6)
,kildesystem varchar(40) not null
) column store compress for query high
partition by list (kildesystem)
(
partition fpsak
values ('FPSAK'),
partition melosys
values ('MELOSYS'),
partition infotrygd
values ('INFOTRYGD'),
partition other
values (default)
)
;
create unique index dk_p.pk_sbs_behandling on dk_p.sbs_behandling (lk_sbs_behandling, kildesystem) local;
alter table dk_p.sbs_behandling add constraint pk_sbs_behandling primary key (lk_sbs_behandling, kildesystem) rely using index dk_p.pk_sbs_behandling;
grant select on dk_p.sbs_behandling to dvh_dk_p_ro_role;
grant insert, update, delete on dk_p.sbs_behandling to dvh_dk_p_rw_role;
alter table dk_p.sbs_behandling
add constraint fk_sbs_fagsak_behandling
foreign key (lk_sbs_fagsak, kildesystem)
references dk_p.sbs_fagsak (lk_sbs_fagsak, kildesystem)
rely disable novalidate;
alter table dk_p.sbs_behandling_historikk
add constraint fk_sbs_behandling
foreign key (lk_sbs_behandling, kildesystem)
references dk_p.sbs_behandling (lk_sbs_behandling, kildesystem)
rely disable novalidate;
alter table dk_p.sbs_fagsak_historikk
add constraint fk_sbs_fagsak
foreign key (lk_sbs_fagsak, kildesystem)
references dk_p.sbs_fagsak (lk_sbs_fagsak, kildesystem)
rely disable novalidate;
|
set hive.execution.engine=spark;
drop table if exists dws.dws_report_revenue_detail;
create table if not exists dws.dws_report_revenue_detail (
create_date timestamp ,
apply_no string ,
company_name string ,
product_type string COMMENT '产品类型',
product_name string ,
product_name_c string ,
is_overtime string COMMENT '是否超期',
fk_amount double COMMENT '当日放款金额',
m_fk_amount double COMMENT '当月放款金额',
net_charge_amount double COMMENT '当日净收费',
m_net_charge_amount double COMMENT '当月净收费',
zt_amount double COMMENT '当日在途余额',
customer_capital_cost double COMMENT '当日客户资金成本',
lc_value double COMMENT '当日利差',
ljjsryg_amount double COMMENT '当日累计净收入预估',
avg_zt_amount double COMMENT '当月日均在途余额',
m_avg_rlc_value double COMMENT '当月平均日利差',
m_ljjsryg_amount double COMMENT '当月净收入预估',
drzjcb_amount double COMMENT '当日资金成本',
drlrfy_amount double COMMENT '当日录入返佣金额',
m_drlrfy_amount double COMMENT '当月录入返佣金额',
m_drzjcb_amount double COMMENT '当月资金成本'
);
with tmp_month as (
select
b.apply_no, b.company_name, b.product_type, b.product_name_c, b.product_name, b.is_overtime
,sum(b.fk_amount) m_fk_amount
,sum(b.zt_amount) m_zt_amount
,sum(b.ljjsryg_amount) m_ljjsryg_amount
,sum(b.drzjcb_amount) m_drzjcb_amount
from dws.tmp_report_revenue_part_two_detail b
where b.create_date >= DATE_FORMAT(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1),"yyyy-MM-01")
group by b.apply_no, b.company_name, b.product_type, b.product_name_c, b.product_name, b.is_overtime
),
tmp_csc1 as (
select
apply_no, to_date(trans_day) trans_day_d, sum(trans_money) trans_money
from ods.ods_bpms_c_cost_trade cct
where cct.trans_type = 'CSC1'
group by apply_no, to_date(trans_day)
),
tmp_csd1 as (
select
apply_no, to_date(trans_day) trans_day_d, sum(trans_money) trans_money
from ods.ods_bpms_c_cost_trade cct
where cct.trans_type = 'CSD1' and cct.trade_status = 1
group by apply_no, to_date(trans_day)
),
tmp_charge_amount as (
select
a.apply_no
,a.company_name
,a.product_name
,a.product_type
,a.product_name_c
,b.trans_day_d create_date
,a.is_overtime
,nvl(sum(b.trans_money), 0) charge_amount
,0 return_premium_amount
from tmp_csc1 as b
left join dws.tmp_report_revenue_part_two_detail as a on a.apply_no = b.apply_no
where b.trans_day_d >= date_format(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), "yyyy-MM-01") and b.trans_day_d < date_add(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), 1)
GROUP BY a.apply_no, a.company_name, a.product_name, a.product_type, a.product_name_c, a.is_overtime, b.trans_day_d
union all
select
a.apply_no
,a.company_name
,a.product_name
,a.product_type
,a.product_name_c
,b.trans_day_d create_date
,a.is_overtime
,0 charge_amount
,nvl(sum(b.trans_money), 0) return_premium_amount
from tmp_csd1 as b
left join dws.tmp_report_revenue_part_two_detail as a on a.apply_no = b.apply_no
where b.trans_day_d >= date_format(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), "yyyy-MM-01") and b.trans_day_d < date_add(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), 1)
GROUP BY
a.apply_no, a.company_name, a.product_name, a.product_type, a.product_name_c, a.is_overtime, b.trans_day_d
),
tmp_lrfy as (
select irpo.apply_no, irpo.company_name, irpo.product_name, irpo.product_type, irpo.product_name_c, irpo.is_overtime
,sum(s_bl.humanpool_rebate) hsfy_amount
,0 fpfy_amount
,0 dsdffy_amount
from ods.ods_bpms_biz_ledger_pay s_bl
left join dws.tmp_report_revenue_part_one irpo on s_bl.apply_no = irpo.apply_no
where s_bl.humanpool_payment_day >= date_format(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), "yyyy-MM-01") and s_bl.humanpool_payment_day < date_add(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), 1)
group by irpo.apply_no, irpo.company_name, irpo.product_name, irpo.product_type, irpo.product_name_c, irpo.is_overtime
union all
-- 当日录入返佣金额-发票报销
select irpo.apply_no, irpo.company_name, irpo.product_name, irpo.product_type, irpo.product_name_c, irpo.is_overtime
,0 hsfy_amount
,sum(s_bl.invoice_rebate) fpfy_amount
,0 dsdffy_amount
from ods.ods_bpms_biz_ledger_invoice s_bl
left join dws.tmp_report_revenue_part_one irpo on s_bl.apply_no = irpo.apply_no
where s_bl.invoice_submit_day >= date_format(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), "yyyy-MM-01") and s_bl.invoice_submit_day < date_add(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), 1)
group by irpo.apply_no, irpo.company_name, irpo.product_name, irpo.product_type, irpo.product_name_c, irpo.is_overtime
union all
-- 当日录入返佣金额-发票报销
select irpo.apply_no, irpo.company_name, irpo.product_name, irpo.product_type, irpo.product_name_c, irpo.is_overtime
,0 hsfy_amount
,0 fpfy_amount
,sum(replace_turn_out) dsdffy_amount
from ods.ods_bpms_biz_ledger_instead s_bl
left join dws.tmp_report_revenue_part_one irpo on s_bl.apply_no = irpo.apply_no
where s_bl.replace_turn_day >= date_format(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), "yyyy-MM-01") and s_bl.replace_turn_day < date_add(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), 1)
group by irpo.apply_no, irpo.company_name, irpo.product_name, irpo.product_type, irpo.product_name_c, irpo.is_overtime
)
insert overwrite table dws.dws_report_revenue_detail
select
date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1) create_date
,a.apply_no, a.company_name, a.product_type, a.product_name, a.product_name_c, a.is_overtime
,round(sum(fk_amount), 6) fk_amount
,round(sum(m_fk_amount), 6) m_fk_amount
,round(sum(net_charge_amount), 6) net_charge_amount
,round(sum(m_net_charge_amount), 6) m_net_charge_amount
,round(sum(zt_amount), 6) zt_amount
,round(sum(customer_capital_cost), 6) customer_capital_cost
,round(sum(lc_value), 6) lc_value
,round(sum(ljjsryg_amount), 6) ljjsryg_amount
,round(sum(avg_zt_amount), 6) avg_zt_amount
,round(sum(m_avg_rlc_value), 6) m_avg_rlc_value
,round(sum(m_ljjsryg_amount), 6) m_ljjsryg_amount
,round(sum(drzjcb_amount), 6) drzjcb_amount
,round(sum(drlrfy_amount), 6) drlrfy_amount
,round(sum(m_drlrfy_amount), 6) m_drlrfy_amount
,round(sum(m_drzjcb_amount), 6) m_drzjcb_amount
from (
-- ------------------------------分割线 A--------------------------------------------
SELECT
a.create_date,
a.apply_no,
a.company_name,
a.product_type,
a.product_name,
a.product_name_c,
a.is_overtime,
cc.fk_amount,
tm.m_fk_amount,
cc.net_charge_amount,
0 m_net_charge_amount,
cc.zt_amount,
cc.customer_capital_cost,
cc.lc_value,
cc.ljjsryg_amount,
tm.m_zt_amount / day(a.create_date) avg_zt_amount,
(
tm.m_ljjsryg_amount
/ tm.m_zt_amount / day(a.create_date)
/ day(a.create_date)*360
) m_avg_rlc_value,
tm.m_ljjsryg_amount,
cc.drzjcb_amount,
cc.drlrfy_amount,
0 m_drlrfy_amount,
tm.m_drzjcb_amount
FROM (
-- 筛选出当月的订单
select date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1) as create_date, a.apply_no, a.company_name, a.product_type, a.product_name, a.product_name_c, a.is_overtime
from dws.tmp_report_revenue_part_two_detail a
where create_date >= date_format(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1), "yyyy-MM-01")
group by a.apply_no, a.company_name, a.product_type, a.product_name, a.product_name_c, a.is_overtime
) a
left join tmp_month tm on a.apply_no = tm.apply_no
and a.company_name = tm.company_name
and a.product_type = tm.product_type
and a.product_name_c = tm.product_name_c
and a.product_name = tm.product_name
and a.is_overtime = tm.is_overtime
left join dws.tmp_report_revenue_part_two_detail cc on a.apply_no = cc.apply_no
and a.company_name = cc.company_name
and a.product_type = cc.product_type
and a.product_name_c = cc.product_name_c
and a.product_name = cc.product_name
and a.is_overtime = cc.is_overtime
and cc.create_date = date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1)
-- ------------------------------分割线 A--------------------------------------------
union all
-- ------------------------------分割线 B--------------------------------------------
select
date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1) create_date
,a.apply_no, a.company_name ,a.product_type ,a.product_name ,a.product_name_c ,a.is_overtime
,0 fk_amount
,0 m_fk_amount
,0 net_charge_amount
,sum(charge_amount) - sum(return_premium_amount) m_net_charge_amount
,0 zt_amount
,0 customer_capital_cost
,0 lc_value
,0 ljjsryg_amount
,0 avg_zt_amount
,0 m_avg_rlc_value
,0 m_ljjsryg_amount
,0 drzjcb_amount
,0 drlrfy_amount
,0 m_drlrfy_amount
,0 m_drzjcb_amount
from tmp_charge_amount as a
group by a.apply_no, a.company_name ,a.product_name ,a.product_type ,a.product_name_c ,a.is_overtime, a.create_date
-- ------------------------------分割线 B--------------------------------------------
union all
-- ------------------------------分割线 C--------------------------------------------
select
date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'), 1) create_date
,a.apply_no ,a.company_name ,a.product_type ,a.product_name ,a.product_name_c ,a.is_overtime
,0 fk_amount
,0 m_fk_amount
,0 net_charge_amount
,0 m_net_charge_amount
,0 zt_amount
,0 customer_capital_cost
,0 lc_value
,0 ljjsryg_amount
,0 avg_zt_amount
,0 m_avg_rlc_value
,0 m_ljjsryg_amount
,0 drzjcb_amount
,0 drlrfy_amount
,nvl(sum(a.hsfy_amount),0) + nvl(sum(a.fpfy_amount), 0) + nvl(sum(a.dsdffy_amount), 0) m_drlrfy_amount
,0 m_drzjcb_amount
from tmp_lrfy as a
group by a.apply_no, a.company_name ,a.product_name ,a.product_type ,a.product_name_c ,a.is_overtime
-- ------------------------------分割线 C--------------------------------------------
) as a
where a.product_name is not null
group by a.apply_no, a.company_name, a.product_name, a.product_type, a.product_name_c, a.is_overtime |
DELETE FROM meals
WHERE totalmealstat_id = ${mealplanId} |
/*
付款申请-费用明细
*/
delimiter $
drop trigger if exists Tgr_ApplyForPaymentsDetail_AftereInsert $
create trigger Tgr_ApplyForPaymentsDetail_AftereInsert after insert
on ApplyForPaymentsDetail
for each row
begin
declare sKeyModaul varchar(255);
declare sKeyNo varchar(255);
set sKeyModaul=new.KeyModaul;
set sKeyNo=new.KeyNo;
if sKeyModaul='收样管理' then
call Proc_ReceiveSamples_SumAppliedChargeed(sKeyNo);-- 收样管理-已申快件费
call Proc_ReceiveSamples_SumAppliedForPayment(sKeyNo);-- 收样管理-已申请样品费
end if;
if sKeyModaul='寄样管理' then
call Proc_SendSamples_SumAppliedForPayment(sKeyNo);-- 寄样管理-已申请付款
end if;
if ifNull(sKeyModaul,'')='开票通知' then
call Proc_BillNotifies_AppliedForPayment(sKeyNo);-- 开票通知-已申请货款
end if;
if sKeyModaul='出运明细' then
call Proc_Shipments_SumAppliedForOverSeas(sKeyNo);-- 出运明细-已申请国外
call Proc_Shipments_SumAppliedForDomestic(sKeyNo);-- 出运明细-已申请国内
end if;
if sKeyModaul='采购合同' then
call Proc_PurchaseOrders_AppliedForPayment(sKeyNo);-- 采购合同-已申请定金
end if;
end$
delimiter ; |
--------------------------------------------------------
-- File created - Thursday-July-02-2020
--------------------------------------------------------
--------------------------------------------------------
-- DDL for Table GERBONG
--------------------------------------------------------
CREATE TABLE "AMAR90487"."GERBONG"
( "ID_GERBONG" VARCHAR2(20 CHAR),
"ID_KERETA" VARCHAR2(20 CHAR),
"NOMOR" NUMBER(*,0),
"KAPASITAS" NUMBER(*,0)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Table JADWAL
--------------------------------------------------------
CREATE TABLE "AMAR90487"."JADWAL"
( "ID_JADWAL" VARCHAR2(20 CHAR),
"ID_KERETA" VARCHAR2(20 CHAR),
"ID_MASINIS" VARCHAR2(20 CHAR),
"TANGGAL" VARCHAR2(20 CHAR),
"JAM" VARCHAR2(20 CHAR),
"TUJUAN" VARCHAR2(20 CHAR)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Table JENIS_KELAS
--------------------------------------------------------
CREATE TABLE "AMAR90487"."JENIS_KELAS"
( "ID_KELAS" VARCHAR2(20 CHAR),
"NAMA_KELAS" VARCHAR2(20 CHAR),
"KETERANGAN" VARCHAR2(100 CHAR)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Table KERETA_API
--------------------------------------------------------
CREATE TABLE "AMAR90487"."KERETA_API"
( "ID_KERETA" VARCHAR2(20 CHAR),
"NAMA_KERETA" VARCHAR2(20 CHAR),
"ID_KELAS" VARCHAR2(20 CHAR),
"GERBONG" NUMBER(*,0)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Table MANAGER
--------------------------------------------------------
CREATE TABLE "AMAR90487"."MANAGER"
( "ID_MANAGER" VARCHAR2(20 CHAR),
"NAMA" VARCHAR2(50 CHAR),
"NO_KTP" NUMBER(20,0),
"ALAMAT" VARCHAR2(100 CHAR),
"TGL_LAHIR" VARCHAR2(20 CHAR),
"USERNAME" VARCHAR2(20 CHAR),
"PASSWORD" VARCHAR2(30 CHAR)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Table MASINIS
--------------------------------------------------------
CREATE TABLE "AMAR90487"."MASINIS"
( "ID_MASINIS" VARCHAR2(20 CHAR),
"NAMA" VARCHAR2(50 CHAR),
"NO_KTP" VARCHAR2(20 CHAR),
"ALAMAT" VARCHAR2(100 CHAR),
"TGL_LAHIR" VARCHAR2(20 CHAR),
"USERNAME" VARCHAR2(20 CHAR),
"PASSWORD" VARCHAR2(30 CHAR)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Table PENUMPANG
--------------------------------------------------------
CREATE TABLE "AMAR90487"."PENUMPANG"
( "ID_PENUMPANG" VARCHAR2(20 CHAR),
"NAMA" VARCHAR2(50 CHAR),
"NO_KTP" NUMBER(20,0),
"UMUR" NUMBER(3,0),
"ALAMAT" VARCHAR2(100 CHAR)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Table PETUGAS
--------------------------------------------------------
CREATE TABLE "AMAR90487"."PETUGAS"
( "ID_PETUGAS" VARCHAR2(20 CHAR),
"NAMA" VARCHAR2(50 CHAR),
"NO_KTP" VARCHAR2(20 CHAR),
"ALAMAT" VARCHAR2(100 CHAR),
"TGL_LAHIR" VARCHAR2(20 CHAR),
"USERNAME" VARCHAR2(20 CHAR),
"PASSWORD" VARCHAR2(30 CHAR)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for View Daftar Jadwal
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."Daftar Jadwal" ("ID_JADWAL", "WAKTU", "TUJUAN") AS
select id_jadwal, waktu, tujuan from jadwal where id_manager = 'Manager001'
;
--------------------------------------------------------
-- DDL for View Daftar Jadwal1
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."Daftar Jadwal1" ("ID_JADWAL", "WAKTU", "TUJUAN") AS
select id_jadwal, waktu, tujuan from jadwal where id_manager = 'Manager001'
;
--------------------------------------------------------
-- DDL for View HAPUS_DATA_MASINIS
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."HAPUS_DATA_MASINIS" ("ID_MASINIS", "NAMA", "NO_KTP", "ALAMAT", "TGL_LAHIR", "USERNAME", "PASSWORD") AS
(select"ID_MASINIS","NAMA","NO_KTP","ALAMAT","TGL_LAHIR","USERNAME","PASSWORD"from masinis)
;
--------------------------------------------------------
-- DDL for View JOIN_1
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."JOIN_1" ("Nama Manager", "Id Jadwal") AS
select nama as "Nama Manager", id_jadwal as "Id Jadwal" from jadwal join manager on jadwal.id_manager = manager.id_manager where jadwal.id_kereta = 'KRA0001' and jadwal.tujuan = 'Jakarta'
;
--------------------------------------------------------
-- DDL for View JOIN_11
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."JOIN_11" ("Nama Manager", "Id Jadwal") AS
select nama as "Nama Manager", id_jadwal as "Id Jadwal" from jadwal join manager on jadwal.id_manager = manager.id_manager where jadwal.id_kereta = 'KRA0001' and jadwal.tujuan != 'Jakarta'
;
--------------------------------------------------------
-- DDL for View JOIN_111
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."JOIN_111" ("Nama Manager", "Id Jadwal") AS
select nama as "Nama Manager", id_jadwal as "Id Jadwal" from jadwal join manager on jadwal.id_manager = manager.id_manager where jadwal.id_kereta = 'KRA0001' and jadwal.tujuan != 'Jakarta'
;
--------------------------------------------------------
-- DDL for View JOIN_2
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."JOIN_2" ("NAMA", "ID_JADWAL", "NAMA_KERETA") AS
select nama as "Nama Manager", id_jadwal as "Id Jadwal", nama_kereta as "Nama Kereta" from jadwal left join manager on manager.id_manager = jadwal.id_manager left join kereta_api on kereta_api.id_kereta = jadwal.id_kereta WHERE id_jadwal in (select id_jadwal from stok_tiket where stok_tiket.id_jadwal = jadwal.id_jadwal)
;
--------------------------------------------------------
-- DDL for View JOIN_3
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."JOIN_3" ("TUJUAN", "ID_KERETA", "STOK_TIKET") AS
select jadwal.tujuan, kereta_api.id_kereta, max(stok_tiket) as "Stok Tiket terbanyak" from stok_tiket right join jadwal on stok_tiket.id_jadwal = jadwal.id_jadwal right join kereta_api on kereta_api.id_kereta = jadwal.id_kereta GROUP BY jadwal.tujuan, kereta_api.id_kereta
;
--------------------------------------------------------
-- DDL for View JOIN_33
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."JOIN_33" ("TUJUAN", "ID_KERETA", "STOK_TIKET") AS
select jadwal.tujuan, kereta_api.id_kereta, max(stok_tiket) as "Stok Tiket terbanyak" from stok_tiket right join jadwal on stok_tiket.id_jadwal = jadwal.id_jadwal right join kereta_api on kereta_api.id_kereta = jadwal.id_kereta GROUP BY jadwal.tujuan, kereta_api.id_kereta
;
--------------------------------------------------------
-- DDL for View JOIN_333
--------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "AMAR90487"."JOIN_333" ("TUJUAN", "ID_KERETA", "STOK_TIKET") AS
select jadwal.tujuan, kereta_api.id_kereta, max(stok_tiket) as "Stok Tiket terbanyak" from stok_tiket right join jadwal on stok_tiket.id_jadwal = jadwal.id_jadwal right join kereta_api on kereta_api.id_kereta = jadwal.id_kereta GROUP BY jadwal.tujuan, kereta_api.id_kereta
;
REM INSERTING into AMAR90487.GERBONG
SET DEFINE OFF;
REM INSERTING into AMAR90487.JADWAL
SET DEFINE OFF;
Insert into AMAR90487.JADWAL (ID_JADWAL,ID_KERETA,ID_MASINIS,TANGGAL,JAM,TUJUAN) values ('JD0001','KR0001','Masinis001','16-06-2020','23:36:12','Sidoarjo');
Insert into AMAR90487.JADWAL (ID_JADWAL,ID_KERETA,ID_MASINIS,TANGGAL,JAM,TUJUAN) values ('JD0002','KR0001','Masinis001','16-07-2020','17:15:59','Surabaya');
REM INSERTING into AMAR90487.JENIS_KELAS
SET DEFINE OFF;
Insert into AMAR90487.JENIS_KELAS (ID_KELAS,NAMA_KELAS,KETERANGAN) values ('K0001','Ekonomi','Murah Meriah cok');
Insert into AMAR90487.JENIS_KELAS (ID_KELAS,NAMA_KELAS,KETERANGAN) values ('K0002','Kaya Banget','dasdasd');
REM INSERTING into AMAR90487.KERETA_API
SET DEFINE OFF;
Insert into AMAR90487.KERETA_API (ID_KERETA,NAMA_KERETA,ID_KELAS,GERBONG) values ('KR0002','Naga','K0002','4');
Insert into AMAR90487.KERETA_API (ID_KERETA,NAMA_KERETA,ID_KELAS,GERBONG) values ('KR0003','Darmo','K0001','6');
Insert into AMAR90487.KERETA_API (ID_KERETA,NAMA_KERETA,ID_KELAS,GERBONG) values ('KR0001','Dragon','K0001','8');
REM INSERTING into AMAR90487.MANAGER
SET DEFINE OFF;
Insert into AMAR90487.MANAGER (ID_MANAGER,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Manager001','Andika','1234567890','Sidoarjo','11-SEP-87','MGR0001','1234');
Insert into AMAR90487.MANAGER (ID_MANAGER,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Manager002','Saiful','7213782731','Surabaya','04-JAN-89','MGR0002','1234');
Insert into AMAR90487.MANAGER (ID_MANAGER,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Manager003','Rafli','8234293823','Surabaya','06-JAN-88','MGR0003','1234');
REM INSERTING into AMAR90487.MASINIS
SET DEFINE OFF;
Insert into AMAR90487.MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis002','Rizky','1234567890','Sidoarjo','11-06-2020','MS0002','1234');
Insert into AMAR90487.MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis0004','Rizky','1234567890','Surabaya','09-07-2020','Rizky123','1234');
Insert into AMAR90487.MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis001','Amar','1234567890','Janti','20-01-1999','MS0001','1234');
Insert into AMAR90487.MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis0003','Testing','1234567890','Janti','08-07-2020','MS0005','1234');
REM INSERTING into AMAR90487.PENUMPANG
SET DEFINE OFF;
REM INSERTING into AMAR90487.PETUGAS
SET DEFINE OFF;
Insert into AMAR90487.PETUGAS (ID_PETUGAS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('PT0001','Amar','1234','Janti','10-06-2020','Amar1','1234');
Insert into AMAR90487.PETUGAS (ID_PETUGAS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('PT0002','Amar2','123456','Surabaya','10-06-2020','Tes','1234');
REM INSERTING into AMAR90487."Daftar Jadwal"
SET DEFINE OFF;
REM INSERTING into AMAR90487."Daftar Jadwal1"
SET DEFINE OFF;
REM INSERTING into AMAR90487.HAPUS_DATA_MASINIS
SET DEFINE OFF;
Insert into AMAR90487.HAPUS_DATA_MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis002','Rizky','1234567890','Sidoarjo','11-06-2020','MS0002','1234');
Insert into AMAR90487.HAPUS_DATA_MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis0004','Rizky','1234567890','Surabaya','09-07-2020','Rizky123','1234');
Insert into AMAR90487.HAPUS_DATA_MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis001','Amar','1234567890','Janti','20-01-1999','MS0001','1234');
Insert into AMAR90487.HAPUS_DATA_MASINIS (ID_MASINIS,NAMA,NO_KTP,ALAMAT,TGL_LAHIR,USERNAME,PASSWORD) values ('Masinis0003','Testing','1234567890','Janti','08-07-2020','MS0005','1234');
REM INSERTING into AMAR90487.JOIN_1
SET DEFINE OFF;
REM INSERTING into AMAR90487.JOIN_11
SET DEFINE OFF;
REM INSERTING into AMAR90487.JOIN_111
SET DEFINE OFF;
REM INSERTING into AMAR90487.JOIN_2
SET DEFINE OFF;
REM INSERTING into AMAR90487.JOIN_3
SET DEFINE OFF;
REM INSERTING into AMAR90487.JOIN_33
SET DEFINE OFF;
REM INSERTING into AMAR90487.JOIN_333
SET DEFINE OFF;
--------------------------------------------------------
-- DDL for Index PK_JADWAL
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_JADWAL" ON "AMAR90487"."JADWAL" ("ID_JADWAL")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index PK_TB_GERBONG_ID
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_TB_GERBONG_ID" ON "AMAR90487"."GERBONG" ("ID_GERBONG")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index PK_TB_JENIS_KELAS_ID
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_TB_JENIS_KELAS_ID" ON "AMAR90487"."JENIS_KELAS" ("ID_KELAS")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index PK_TB_KERETA_API_ID
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_TB_KERETA_API_ID" ON "AMAR90487"."KERETA_API" ("ID_KERETA")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index PK_TB_MANAGER_ID
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_TB_MANAGER_ID" ON "AMAR90487"."MANAGER" ("ID_MANAGER")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index PK_TB_MASINIS_ID
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_TB_MASINIS_ID" ON "AMAR90487"."MASINIS" ("ID_MASINIS")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index PK_TB_PENUMPANG_ID
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_TB_PENUMPANG_ID" ON "AMAR90487"."PENUMPANG" ("ID_PENUMPANG")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index PK_TB_PETUGAS_ID
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."PK_TB_PETUGAS_ID" ON "AMAR90487"."PETUGAS" ("ID_PETUGAS")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index SYS_C008536
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."SYS_C008536" ON "AMAR90487"."PETUGAS" ("USERNAME")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index SYS_C008545
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."SYS_C008545" ON "AMAR90487"."MANAGER" ("USERNAME")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- DDL for Index SYS_C008554
--------------------------------------------------------
CREATE UNIQUE INDEX "AMAR90487"."SYS_C008554" ON "AMAR90487"."MASINIS" ("USERNAME")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ;
--------------------------------------------------------
-- Constraints for Table GERBONG
--------------------------------------------------------
ALTER TABLE "AMAR90487"."GERBONG" ADD CONSTRAINT "PK_TB_GERBONG_ID" PRIMARY KEY ("ID_GERBONG")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."GERBONG" MODIFY ("KAPASITAS" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."GERBONG" MODIFY ("NOMOR" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."GERBONG" MODIFY ("ID_KERETA" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."GERBONG" MODIFY ("ID_GERBONG" NOT NULL ENABLE);
--------------------------------------------------------
-- Constraints for Table JADWAL
--------------------------------------------------------
ALTER TABLE "AMAR90487"."JADWAL" ADD CONSTRAINT "PK_JADWAL" PRIMARY KEY ("ID_JADWAL")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."JADWAL" MODIFY ("TUJUAN" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."JADWAL" MODIFY ("JAM" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."JADWAL" MODIFY ("TANGGAL" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."JADWAL" MODIFY ("ID_MASINIS" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."JADWAL" MODIFY ("ID_KERETA" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."JADWAL" MODIFY ("ID_JADWAL" NOT NULL ENABLE);
--------------------------------------------------------
-- Constraints for Table JENIS_KELAS
--------------------------------------------------------
ALTER TABLE "AMAR90487"."JENIS_KELAS" ADD CONSTRAINT "PK_TB_JENIS_KELAS_ID" PRIMARY KEY ("ID_KELAS")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."JENIS_KELAS" MODIFY ("KETERANGAN" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."JENIS_KELAS" MODIFY ("NAMA_KELAS" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."JENIS_KELAS" MODIFY ("ID_KELAS" NOT NULL ENABLE);
--------------------------------------------------------
-- Constraints for Table KERETA_API
--------------------------------------------------------
ALTER TABLE "AMAR90487"."KERETA_API" ADD CONSTRAINT "PK_TB_KERETA_API_ID" PRIMARY KEY ("ID_KERETA")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."KERETA_API" MODIFY ("GERBONG" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."KERETA_API" MODIFY ("ID_KELAS" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."KERETA_API" MODIFY ("NAMA_KERETA" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."KERETA_API" MODIFY ("ID_KERETA" NOT NULL ENABLE);
--------------------------------------------------------
-- Constraints for Table MANAGER
--------------------------------------------------------
ALTER TABLE "AMAR90487"."MANAGER" ADD UNIQUE ("USERNAME")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."MANAGER" ADD CONSTRAINT "PK_TB_MANAGER_ID" PRIMARY KEY ("ID_MANAGER")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."MANAGER" MODIFY ("PASSWORD" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MANAGER" MODIFY ("USERNAME" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MANAGER" MODIFY ("TGL_LAHIR" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MANAGER" MODIFY ("ALAMAT" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MANAGER" MODIFY ("NO_KTP" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MANAGER" MODIFY ("NAMA" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MANAGER" MODIFY ("ID_MANAGER" NOT NULL ENABLE);
--------------------------------------------------------
-- Constraints for Table MASINIS
--------------------------------------------------------
ALTER TABLE "AMAR90487"."MASINIS" ADD UNIQUE ("USERNAME")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."MASINIS" ADD CONSTRAINT "PK_TB_MASINIS_ID" PRIMARY KEY ("ID_MASINIS")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."MASINIS" MODIFY ("PASSWORD" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MASINIS" MODIFY ("USERNAME" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MASINIS" MODIFY ("TGL_LAHIR" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MASINIS" MODIFY ("ALAMAT" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MASINIS" MODIFY ("NO_KTP" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MASINIS" MODIFY ("NAMA" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."MASINIS" MODIFY ("ID_MASINIS" NOT NULL ENABLE);
--------------------------------------------------------
-- Constraints for Table PENUMPANG
--------------------------------------------------------
ALTER TABLE "AMAR90487"."PENUMPANG" ADD CONSTRAINT "PK_TB_PENUMPANG_ID" PRIMARY KEY ("ID_PENUMPANG")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."PENUMPANG" MODIFY ("ALAMAT" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PENUMPANG" MODIFY ("UMUR" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PENUMPANG" MODIFY ("NO_KTP" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PENUMPANG" MODIFY ("NAMA" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PENUMPANG" MODIFY ("ID_PENUMPANG" NOT NULL ENABLE);
--------------------------------------------------------
-- Constraints for Table PETUGAS
--------------------------------------------------------
ALTER TABLE "AMAR90487"."PETUGAS" ADD UNIQUE ("USERNAME")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."PETUGAS" ADD CONSTRAINT "PK_TB_PETUGAS_ID" PRIMARY KEY ("ID_PETUGAS")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "TUGAS_PRAKTIKUM_BD_90487" ENABLE;
ALTER TABLE "AMAR90487"."PETUGAS" MODIFY ("PASSWORD" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PETUGAS" MODIFY ("USERNAME" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PETUGAS" MODIFY ("TGL_LAHIR" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PETUGAS" MODIFY ("ALAMAT" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PETUGAS" MODIFY ("NO_KTP" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PETUGAS" MODIFY ("NAMA" NOT NULL ENABLE);
ALTER TABLE "AMAR90487"."PETUGAS" MODIFY ("ID_PETUGAS" NOT NULL ENABLE);
--------------------------------------------------------
-- Ref Constraints for Table GERBONG
--------------------------------------------------------
ALTER TABLE "AMAR90487"."GERBONG" ADD CONSTRAINT "FK_TB_GERBONG_IDKERETA" FOREIGN KEY ("ID_KERETA")
REFERENCES "AMAR90487"."KERETA_API" ("ID_KERETA") ON DELETE CASCADE ENABLE;
--------------------------------------------------------
-- Ref Constraints for Table JADWAL
--------------------------------------------------------
ALTER TABLE "AMAR90487"."JADWAL" ADD CONSTRAINT "FK_KERETA" FOREIGN KEY ("ID_KERETA")
REFERENCES "AMAR90487"."KERETA_API" ("ID_KERETA") ENABLE;
ALTER TABLE "AMAR90487"."JADWAL" ADD CONSTRAINT "FK_MASINIS" FOREIGN KEY ("ID_MASINIS")
REFERENCES "AMAR90487"."MASINIS" ("ID_MASINIS") ENABLE;
--------------------------------------------------------
-- Ref Constraints for Table KERETA_API
--------------------------------------------------------
ALTER TABLE "AMAR90487"."KERETA_API" ADD CONSTRAINT "FK_TB_KERETA_API_KELASID" FOREIGN KEY ("ID_KELAS")
REFERENCES "AMAR90487"."JENIS_KELAS" ("ID_KELAS") ENABLE;
|
Create Procedure SP_Precheck_FSU
AS
BEGIN
update Setup set FSUinstallFlag=1
Select distinct isnull(HostName,'') from Master.dbo.sysprocesses
Where dbid in (Select dbid from Master.dbo.sysdatabases Where name like 'Minerva_%')
And isnull(HostName,'') <> host_name()
END
|
-- phpMyAdmin SQL Dump
-- version 4.1.6
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 28, 2017 at 02:35 PM
-- Server version: 5.6.16
-- PHP Version: 5.5.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 utf8 */;
--
-- Database: `technofarm`
--
-- --------------------------------------------------------
--
-- Table structure for table `contracts`
--
CREATE TABLE IF NOT EXISTS `contracts` (
`contract_id` int(11) NOT NULL AUTO_INCREMENT,
`type` enum('rent','ownership') COLLATE utf8_bin NOT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
`rent` decimal(13,2) DEFAULT NULL,
`price` decimal(13,2) DEFAULT NULL,
PRIMARY KEY (`contract_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=7 ;
--
-- Dumping data for table `contracts`
--
INSERT INTO `contracts` (`contract_id`, `type`, `start_date`, `end_date`, `rent`, `price`) VALUES
(1, 'rent', '2017-06-26', '2018-06-25', '100.00', '0.00'),
(3, 'ownership', '2017-06-01', '2017-06-01', '0.00', '1000.00'),
(4, 'ownership', '2017-06-27', '2017-06-27', '0.00', '1000.00'),
(5, 'rent', '2017-06-01', '2018-06-01', '41.00', '0.00'),
(6, 'rent', '2014-06-30', '2016-06-30', '65.00', '0.00');
-- --------------------------------------------------------
--
-- Table structure for table `contract_property`
--
CREATE TABLE IF NOT EXISTS `contract_property` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ctr_id` int(11) NOT NULL,
`property_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=22 ;
--
-- Dumping data for table `contract_property`
--
INSERT INTO `contract_property` (`id`, `ctr_id`, `property_id`) VALUES
(1, 1, 1343),
(3, 1, 2411),
(7, 3, 3111),
(8, 3, 4515),
(9, 4, 1536),
(10, 5, 1538),
(11, 3, 2113),
(18, 5, 1553),
(20, 5, 1515),
(21, 6, 1517);
-- --------------------------------------------------------
--
-- Table structure for table `ouner`
--
CREATE TABLE IF NOT EXISTS `ouner` (
`ouner_id` int(4) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_bin NOT NULL,
`egn` varchar(8) COLLATE utf8_bin NOT NULL,
`phone` varchar(10) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`ouner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=3 ;
--
-- Dumping data for table `ouner`
--
INSERT INTO `ouner` (`ouner_id`, `name`, `egn`, `phone`) VALUES
(1, 'Камен Влахов', '84121221', '08888888'),
(2, 'Иван Шишман', '84212121', '08888');
-- --------------------------------------------------------
--
-- Table structure for table `property`
--
CREATE TABLE IF NOT EXISTS `property` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`unic_id` int(11) NOT NULL,
`area` decimal(10,0) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=33 ;
--
-- Dumping data for table `property`
--
INSERT INTO `property` (`id`, `unic_id`, `area`) VALUES
(14, 1234, '12'),
(16, 2411, '20'),
(17, 3111, '20'),
(18, 4515, '10'),
(19, 1536, '10'),
(20, 1538, '40'),
(21, 2113, '12'),
(23, 1516, '10'),
(28, 1553, '53'),
(31, 1515, '5'),
(32, 1517, '20');
-- --------------------------------------------------------
--
-- Table structure for table `property_ouner`
--
CREATE TABLE IF NOT EXISTS `property_ouner` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`property_id` int(11) NOT NULL,
`ouner_id` int(11) NOT NULL,
`part` decimal(10,0) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=7 ;
--
-- Dumping data for table `property_ouner`
--
INSERT INTO `property_ouner` (`id`, `property_id`, `ouner_id`, `part`) VALUES
(1, 1234, 1, '50'),
(2, 1234, 2, '50'),
(3, 1553, 1, '50'),
(5, 1515, 2, '50'),
(6, 1517, 2, '30');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE TABLE IF NOT EXISTS DEPARTMENTS (
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
DEPARTMENT VARCHAR(50) DEFAULT NULL,
DISTRICT VARCHAR(50) DEFAULT NULL
) |
-- phpMyAdmin SQL Dump
-- version 4.2.7.1
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tiempo de generación: 26-03-2015 a las 15:45:58
-- Versión del servidor: 5.5.39
-- Versión de PHP: 5.4.31
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: `tasksadmin`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `task`
--
CREATE TABLE IF NOT EXISTS `task` (
`id` int(11) NOT NULL,
`description` text NOT NULL,
`priority` int(11) NOT NULL,
`end_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`topic` varchar(64) NOT NULL,
`type` varchar(64) NOT NULL,
`completed` int(11) NOT NULL,
`user` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL,
`username` varchar(64) NOT NULL,
`password` varchar(128) NOT NULL,
`email` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `task`
--
ALTER TABLE `task`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`,`email`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `task`
--
ALTER TABLE `task`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE VIEW reviews_for_news_check
AS SELECT *from review
WHERE news_id = 1
WITH LOCAL CHECK OPTION;
INSERT INTO reviews_for_news_check(review_id, client_id, news_id, article)
VALUES (5,3,1,'Hello');
CREATE VIEW author_of_the_news
AS SELECT *from news
WHERE author_id = 1
WITH LOCAL CHECK OPTION;
|
CREATE TABLE `civicrm__lookup_payment_type` (
`payment_type_id` int(11) DEFAULT NULL,
`payment_type` varchar(200) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='could not find this info - creating by hand';
/*
4 Check
1 Credit Card
3 Cash
5 Other
*/ |
create or replace view v_jk006 as
(
select jkdm,de011,de022,rq,
nvl(sum(decode(lcsjlx, 1, na)),0) as je1,
nvl(sum(decode(lcsjlx, 2, na)),0) as je2,
nvl(sum(decode(lcsjlx, 3, na)),0) as je3,
nvl(sum(decode(lcsjlx, 4, na)),0) as je4
from jk006
group by jkdm,de011,de022,rq
);
|
INSERT INTO `core_DBversion` VALUES ('4', '0', '0', '2008-11-07 14:19:11'); |
Create Procedure sp_update_CompanyName (@CompanyID nvarchar(50), @CompanyName_ClientDB nvarchar(4000))
as
update Setup Set OrganisationTitle = @CompanyName_ClientDB Where RegisteredOwner = @CompanyID
|
create table tb_state_order
(
id int auto_increment
primary key,
id_payment int not null,
id_execution int not null,
constraint tb_state_order_tb_execution_id_execution_fk
foreign key (id_execution) references tb_execution (id_execution),
constraint tb_state_order_tb_payment_id_payment_fk
foreign key (id_payment) references tb_payment (id_payment)
);
|
/*
** Question: https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends/
*/
-- method 1, LC solution
-- The key is to use UNION ALL so that COUNT will take into considertation of id both
-- when it's a requester and an accepter.
select
top 1
ids as id, cnt as num
from
(
select ids, count(*) as cnt
from
(
select requester_id as ids from request_accepted
union all
select accepter_id from request_accepted
) as tbl1
group by ids
) as tbl2
order by cnt desc
;
-- method 1, Oracle
WITH friends_num AS (
SELECT
COALESCE(t1.requester_id, t2.accepter_id) AS id,
(CASE WHEN t1.cnt IS NULL THEN 0 ELSE t1.cnt END) +
(CASE WHEN t2.cnt IS NULL THEN 0 ELSE t2.cnt END) AS num
FROM
(SELECT requester_id, COUNT(*) AS cnt
FROM request_accepted
GROUP BY requester_id) t1
FULL OUTER JOIN
(SELECT accepter_id, COUNT(*) AS cnt
FROM request_accepted
GROUP BY accepter_id
) t2 ON t1.requester_id = t2.accepter_id
)
SELECT t1.id, t1.num
FROM
(
SELECT
f.id, f.num,
RANK() OVER (ORDER BY f.num DESC) AS pos
FROM friends_num f
) t1
WHERE t1.pos = 1
;
-- method 2, MS SQL Server
SELECT
TOP 1
COALESCE(t1.requester_id, t2.accepter_id) AS id,
(CASE WHEN t1.cnt IS NULL THEN 0 ELSE t1.cnt END) +
(CASE WHEN t2.cnt IS NULL THEN 0 ELSE t2.cnt END) AS num
FROM
(SELECT requester_id, COUNT(*) AS cnt
FROM request_accepted
GROUP BY requester_id) t1
FULL OUTER JOIN
(SELECT accepter_id, COUNT(*) AS cnt
FROM request_accepted
GROUP BY accepter_id
) t2 ON t1.requester_id = t2.accepter_id
ORDER BY num DESC
;
-- method 3, MS SQL server
-- use correlated subquery
SELECT
TOP 1
t1.id,
(SELECT COUNT(*)
FROM request_accepted
WHERE requester_id = t1.id OR accepter_id = t1.id) AS num
FROM
(
SELECT requester_id AS id
FROM request_accepted
UNION
SELECT accepter_id AS id
FROM request_accepted
) t1
ORDER BY num DESC
;
|
alter table users
rename column birthdate to birthday; |
CREATE TABLE users (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
login CHAR(50) NOT NULL,
password CHAR(50) NOT NULL,
email VARCHAR(50)
); |
/*
Navicat SQLite Data Transfer
Source Server : BestRater
Source Server Version : 30706
Source Host : :0
Target Server Type : SQLite
Target Server Version : 30706
File Encoding : 65001
Date: 2012-04-12 01:25:10
*/
PRAGMA foreign_keys = OFF;
-- ----------------------------
-- Table structure for "main"."categories"
-- ----------------------------
DROP TABLE "main"."categories";
CREATE TABLE "categories" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" VARCHAR(50) NOT NULL,
"adjective" VARCHAR(20),
"searchKeyword" VARCHAR(50) NOT NULL,
"urlName" VARCHAR(20) NOT NULL
);
-- ----------------------------
-- Records of categories
-- ----------------------------
-- ----------------------------
-- Table structure for "main"."imageCategory"
-- ----------------------------
DROP TABLE "main"."imageCategory";
CREATE TABLE "imageCategory" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"imageID" INTEGER NOT NULL,
"categoryID" INTEGER NOT NULL,
"upvotes" INTEGER NOT NULL,
"downvotes" INTEGER NOT NULL,
"score" INTEGER NOT NULL,
CONSTRAINT "fk_ic_image" FOREIGN KEY ("imageID") REFERENCES "images" ("id") ON DELETE CASCADE,
CONSTRAINT "fk_ic_category" FOREIGN KEY ("categoryID") REFERENCES "categories" ("id") ON DELETE CASCADE
);
-- ----------------------------
-- Records of imageCategory
-- ----------------------------
-- ----------------------------
-- Table structure for "main"."images"
-- ----------------------------
DROP TABLE "main"."images";
CREATE TABLE "images" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"isLocal" BOOLEAN NOT NULL,
"file" VARCHAR(50) NOT NULL,
"url" VARCHAR(600) NOT NULL,
"caption" VARCHAR(50)
);
-- ----------------------------
-- Records of images
-- ----------------------------
|
CREATE procedure sp_get_BanknBranch (@Customer nvarchar(15))
as
Select Top 1 Collections.BankCode, BankMaster.BankName, Collections.BranchCode,
BranchMaster.BranchName From Collections, BranchMaster, BankMaster
Where Collections.CustomerID = @Customer And
Collections.BankCode = BankMaster.BankCode And
Collections.BranchCode = BranchMaster.BranchCode And
Collections.BankCode = BranchMaster.BankCode
Order By Collections.DocumentDate Desc
|
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ##### ### #####
# # ## ## # # # # # # # # ## ## # # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### # # # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # # ### # # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ### ##### #### # # #### # # # # # # # # # ####
sql server script to create foreign key, unique, and check constraints within the OMOP common data model, version 6.0
last revised: 2018-04-12
*************************/
/************************
*************************
*************************
*************************
Foreign key constraints
*************************
*************************
*************************
************************/
/**************************
Standardized meta-data
***************************/
ALTER TABLE cdm.metadata ADD CONSTRAINT fpk_metadata_concept FOREIGN KEY (metadata_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.metadata ADD CONSTRAINT fpk_metadata_type_concept FOREIGN KEY (metadata_type_concept_id) REFERENCES cdm.concept (concept_id);
/************************
Standardized clinical data
************************/
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_gender_concept FOREIGN KEY (gender_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_race_concept FOREIGN KEY (race_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_ethnicity_concept FOREIGN KEY (ethnicity_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_gender_concept_s FOREIGN KEY (gender_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_race_concept_s FOREIGN KEY (race_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_ethnicity_concept_s FOREIGN KEY (ethnicity_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_location FOREIGN KEY (location_id) REFERENCES cdm.location (location_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.person ADD CONSTRAINT fpk_person_care_site FOREIGN KEY (care_site_id) REFERENCES cdm.care_site (care_site_id);
ALTER TABLE cdm.observation_period ADD CONSTRAINT fpk_observation_period_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.observation_period ADD CONSTRAINT fpk_observation_period_concept FOREIGN KEY (period_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.specimen ADD CONSTRAINT fpk_specimen_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.specimen ADD CONSTRAINT fpk_specimen_concept FOREIGN KEY (specimen_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.specimen ADD CONSTRAINT fpk_specimen_type_concept FOREIGN KEY (specimen_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.specimen ADD CONSTRAINT fpk_specimen_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.specimen ADD CONSTRAINT fpk_specimen_site_concept FOREIGN KEY (anatomic_site_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.specimen ADD CONSTRAINT fpk_specimen_status_concept FOREIGN KEY (disease_status_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.death ADD CONSTRAINT fpk_death_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.death ADD CONSTRAINT fpk_death_type_concept FOREIGN KEY (death_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.death ADD CONSTRAINT fpk_death_cause_concept FOREIGN KEY (cause_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES cdm.care_site (care_site_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_occurrence ADD CONSTRAINT fpk_visit_preceding FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_concept FOREIGN KEY (visit_detail_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_type_concept FOREIGN KEY (visit_detail_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care_site_id) REFERENCES cdm.care_site (care_site_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_detail_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_preceding FOREIGN KEY (preceding_visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpk_v_detail_parent FOREIGN KEY (visit_detail_parent_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.visit_detail ADD CONSTRAINT fpd_v_detail_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_concept FOREIGN KEY (procedure_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_type_concept FOREIGN KEY (procedure_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_modifier FOREIGN KEY (modifier_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.procedure_occurrence ADD CONSTRAINT fpk_procedure_concept_s FOREIGN KEY (procedure_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_concept FOREIGN KEY (drug_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_type_concept FOREIGN KEY (drug_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_route_concept FOREIGN KEY (route_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.drug_exposure ADD CONSTRAINT fpk_drug_concept_s FOREIGN KEY (drug_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.device_exposure ADD CONSTRAINT fpk_device_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.device_exposure ADD CONSTRAINT fpk_device_concept FOREIGN KEY (device_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.device_exposure ADD CONSTRAINT fpk_device_type_concept FOREIGN KEY (device_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.device_exposure ADD CONSTRAINT fpk_device_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.device_exposure ADD CONSTRAINT fpk_device_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.device_exposure ADD CONSTRAINT fpk_device_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.device_exposure ADD CONSTRAINT fpk_device_concept_s FOREIGN KEY (device_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_concept FOREIGN KEY (condition_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_type_concept FOREIGN KEY (condition_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_status_concept FOREIGN KEY (condition_status_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.condition_occurrence ADD CONSTRAINT fpk_condition_concept_s FOREIGN KEY (condition_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_concept FOREIGN KEY (measurement_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_type_concept FOREIGN KEY (measurement_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_operator FOREIGN KEY (operator_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_value FOREIGN KEY (value_as_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_unit FOREIGN KEY (unit_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.measurement ADD CONSTRAINT fpk_measurement_concept_s FOREIGN KEY (measurement_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_note_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_note_type_concept FOREIGN KEY (note_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_note_class_concept FOREIGN KEY (note_class_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_note_encoding_concept FOREIGN KEY (encoding_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_language_concept FOREIGN KEY (language_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_note_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_note_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.note ADD CONSTRAINT fpk_note_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.note_nlp ADD CONSTRAINT fpk_note_nlp_note FOREIGN KEY (note_id) REFERENCES cdm.note (note_id);
ALTER TABLE cdm.note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept FOREIGN KEY (section_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.note_nlp ADD CONSTRAINT fpk_note_nlp_concept_s FOREIGN KEY (note_nlp_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_concept FOREIGN KEY (observation_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_type_concept FOREIGN KEY (observation_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_value FOREIGN KEY (value_as_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_qualifier FOREIGN KEY (qualifier_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_unit FOREIGN KEY (unit_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit_occurrence (visit_occurrence_id);
ALTER TABLE cdm.observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES cdm.provider (provider_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES cdm.visit (visit_occurrence_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES cdm.visit_detail (visit_detail_id);
ALTER TABLE cdm.survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES cdm.visit (visit_occurrence_id);
ALTER TABLE cdm.fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.fact_relationship ADD CONSTRAINT fpk_fact_domain_2 FOREIGN KEY (domain_concept_id_2) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.fact_relationship ADD CONSTRAINT fpk_fact_relationship FOREIGN KEY (relationship_concept_id) REFERENCES cdm.concept (concept_id);
/************************
Standardized health system data
************************/
ALTER TABLE cdm.location_history ADD CONSTRAINT fpk_location_history FOREIGN KEY ( location_id ) REFERENCES cdm.location ( location_id );
ALTER TABLE cdm.location_history ADD CONSTRAINT fpk_relationship_type FOREIGN KEY (relationship_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.care_site ADD CONSTRAINT fpk_care_site_place FOREIGN KEY (place_of_service_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.care_site ADD CONSTRAINT fpk_care_site_location FOREIGN KEY (location_id) REFERENCES cdm.location (location_id);
ALTER TABLE cdm.provider ADD CONSTRAINT fpk_provider_specialty FOREIGN KEY (specialty_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.provider ADD CONSTRAINT fpk_provider_care_site FOREIGN KEY (care_site_id) REFERENCES cdm.care_site (care_site_id);
ALTER TABLE cdm.provider ADD CONSTRAINT fpk_provider_gender FOREIGN KEY (gender_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.provider ADD CONSTRAINT fpk_provider_specialty_s FOREIGN KEY (specialty_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.provider ADD CONSTRAINT fpk_provider_gender_s FOREIGN KEY (gender_source_concept_id) REFERENCES cdm.concept (concept_id);
/************************
Standardized health economics
************************/
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_contract_person FOREIGN KEY (contract_person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_payer_concept FOREIGN KEY (payer_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_plan_concept_id FOREIGN KEY (plan_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_contract_concept FOREIGN KEY (contract_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_sponsor_concept FOREIGN KEY (sponsor_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_stop_reason_concept FOREIGN KEY (stop_reason_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_payer_s FOREIGN KEY (payer_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_plan_s FOREIGN KEY (plan_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_contract_s FOREIGN KEY (contract_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_sponsor_s FOREIGN KEY (sponsor_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.payer_plan_period ADD CONSTRAINT fpk_stop_reason_s FOREIGN KEY (stop_reason_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_cost_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_cost_concept FOREIGN KEY (cost_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_cost_type FOREIGN KEY (cost_type_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_revenue_concept FOREIGN KEY (revenue_code_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_drg_concept FOREIGN KEY (drg_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_cost_s FOREIGN KEY (cost_source_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.cost ADD CONSTRAINT fpk_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES cdm.payer_plan_period (payer_plan_period_id);
/************************
Standardized derived elements
************************/
ALTER TABLE cdm.drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.dose_era ADD CONSTRAINT fpk_dose_era_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.dose_era ADD CONSTRAINT fpk_dose_era_concept FOREIGN KEY (drug_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.dose_era ADD CONSTRAINT fpk_dose_era_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES cdm.concept (concept_id);
ALTER TABLE cdm.condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (person_id) REFERENCES cdm.person (person_id);
ALTER TABLE cdm.condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES cdm.concept (concept_id);
|
CREATE Procedure Sp_Ser_LoadJobInfo(@JobId nvarchar(50))
as
select jobid,taskmaster.taskid,[Description] from job_tasks,taskmaster
where job_tasks.jobid = @jobId
and taskmaster.taskid = job_tasks.taskid
|
ALTER TABLE parking_lot ADD COLUMN hour_rate double precision NOT NULL DEFAULT 0.0;
ALTER TABLE parking_lot ADD COLUMN distance double precision NOT NULL DEFAULT 0.0;
ALTER TABLE parking_lot ADD COLUMN rating double precision NOT NULL DEFAULT 0.0; |
CREATE TABLE `wechat_sys_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`telephone` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`remark` varchar(255) DEFAULT NULL,
`state` int(255) DEFAULT NULL,
`operator` varchar(255) DEFAULT NULL,
`operator_time` datetime DEFAULT NULL,
`operator_ip` varchar(255) DEFAULT NULL,
`dept_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
INSERT INTO `demo`.`wechat_sys_user` (`id`, `username`, `password`, `telephone`, `email`, `remark`, `state`, `operator`, `operator_time`, `operator_ip`, `dept_id`) VALUES ('2', 'admins', '123456', '12345678912', '9632587@qq.com', NULL, '0', '', '2019-05-27 14:22:26', '1', '1');
CREATE TABLE `spring_cloud_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`balance` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
INSERT INTO `demo`.`spring_cloud_user` (`id`, `username`, `name`, `age`, `balance`) VALUES ('1', 'user1', '张三', '20', '100');
INSERT INTO `demo`.`spring_cloud_user` (`id`, `username`, `name`, `age`, `balance`) VALUES ('2', 'user2', '李四', '20', '100');
INSERT INTO `demo`.`spring_cloud_user` (`id`, `username`, `name`, `age`, `balance`) VALUES ('3', 'user3', '王五', '20', '100');
INSERT INTO `demo`.`spring_cloud_user` (`id`, `username`, `name`, `age`, `balance`) VALUES ('4', 'user4', '马六', '20', '100');
CREATE TABLE `blog_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
|
create database if not exists loja;
use loja;
create table tb_produto(
idProduto integer not null primary key,
nome_Prod varchar(80) not null,
preco decimal(6,2) not null,
idCategoria integer,
constraint idCategoriaFK foreign key (idCategoria) references tb_categoria (idCategoria)
);
create table tb_categoria(
idCategoria integer not null primary key,
nome varchar(65) not null,
qtd_Produto double not null
);
create table tb_cliente(
idCliente integer not null primary key,
nome_Cliente varchar(80) not null,
cpf varchar(12)
);
create table tb_compra(
idCompra integer not null primary key,
idProduto integer,
idCliente integer,
constraint idProdutoPFK foreign key (idProduto) references tb_produto (idProduto),
constraint idClientePFK foreign key (idCliente) references tb_cliente (idCliente),
qtd_Produto double not null,
valor_Parcial double not null,
_Data varchar(10) not null,
Hora varchar(5) not null,
);
|
CREATE PROCEDURE [actual].[pDel_cmn_location]
AS
TRUNCATE TABLE [actual].[cmn_location] |
CREATE DATABASE cakebrowser;
CREATE TABLE `cakebrowser`.`usuarios` ( `codigo` INT NOT NULL AUTO_INCREMENT, `correo` VARCHAR(50) NOT NULL , `contraseņa` VARCHAR(32) NOT NULL , PRIMARY KEY (`codigo`)) ENGINE = InnoDB;
|
SELECT
c.`id` AS id,
c.`started` AS started,
c.`stopped` AS stopped,
c.`user` AS user,
b.`username` AS username,
b.`password` AS password,
cc.`uuid` AS clientUuid,
cc.`name` AS clientName,
cc.`user` AS clientUser,
cc.`open` AS clientOpen,
b.`uri` AS brokerUri,
b.`name` AS brokerName,
b.`user` AS brokerUser
FROM `connects` c
INNER JOIN `clients` cc ON cc.`uuid` = c.`client`
INNER JOIN `shares` s ON s.`client` = cc.`uuid`
INNER JOIN `brokers` b ON b.`uri` = cc.`broker`
WHERE cc.`uuid` = ?
AND s.`control` = 1
AND s.`user` = c.`user`
AND b.`user` = c.`user`
AND c.`started` IS NOT NULL
AND c.`stopped` IS NULL; |
-- MySQL dump 10.13 Distrib 5.7.17, for Linux (x86_64)
--
-- Host: localhost Database: pricelist_db
-- ------------------------------------------------------
-- Server version 5.5.5-10.1.21-MariaDB
/*!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 `component`
--
DROP TABLE IF EXISTS `component`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `component` (
`code` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
`manufacturer` varchar(600) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`name` varchar(600) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`price` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`co_file_name` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`code`),
KEY `fk_component_1_idx` (`co_file_name`),
CONSTRAINT `fk_component_1` FOREIGN KEY (`co_file_name`) REFERENCES `file` (`fi_file_name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `component`
--
LOCK TABLES `component` WRITE;
/*!40000 ALTER TABLE `component` DISABLE KEYS */;
/*!40000 ALTER TABLE `component` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `field_mapping`
--
DROP TABLE IF EXISTS `field_mapping`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `field_mapping` (
`file_name` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
`manufacturer` varchar(300) COLLATE utf8mb4_unicode_ci NOT NULL,
`code` varchar(300) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(300) COLLATE utf8mb4_unicode_ci NOT NULL,
`price` varchar(300) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`file_name`),
CONSTRAINT `fk_field_mapping_1` FOREIGN KEY (`file_name`) REFERENCES `file` (`fi_file_name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `field_mapping`
--
LOCK TABLES `field_mapping` WRITE;
/*!40000 ALTER TABLE `field_mapping` DISABLE KEYS */;
/*!40000 ALTER TABLE `field_mapping` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `file`
--
DROP TABLE IF EXISTS `file`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `file` (
`fi_file_name` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`fi_file_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `file`
--
LOCK TABLES `file` WRITE;
/*!40000 ALTER TABLE `file` DISABLE KEYS */;
/*!40000 ALTER TABLE `file` 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 2017-03-19 19:44:33
|
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
`role` enum('BUYER','SELLER') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'BUYER',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `unit` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) unsigned DEFAULT NULL,
`name` text NOT NULL,
`price` decimal(15,2) unsigned NOT NULL,
`free` tinyint(1) NOT NULL DEFAULT '1',
`active` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
CREATE TABLE `reservation` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id_buyer` int(11) unsigned NOT NULL,
`user_id_seller` int(11) unsigned NOT NULL,
`unit_id` int(11) unsigned NOT NULL,
`price` decimal(15,2) unsigned NOT NULL,
`total` decimal(15,2) unsigned NOT NULL,
`start_from` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`end_at` datetime DEFAULT NULL,
`days` int(11) unsigned NOT NULL DEFAULT '1',
`status` enum('ACTIVE','CLOSED') NOT NULL DEFAULT 'ACTIVE',
`report_year` tinyint(1) unsigned NOT NULL,
`report_month` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
INSERT INTO `user` (`id`, `username`, `password`, `email`, `role`)
VALUES
(8, 'admin', '$2y$13$wHwEzm.iE7lUkqsk4G.qTe/W7uH/G2nTwmaOoZgjA0mM9En6n7V8S', 'admin@localhost', 'BUYER'),
(9, 'user', '$2y$13$UFQ8OsVx6FraLC8hdFhSq.L.S9Zaeu2/7895mgjEuehQqBw.vzX9e', 'user@localhost', 'BUYER');
INSERT INTO `unit` (`id`, `user_id`, `name`, `price`, `free`, `active`)
VALUES
(26, 8, 'Unit #1', 1.00, 0, 1),
(27, 8, 'Unit Two', 2.00, 0, 1),
(28, 8, 'Unit Three', 3.00, 0, 1),
(29, 8, 'Unit Four', 4.00, 0, 1),
(30, 8, 'Unit Five', 5.00, 1, 1),
(31, 9, 'Unit from User #1', 2.00, 1, 1),
(32, 9, 'Unit from User #2', 3.00, 1, 1);
INSERT INTO `reservation` (`id`, `user_id_buyer`, `user_id_seller`, `unit_id`, `price`, `total`, `start_from`, `end_at`, `days`, `status`, `report_year`, `report_month`)
VALUES
(24, 8, 8, 26, 1.00, 5.00, '2017-05-18 14:26:07', '2017-05-23 14:26:07', 5, 'ACTIVE', 17, 5),
(25, 8, 8, 27, 2.00, 4.00, '2017-05-18 14:38:20', '2017-05-20 14:38:20', 2, 'ACTIVE', 17, 5),
(26, 9, 8, 29, 4.00, 8.00, '2017-05-18 14:39:03', '2017-05-20 14:39:03', 2, 'ACTIVE', 17, 5),
(27, 9, 8, 28, 3.00, 12.00, '2017-05-18 14:39:14', '2017-05-22 14:39:14', 4, 'ACTIVE', 17, 5),
(28, 8, 8, 26, 1.00, 5.00, '2017-04-18 14:26:07', '2017-04-23 14:26:07', 5, 'CLOSED', 17, 4),
(29, 8, 8, 27, 2.00, 4.00, '2017-04-18 14:38:20', '2017-04-20 14:38:20', 2, 'CLOSED', 17, 4),
(30, 9, 8, 29, 4.00, 8.00, '2017-04-18 14:39:03', '2017-04-20 14:39:03', 2, 'CLOSED', 17, 4),
(31, 9, 8, 28, 3.00, 12.00, '2017-04-18 14:39:14', '2017-04-22 14:39:14', 4, 'CLOSED', 17, 4),
(32, 8, 8, 26, 1.00, 5.00, '2017-04-23 14:27:00', '2017-04-23 14:27:00', 5, 'CLOSED', 17, 4);
|
select
"userId"
, case when "playerPosition" > 300 THEN 'READ' ELSE 'SKIP' END as rs
, case when M1.title is not null then 'SERIE' else 'FILM' end as type
, case when M1.title is not null then M1._id else M2._id end as id
, case when M1.title is not null then "Episodes"."episodeNumber" else 0 end as ep
, case when M1.title is not null then 'Serie: ' || M1.title || ' S' || "Seasons"."seasonNumber" || 'E' || "Episodes"."episodeNumber" else 'Film: ' || M2.title end as title
from "UsersVideos"
INNER JOIN (
select
BU.user_reference_uuid,
CASE WHEN BS.sub_expires_date is null AND BS.sub_canceled_date is null THEN 'ACTIVE'
WHEN BS.sub_expires_date is null AND BS.sub_canceled_date is not null THEN 'FUTUR CANCELED'
WHEN BS.sub_expires_date is not null AND BS.sub_canceled_date is not null THEN
CASE WHEN BS.sub_expires_date = BS.sub_canceled_date THEN 'ERROR'
WHEN BS.sub_canceled_date IS NULL AND BPR._id <> 14 THEN 'EXPIRED'
WHEN BS.sub_expires_date <> BS.sub_canceled_date OR (BPR._id = 14 AND BS.sub_canceled_date IS NULL) THEN 'CANCELED'
ELSE 'unknown (2)'
END
ELSE 'unknown (1)'
END as "status",
date_part('day', BS.sub_expires_date - BS.sub_activated_date) as "aboDuration",
date_part('day', BS.sub_canceled_date - BS.sub_activated_date) as "aboDaysBeforeCancel",
BS.sub_activated_date,
BS.sub_canceled_date
FROM "Vue_billing_subscriptions" BS
INNER JOIN "Vue_billing_users" BU on (BS.userid = BU._id)
INNER JOIN "Vue_billing_providers" BPR ON (BS.providerid = BPR._id)
INNER JOIN "Vue_billing_plans" BP on (BS.planid = BP._id)
INNER JOIN "Vue_billing_internal_plans" BIP on (BIP._id = BP.internal_plan_id)
INNER JOIN (
SELECT DISTINCT ON (subid) subid, _id, amount_in_cents
FROM "Vue_billing_transactions"
WHERE transaction_type = 'purchase' AND transaction_status = 'success'
ORDER BY subid, _id ASC
) as BT ON BT.subid = BS._id
WHERE BS.deleted = false AND BU.deleted = false
-- on ne veut que les CANCELED ou FUTUR CANCELED
AND
( -- futur canceled
(BS.sub_expires_date is null AND BS.sub_canceled_date is not null)
-- actual canceled
OR (
BS.sub_expires_date is not null AND BS.sub_canceled_date is not null AND (BS.sub_expires_date <> BS.sub_canceled_date OR (BPR._id = 14 AND BS.sub_canceled_date IS NULL))
)
)
-- AND BIP._id IN (64,65,66,67)
AND BS.sub_activated_date > '2016-10-01 00:00:00'
ORDER BY "status", date (BS.sub_activated_date AT TIME ZONE 'Europe/Paris') DESC
) as billing ON billing.user_reference_uuid::integer = "UsersVideos"."userId" AND billing.sub_activated_date <= "UsersVideos"."dateStartRead"
AND (billing.sub_canceled_date is null OR billing.sub_canceled_date >= "UsersVideos"."dateStartRead")
left join "Episodes" on "Episodes"."videoId" = "UsersVideos"."videoId"
left join "Seasons" on "Seasons"."_id" = "Episodes"."seasonId"
left join "Movies" M1 on M1."_id" = "Seasons"."movieId"
left join "Movies" M2 on M2."videoId" = "UsersVideos"."videoId"
WHERE
(billing.status = 'ACTIVE' OR billing.status='CANCELED' OR billing.status='FUTUR CANCELED')
ORDER BY "userId", "dateStartRead"
|
prompt TABLE PARTITION HISTORGRAMS for table_name = '&1' and column_name = '&2'
select * from DBA_PART_HISTOGRAMS
where table_name = upper('&1') and column_name=upper('&2')
order by partition_name, bucket_number;
|
create table covidSurvey(
id varchar,
regionOfResidence varchar,
ageOfSubject INT,
timeSpentOnOnlineClass numeric,
ratingOfOnlineClassExperience varchar,
mediumForOnlineClass varchar,
timeSpentOnSelfStudy numeric,
timeSpentOnFitness numeric,
timeSpentOnSleep numeric,
timeSpentOnSocialMedia numeric,
preferredSocialMediaPlatform varchar,
timeSpentOnTv numeric,
numberOfMealsPerDay INT,
changeInWeight varchar,
healthIssueDuringLockdown BOOLEAN,
stressBusters varchar,
timeUtilized BOOLEAN,
moreConnectionWithFamilyCloseFriendsOrRelatives BOOLEAN,
missTheMost varchar
);
\copy covidSurvey (id,regionOfResidence,ageOfSubject,timeSpentOnOnlineClass,ratingOfOnlineClassExperience,mediumForOnlineClass,timeSpentOnSelfStudy,timeSpentOnFitness,timeSpentOnSleep,timeSpentOnSocialMedia,preferredSocialMediaPlatform,timeSpentOnTv,numberOfMealsPerDay,changeInWeight,healthIssueDuringLockdown,stressBusters,timeUtilized,moreConnectionWithFamilyCloseFriendsOrRelatives,missTheMost) FROM '*insert spreadsheet path here*' DELIMITER ',' CSV HEADER
select * from covidSurvey;
--Q1: How do the time spent on fitness and the number of meals per day affect the weight of the interviewee?
--During the pandemic, if the student eats more meals but does less exercise, and his/her weight is increasing, then this shows that the time spent on fitness and the number of meals per day will affect people’s weight.
--During the pandemic, if the student eats fewer meals but does more exercise, and his/her weight is decreasing, then this shows that the time spent on fitness and the number of meals per day will affect people’s weight.
--Otherwise, other answers show that the time spent on fitness and the number of meals per day will NOT affect people’s weight.
SELECT id, timeSpentOnFitness, numberOfMealsPerDay, changeInWeight,
CASE
WHEN timeSpentOnFitness < numberOfMealsPerDay AND changeInWeight = 'Increased' THEN 'YES'
WHEN timeSpentOnFitness > numberOfMealsPerDay AND changeInWeight = 'Decreased' THEN 'YES'
ELSE 'NO'
END AS Do_Fitness_Time_And_Number_Of_Meals_Affect_The_Weight
FROM covidSurvey;
--Q2: What is the ratio of the time spending on social media and TV to online classes and self-study for each interviewee?
--If the answer is less than 1, this means that the student is more hard-working.
--In contrast, if the answer is more than 1, this means that the student spends more time on leisure activities.
SELECT id, timeSpentOnSocialMedia, timeSpentOnTv, timeSpentOnOnlineClass, timeSpentOnSelfStudy, round(((timeSpentOnSocialMedia + timeSpentOnTv) / NULLIF((timeSpentOnOnlineClass + timeSpentOnSelfStudy), 0)), 2) as Ratio FROM covidSurvey;
--Q3: How does the health issue relate to each interviewee finding themselves more connected with their family, close friends, and relatives?
--If “Health issue during lockdown” = “Do you find yourself more connected with your family, close friends, and relatives”, this means that the connection with family, close friends, and relatives will affect the health of the student.
SELECT id, moreConnectionWithFamilyCloseFriendsOrRelatives, healthIssueDuringLockdown,
CASE
WHEN moreConnectionWithFamilyCloseFriendsOrRelatives = healthIssueDuringLockdown THEN 'YES'
ELSE 'NO'
END AS Does_The_Connection_With_Others_Affect_The_Health_Issue
FROM covidSurvey; |
-- create database
create role test_user login password 'test_password';
create database testdb;
grant all privileges on database testdb to test_user;
\c testdb
-- create schema
create schema test_schema;
alter schema test_schema owner to test_user;
-- create table
CREATE TABLE IF NOT EXISTS test_schema.user (
id SERIAL PRIMARY KEY,
todoist_id BIGINT NOT NULL,
point INTEGER DEFAULT 0,
UNIQUE(todoist_id)
);
alter table test_schema.user owner to test_user; |
create database paradam
default character set utf8 default collate utf8_unicode_ci;
create database paradam_test
default character set utf8 default collate utf8_unicode_ci; |
CREATE TABLE `userinfo`(
`id` int(11) not null auto_increment,
`user_id` varchar(20) not null,
`nickname` varchar(20) not null,
`password` varchar(40) not null,
`email` varchar(40) not null,
`phone_number` varchar(13),
`mobile_number` varchar(13) not null,
`comment` text,
`join_date` datetime not null,
primary key(id)
) engine = innodb default charset=utf8;
|
--Problem 18 RANK SELECT PLACE
SELECT DepartmentID, Salary
FROM (
SELECT DepartmentID,
Salary,
DENSE_RANK() over (partition by DepartmentID order by Salary DESC) [Rank]
FROM Employees) [k]
WHERE Rank = 3
GROUP BY DepartmentID, Salary
|
INSERT INTO `search_crawler`.`job_info`
(`job_id`,
`job_name`,
`job_desc`,
`create_time`,
`update_time`,
`appkey`,
`min_count`,
`latest_time`)
VALUES
(1,
'search_crawler',
'基于搜索引擎的爬虫',
'2018-04-19 20:04:49',
null,
666,
null,
null);
|
-- table data model info
select tab.schema_id, schema_name(tab.schema_id) as schema_name,
tab.name as table_name,
tab.create_date as created,
tab.modify_date as last_modified,
ep.value as comments
from sys.tables tab
left join sys.extended_properties ep
on tab.object_id = ep.major_id
and ep.name = 'MS_Description'
and ep.minor_id = 0
and ep.class_desc = 'OBJECT_OR_COLUMN'
WHERE 1=1
AND tab.name lIKE '%Employee%'
order by schema_name,
table_name
;
-- table size
WITH tab_rows_ AS (
select distinct p.object_id, sum(p.rows) rows
from sys.tables t
inner join sys.partitions p ON p.object_id = t.object_id
group by p.object_id, p.index_id
)
SELECT tab.name TableName
, schema_name(tab.schema_id) as schema_name
,ps.object_id ps_object_id
,object_name( ps.object_id) SegmentName
,ix.name IndexName
,CASE ps.index_id WHEN 0 THEN 'Table' WHEN 1 THEN 'ClustIx' ELSE 'otherIx' END AS SegmentType
,ps.index_id tab_index_id
,tab.create_date tableCreDate
,tr.rows table_rows
,ROUND(ps.used_page_count * 8 / 1024.0, 2) SegmentMbUsed
,ps.used_page_count SegmentPages
FROM sys.tables tab
LEFT JOIN tab_rows_ tr ON tr.object_id = tab.object_id
LEFT JOIN sys.dm_db_partition_stats ps ON ps.object_id = tab.object_id
LEFT JOIN sys.indexes ix ON ix.object_id = tab.object_id -- index does not have any object id. so object_id is always the table's object_id
WHERE 1=1
AND tab.name LIKE '%Internet%'
;
-- column information
SELECT c.object_id
,c.name column_name
,t.Name data_type
,c.max_length
,c.precision
,c.scale
,c.is_nullable nullible
,CASE
WHEN t.name LIKE '%varchar' THEN t.name + '(' + CONVERT( VARCHAR, c.max_length ) + ')'
WHEN t.name LIKE 'decimal' THEN t.name + '(' + CONVERT( VARCHAR, c.[precision] ) + ',' + CONVERT( VARCHAR, c.[scale] ) + ')'
ELSE t.name
END AS data_type_specs
,ISNULL(i.is_primary_key, 0) is_pk
FROM
sys.columns c
INNER JOIN
sys.types t ON c.user_type_id = t.user_type_id
LEFT OUTER JOIN
sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id--
LEFT OUTER JOIN
sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
WHERE c.object_id = object_id( 'dbo.emp')
;
SELECT ps.index_id tab_index_id, ps.*
FROM sys.tables tab
LEFT JOIN sys.dm_db_partition_stats ps ON ps.object_id = tab.object_id
WHERE 1=1
AND tab.name LIKE '%Product%'
;
-- who can do what
select prin.name grantee
, perm.grantor_principal_id grantor_id
, prin.principal_id grantee_id
, prin.type_desc grantee_type
, perm.permission_name
, prin.is_disabled
, prin.is_fixed_role
, perm.class_desc perm_class
FROM sys.server_permissions perm
JOIN sys.server_principals prin ON prin.principal_id = perm.grantee_principal_id
SELECT * FROM sys.dm_db_partition_stats ps WHERE object_id = object_id ( 'dbo.FactInternetSales')
SELECT * from sys.indexes
-- check if full text search feature installed
SELECT FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')
select object_name( object_id) object_name, * from sys.fulltext_indexes
;
-- find indexed (materialized) views
select schema_name(v.schema_id) as schema_name,
v.name as view_name,
i.name as index_name,
m.definition
from sys.views v
join sys.indexes i
on i.object_id = v.object_id
-- and i.index_id = 1
-- and i.ignore_dup_key = 0
join sys.sql_modules m
on m.object_id = v.object_id
WHERE 1=1
-- AND i.object_id = object_id( 'HumanResources.JobCandidate')
order by schema_name,
view_name; |
CREATE TABLE `tbl_user` (
`user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`password` varchar(60) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `unq_user` (`email`)
);
CREATE TABLE `tbl_screen` (
`screen_id` int(10) unsigned NOT NULL,
`screen` varchar(255) NOT NULL,
`seating_capacity` int(10) unsigned NOT NULL,
PRIMARY KEY (`screen_id`)
);
CREATE TABLE `tbl_film` (
`film_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`rt_id` int(10) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`year` year(4) NOT NULL,
`runtime` int(3) unsigned DEFAULT NULL,
`trailer` varchar(255) DEFAULT NULL,
PRIMARY KEY (`film_id`),
UNIQUE KEY `unq_rt` (`rt_id`)
);
CREATE TABLE `tbl_booking` (
`booking_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL,
`showing_id` int(10) unsigned NOT NULL,
`no_of_seats_booked` int(1) unsigned NOT NULL,
`total_price` decimal(5,2) unsigned NOT NULL,
PRIMARY KEY (`booking_id`)
);
CREATE TABLE `tbl_showing` (
`showing_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`film_id` int(10) unsigned NOT NULL,
`screen_id` int(10) unsigned NOT NULL,
`start_date` date NOT NULL,
`start_time` time NOT NULL,
`price_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`showing_id`)
);
CREATE TABLE `tbl_Price` (
`price_id` int unsigned NOT NULL AUTO_INCREMENT,
`price` decimal(10,2) unsigned NOT NULL,
PRIMARY KEY (`price_id`)
);
ALTER TABLE `tbl_Showing` ADD CONSTRAINT `fk_Showing_Screen_1` FOREIGN KEY (`screen_id`) REFERENCES `tbl_Screen` (`screen_id`);
ALTER TABLE `tbl_Showing` ADD CONSTRAINT `fk_Showing_Film_1` FOREIGN KEY (`film_id`) REFERENCES `tbl_Film` (`film_id`);
ALTER TABLE `tbl_Booking` ADD CONSTRAINT `fk_Booking_Showing_1` FOREIGN KEY (`showing_id`) REFERENCES `tbl_Showing` (`showing_id`);
ALTER TABLE `tbl_Booking` ADD CONSTRAINT `fk_Booking_User_1` FOREIGN KEY (`user_id`) REFERENCES `tbl_User` (`user_id`);
ALTER TABLE `tbl_Showing` ADD CONSTRAINT `fk_Showing_Price_1` FOREIGN KEY (`price_id`) REFERENCES `tbl_Price` (`price_id`);
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `tbl_user` VALUES ('1', 'admin', '$2a$07$196806248031830437075ulz5WDdky.VCck/0ZepPRK3Vkwv6i6Q2');
INSERT INTO `tbl_price` VALUES ('1', '5.25');
INSERT INTO `tbl_price` VALUES ('2', '7.50');
INSERT INTO `tbl_price` VALUES ('3', '6.10');
INSERT INTO `tbl_screen` VALUES ('1', 'One', '100');
INSERT INTO `tbl_screen` VALUES ('2', 'Two', '50');
INSERT INTO `tbl_screen` VALUES ('3', 'Three', '100');
INSERT INTO `tbl_screen` VALUES ('4', 'Four', '75');
INSERT INTO `tbl_screen` VALUES ('5', 'Five', '5');
INSERT INTO `tbl_film` VALUES ('1', '771190618', 'The Hunger Games', '2012', '142', 'qoUT7q2iTbQ');
INSERT INTO `tbl_film` VALUES ('2', '770863876', '21 Jump Street', '2012', '109', 'RLoKtb4c4W0');
INSERT INTO `tbl_film` VALUES ('3', '771229793', 'Mirror Mirror', '2012', '95', '8CHXHEIGb7A');
INSERT INTO `tbl_film` VALUES ('4', '770740154', 'Marvel\'s The Avengers', '2012', '142', 'eOrNdBpGMv8');
INSERT INTO `tbl_film` VALUES ('5', '771252912', 'The Best Exotic Marigold Hotel', '2012', '118', 'dDY89LYxK0w');
INSERT INTO `tbl_film` VALUES ('6', '771208374', 'Wrath of the Titans', '2012', '99', 'mQckuXV6DRA');
INSERT INTO `tbl_film` VALUES ('7', '770858174', 'Battleship', '2012', '131', 'sbx9dxcLsiQ');
INSERT INTO `tbl_film` VALUES ('8', '771240536', 'The Devil Inside', '2012', '83', 'ojTQp923rQw');
INSERT INTO `tbl_film` VALUES ('9', '771224339', 'Contraband', '2012', '109', 'Rp0b5ZXIUvE');
INSERT INTO `tbl_film` VALUES ('10', '771203062', 'We Bought a Zoo', '2011', '124', 'brbzw0ZJGlI');
INSERT INTO `tbl_film` VALUES ('11', '714976247', 'Iron Man', '2008', '126', '');
INSERT INTO `tbl_film` VALUES ('12', '770800493', 'Iron Man 2', '2010', '124', '');
INSERT INTO `tbl_film` VALUES ('13', '769959054', 'The Dark Knight', '2008', '152', '');
INSERT INTO `tbl_film` VALUES ('14', '770805418', 'Inception', '2010', '148', '');
INSERT INTO `tbl_film` VALUES ('15', '770863873', 'Mission: Impossible Ghost Protocol', '2011', '133', '');
INSERT INTO `tbl_film` VALUES ('16', '771041419', 'Men in Black III', '2012', '99', '');
INSERT INTO `tbl_film` VALUES ('17', '770672991', 'Harry Potter and the Deathly Hallows - Part 1', '2010', '146', '');
INSERT INTO `tbl_showing` VALUES ('1', '1', '1', '2012-04-27', '18:00:00', '1');
INSERT INTO `tbl_showing` VALUES ('2', '1', '5', '2012-04-27', '22:00:00', '2');
INSERT INTO `tbl_showing` VALUES ('3', '1', '1', '2012-04-28', '12:00:00', '1');
INSERT INTO `tbl_showing` VALUES ('4', '2', '5', '2012-04-29', '17:00:00', '3');
INSERT INTO `tbl_showing` VALUES ('5', '3', '2', '2012-06-27', '13:00:00', '3');
INSERT INTO `tbl_showing` VALUES ('6', '4', '2', '2012-06-26', '14:00:00', '1');
INSERT INTO `tbl_showing` VALUES ('7', '14', '1', '2012-04-19', '16:00:00', '2');
INSERT INTO `tbl_showing` VALUES ('8', '14', '1', '2012-04-30', '15:00:00', '1');
INSERT INTO `tbl_showing` VALUES ('9', '1', '3', '2012-06-18', '14:00:00', '3'); |
-- Update for 2015-05-13
-- > added new columns to task table
USE `baiken_fwm_1`;
ALTER TABLE `task`
ADD COLUMN `task_start_date` varchar(50) NULL,
ADD COLUMN `task_activated` tinyint(1) NOT NULL DEFAULT '0'; |
--PROBLEM 01
--Write a SQL query to find first and last names of all employees whose first name starts with “SA”.
SELECT
FirstName
,LastName
FROM Employees
WHERE FirstName LIKE 'SA%' |
create or replace view v_lymx2bno as
select distinct DE011,DE022,bc_public.getBnoByLymx(DE011, DE022, CZDE951) as bno
from (select distinct DE011, DE022, czde951
from jh001
where jsde940 = '80'
and nvl(jsde202, -1) = -1);
|
CREATE DATABASE IF NOT EXISTS stocks;
use stocks;
# Reset the Database
SET foreign_key_checks =0;
DROP TABLE IF EXISTS securities;
DROP TABLE IF EXISTS prices;
DROP TABLE IF EXISTS prices_split;
DROP TABLE IF EXISTS fillings;
DROP TABLE IF EXISTS fundamentals;
SET foreign_key_checks =1;
# Create tables
# Data gathered from https://www.kaggle.com/dgawlik/nyse
# general description of each company with division on sectors
CREATE TABLE securities
(
symbol VARCHAR(5) PRIMARY KEY,
Security VARCHAR(20) NOT NULL,
SEC_filings CHAR(7) NOT NULL,
GICS_Sector VARCHAR(20) NOT NULL,
GICS_Sub_Industry VARCHAR(30) NOT NULL,
Address VARCHAR(25) NOT NULL,
Date_first_added DATE,
CIK INT NOT NULL
);
# raw, as_is daily prices. Most of data spans from 2010 to the end 2016,
# for companies new on stock market date range is shorter. There have
# been approx. 140 stock splits in that time, this set doesn't account for that.
CREATE TABLE prices
(
date DATE NOT NULL,
symbol VARCHAR(5) NOT NULL,
open DECIMAL(10,6) NOT NULL,
close DECIMAL(10,6) NOT NULL,
low DECIMAL(10,6) NOT NULL,
high DECIMAL(10,6) NOT NULL,
volume INT,
CONSTRAINT FOREIGN KEY (symbol) REFERENCES securities(symbol)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT PRIMARY KEY (date, symbol)
);
# same as prices, but there have been added adjustments for splits.
CREATE TABLE prices_split
(
date DATE NOT NULL,
symbol VARCHAR(5) NOT NULL,
open DECIMAL(10,6) NOT NULL,
close DECIMAL(10,6) NOT NULL,
low DECIMAL(10,6) NOT NULL,
high DECIMAL(10,6) NOT NULL,
volume INT,
CONSTRAINT FOREIGN KEY (symbol) REFERENCES securities (symbol)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT PRIMARY KEY (date, symbol)
);
# SEC 10K annual fillings (2016_2012)
CREATE TABLE fundamentals (
ID INT PRIMARY KEY,
Symbol VARCHAR(5) NOT NULL,
Period_Ending DATE NOT NULL,
Accounts_Payable BIGINT NOT NULL,
Accounts_Receivable BIGINT NOT NULL,
Add_income_expenses BIGINT NOT NULL,
After_Tax_ROE SMALLINT NOT NULL,
Capital_Expenditures BIGINT NOT NULL,
Capital_Surplus BIGINT NOT NULL,
Cash_Ratio SMALLINT NOT NULL,
CC_Equivalents BIGINT NOT NULL,
Changes_in_Inventories BIGINT NOT NULL,
Common_Stocks BIGINT NOT NULL,
Cost_of_Revenue BIGINT NOT NULL,
Current_Ratio SMALLINT,
Deferred_Asset_Charges BIGINT NOT NULL,
Deferred_Liability_Charges BIGINT NOT NULL,
Depreciation BIGINT NOT NULL,
Earnings_Before_Interest_and_Tax BIGINT NOT NULL,
Earnings_Before_Tax INT NOT NULL,
Effect_of_Exchange_Rate BIGINT NOT NULL,
Equity_Earnings_Loss_Unconsolidated_Subsidiary BIGINT NOT NULL,
Fixed_Assets BIGINT NOT NULL,
Goodwill BIGINT NOT NULL,
Gross_Margin TINYINT NOT NULL,
Gross_Profit BIGINT NOT NULL,
Income_Tax BIGINT NOT NULL,
Intangible_Assets BIGINT NOT NULL,
Interest_Expense BIGINT NOT NULL,
Inventory BIGINT NOT NULL,
Investments BIGINT NOT NULL,
Liabilities BIGINT NOT NULL,
Long_Term_Debt BIGINT NOT NULL,
Long_Term_Investments BIGINT NOT NULL,
Minority_Interest BIGINT NOT NULL,
Misc_Stocks BIGINT NOT NULL,
Net_Borrowings BIGINT NOT NULL,
Net_Cash_Flow BIGINT NOT NULL,
Net_Cash_Flow_Operating BIGINT NOT NULL,
Net_Cash_Flows_Financing BIGINT NOT NULL,
Net_Cash_Flows_Investing BIGINT NOT NULL,
Net_Income BIGINT NOT NULL,
Net_Income_Adjustments BIGINT NOT NULL,
Net_Income_Applicable_to_Common_Shareholders BIGINT NOT NULL,
Net_Income_Cont_Operations BIGINT NOT NULL,
Net_Receivables BIGINT NOT NULL,
Non_Recurring_Items BIGINT NOT NULL,
Operating_Income BIGINT NOT NULL,
Operating_Margin SMALLINT NOT NULL,
Other_Assets BIGINT NOT NULL,
Other_Current_Assets BIGINT NOT NULL,
Other_Current_Liabilities BIGINT NOT NULL,
Other_Equity BIGINT NOT NULL,
Other_Financing_Activities BIGINT NOT NULL,
Other_Investing_Activities BIGINT NOT NULL,
Other_Liabilities BIGINT NOT NULL,
Other_Operating_Activities BIGINT NOT NULL,
Other_Operating_Items BIGINT NOT NULL,
PreTax_Margin SMALLINT NOT NULL,
PressTax_ROE SMALLINT NOT NULL,
Profit_Margin SMALLINT NOT NULL,
Quick_Ratio SMALLINT,
Research_and_Development BIGINT NOT NULL,
Retained_Earnings BIGINT NOT NULL,
Sale_and_Purchase_of_Stock BIGINT NOT NULL,
Sales_General_and_Admin BIGINT NOT NULL,
STD_Current_Portion_of_Long_Term_Debt BIGINT NOT NULL,
Short_Term_Investments BIGINT NOT NULL,
Total_Assets BIGINT NOT NULL,
Total_Current_Assets BIGINT NOT NULL,
Total_Current_Liabilities BIGINT NOT NULL,
Total_Equity BIGINT NOT NULL,
Total_Liabilities BIGINT NOT NULL,
Total_Liabilities_Equity BIGINT NOT NULL,
Total_Revenue BIGINT NOT NULL,
Treasury_Stock TINYINT NOT NULL,
For_Year SMALLINT,
Earnings_Per_Share TINYINT,
Estimated_Shares_Outstanding BIGINT,
CONSTRAINT FOREIGN KEY(symbol) REFERENCES securities(symbol)
ON DELETE CASCADE
ON UPDATE CASCADE
);
|
CREATE VIEW [TimeManagement].[VI_UserAssignment]
AS SELECT [TimeManagement].[UserAssignment].[PK_Id],
[FK_UserId],
[FK_ProjectId],
[NK_Name] as [UserName],
[Users].[NK_ZId],
[Projects].[Name] as [ProjectName],
[FK_OrderNumber],
[Number],
[Title]
FROM [TimeManagement].[UserAssignment]
JOIN
[TimeManagement].[Users] on [UserAssignment].[FK_UserId] = [Users].[PK_Id]
JOIN
[TimeManagement].[Projects] on [UserAssignment].[FK_ProjectId] = [Projects].[PK_Id]
JOIN
[TimeManagement].[OrderNumber] on [FK_OrderNumber] = [OrderNumber].[PK_Id]
--Needs different joins with the correct tables |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.