1) Read this program carefully. What does this program print? What's in the first column, the second column, the third column, etc.?
#!/usr/bin/perl2) Suppose the database daemon for MySQL was not running when this program ran? What line would fail?
my($name, $age);
use DBI;
$dbh = DBI->connect("DBI:mysql:fred", "tom", "steve");
$dbh->do("select name from people where age > 100 order by age");
$sth = $dbh->prepare("select age, name from people where name > 'z' order by name");
$sth->execute();
$sth->bind_columns(undef, \$name, \$age);
while ($sth->fetch) {
print "$name $age\n";
}
$dbh->disconnect;
3) Which of these is the slowest DBI call for the types of queries run in class?
The sth->prepare4) (Yes/no) Is there a DBI for C++? I'm not asking if there is SOME interface to the database via C++, but one named DBI with calls like connect, execute, etc.
The sth->execute
The sth->fetch
The dbh->connect
5) Suppose you want to delete a table and all the data in contains. It's not an already empty table. Write me a DBI/Perl program to do this.
6) Which of these statements are suitable for dbh->do? Circle all that apply
select * from people7) (True/false) Suppose VISA runs a transaction on their database. At the same time VISA runs a second transaction. There is NO WAY that the second transaction is effected by the first, assuming that both transactions run correctly, the database is working properly, etc.
create table people(name char(30) not null, age int)
insert into people values ("dan", 20)
8) Suppose table 1 has 1000 rows and 8 columns, Ten of the rows have name = 'fred'. Table 2 has 500 rows and 6 entries with age =7. How many answer rows does this querry generate?
Remove $100 from your account
Add $100 to my accountSum = 0
Sum = Sum + Your_Account_Balance
Sum = Sum + My_Account_Balance
select * from tabel1 A, table2, table1 B where age = 7 and A.name = 'fred';