《MySQL数据库程序设计》课后编程题
第三章
1. create database db_test;
2.create tablecontent(content_idint not null auto_increment primary key,subjectvarchar(200),words varchar(1000))…
第四章
1. insert into db_test.content(content_id,subject,words) values(null,’MySQL问题请教’,’MySQL中对表数据的基本操作有哪些’);
2. update db_test.content set words=’如何使用insert语句’where username=’MySQL 初学者’;
3. delete from db_test.content where username=’MySQL初学者’;
第五章
Use db_test;
Select * from content where username=’MySQL初学者’;
第六章
Use db_test;
Create index index_subject on content(subject(3) asc);
第七章
Use db_test;
Create view content_view as select * from content where username=’MySQL初学者’with check option;
第九章
Use db_test;
Create trigger content_delete_trigger after delete on content for each row set @str=’old content deleted!’;
第十章
Use db_test;
Delimiter //
Create event event_content on schedule every 1 month
Starts curdate()+interval 1 month
Ends ’2013-12-31’
Do
Begin
If year(curdate())<2013 then
Delete from content where username=’MySQL初学者’;
End if;
End;
//
第十一章
Use db_test;
Delimiter //
Create procedure proce_content(in user_namevarchar(50),inuser_email
varchar(50))
Begin
Update content set email=e_mail where username=user_name;
End;
//
Select distinct prod_id,prod_name from products limit 4,5;
第十四章
$con=mysql_connect(“localhost:3306”,“root”,“123456”) or die(“数据库服务器连接失败!
”);
Mysql_select_db(“db_test”,$con) or die(“数据库选择失败!
”);
Mysql_query(“set names ’gbk’”);
$sql=“insert into content(content_id,subject,words,username)”;
$sql=$sql.“values(null,’MySQL问题请教’,“MySQL中对表数据的基本操作有哪些?”,“MySQL初学者”)”;
If(mysql_query($sql,$con))
echo “留言信息添加成功!
”;
else
echo “留言信息添加失败!
”;
?>