数据库SQL语句的使用
这篇文章主要讲解了“数据库SQL语句的使用”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“数据库SQL语句的使用”吧!
1、创建数据库createdatabaseifnotexistscs2013;2、创建数据库表格createtableifnotexistscomp(idintnotnullprimarykeyauto_increment,pidvarchar(30)notnullunique,cnamevarchar(30)notnull,enamevarchar(30)notnull,gradevarchar(30)notnull,sexintnotnull,clothevarchar(15)notnull)defaultcharset=utf8;createtableifnotexiststeam(idintnotnullprimarykeyauto_increment,cnamevarchar(30)notnull,enamevarchar(30)notnull,coach0intnotnull,coach2intnotnull,stu0intnotnull,stu1intnotnull,stu2intnotnull,isgirlsintnotnull,emailvarchar(30)notnull,phonevarchar(15)notnull,foreignkey(coach0)referencescomp(id),foreignkey(coach2)referencescomp(id),foreignkey(stu0)referencescomp(id),foreignkey(stu1)referencescomp(id),foreignkey(stu2)referencescomp(id))defaultcharset=utf8;createtableifnotexistscollege(idintnotnullprimarykeyauto_increment,cnamevarchar(30)notnull,enamevarchar(30)notnull,teamcntintnotnull)defaultcharset=utf8;createtableifnotexistsrc(idintnotnullprimarykeyauto_increment,collegeintnotnull,teamintnotnull,datedatenotnull,foreignkey(college)referencescollege(id),foreignkey(team)referencesteam(id))defaultcharset=utf8;createtableifnotexistsroom(idintnotnullprimarykeyauto_increment,namevarchar(30)notnull,totcntintnotnull,regcntintnotnull,pricedoublenotnull)defaultcharset=utf8;createtableifnotexistshotel(idintnotnullprimarykeyauto_increment,namevarchar(30)notnull,room0intnotnull,room1intnotnull,room2intnotnull,foreignkey(room0)referencesroom(id),foreignkey(room1)referencesroom(id),foreignkey(room2)referencesroom(id))defaultcharset=utf8;createtableifnotexistsrh(idintnotnullprimarykeyauto_increment,collegeintnotnull,hotelintnotnull,datedatenotnull,foreignkey(college)referencescollege(id),foreignkey(hotel)referenceshotel(id))defaultcharset=utf8;
感谢各位的阅读,以上就是“数据库SQL语句的使用”的内容了,经过本文的学习后,相信大家对数据库SQL语句的使用这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。