-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestSQL.sql
More file actions
53 lines (39 loc) · 1.37 KB
/
testSQL.sql
File metadata and controls
53 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use ad_e6d8eb1c641e824;
show tables;
create table error_tracker(error_id int auto_increment primary key,
uname varchar(100) not null,
message varchar(500) not null,
time_stamp datetime);
desc error_tracker;
desc stockvalue;
desc user;
desc utransaction;
desc message;
desc company;
select * from message;
select * from stockvalue;
insert into stockvalue values('IBM', 125, '2016-06-20 12 :34:09 AM');
select stime, price from stockvalue where company ='IBM' order by stime desc;
select * from utransaction;
insert into utransaction values('priyanjitcareer@gmail.com', 'testadmin@gmail.com', '2016-07-08 17:41:07', 'Facebook', 1,
5, 220);
insert into utransaction values('priyanjitcareer@gmail.com', 'testadmin@gmail.com', '2016-07-08 17:41:07', 'IBM', 1,
5, 220);
insert into utransaction values('priyanjitcareer@gmail.com', 'testadmin@gmail.com', '2016-07-08 17:41:07', 'Google', 1,
5, 260);
select t.company, s.stime, s.price price from stockvalue s
inner join utransaction t where s.company = t.company
and uemail = 'priyanjitcareer@gmail.com';
select * from error_tracker;
DELIMITER $$
create trigger `cash_check` before update on user
for each row
begin
declare msg varchar(128);
if new.cash<0 then
set msg=concat("Negative cash balance not allowed.");
signal sqlstate '45000' set message_text=msg;
end if;
end;
$$
show grants;