版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、数据库原理及应用电子实验报告题 目:SQL语言 数据定义日期姓 名实验环境: Windows 7,Sql Server2005实验目的:1 熟悉Sql Server2005环境2 掌握基本表的定义、删除和修改3 掌握索引的建立和删除实验内容:1. Sql Server2005的启动 Sql Server2005的启动方法:单击“开始”按钮“所用程序” “Microsoft SOL Server 2005” “SQL Server Management Studio”。之后将会出现如图1所示的“连接到服务器”的窗口。 安装时将 Sql Server2005 的快捷图标放到桌面或锁定到任务栏打开S
2、ql Server2005界面(如下图)单击连接,进入界面(如下图)点击新建查询,进入空白页面,编写程序。2. 定义基本表的语句格式1)create语句SQL 语言使用CREATE TABLE语句定义基本表,其基本格式如下:CREATE TABLE ( , , ); :所要定义的基本表的名字 :组成该表的各个属性(列) :涉及相应属性列的完整性约束条件 :涉及一个或多个属性列的完整性约束条件 2)drop语句当某个基本表不再需要时,可以使用DROP TABLE语句删除它。其一般格式为:DROP TABLE RESTRICT | CASCADE; 基本表删除后:数据、表上的索引都删除 表上的视图
3、往往仍然保留,但无法引用 删除基本表时,系统会从数据字典中删去有关该基本表及其索引的描述。用DROP做删除操作时,是把整个表都删了,而用delete做删除操作时,是清空列表,使其为一个空表3)alter语句SQL语言用ALTER TABLE语句修改基本表,其一般格式为: ALTER TABLE ADD 完整性约束 DROP MODIFY ; :要修改的基本表 ADD子句:增加新列和新的完整性约束条件 DROP子句:删除指定的完整性约束条件 MODIFY子句:用于修改列名和数据类型3.基本表的定义、删除和修改1)基本表的定义(写出题目、sql语句,阐述有哪些常用完整性约束,辨析primary 可
4、以 和unique的区别)【实例1】建立一个学生表代码如下:CREATE TABLE Student (Sno CHAR(9)PRIMARY KEY,Sname CHAR(20)UNIQUE,Ssex CHAR (2),Sage SMALLINT,Sdept CHAR(20); 执行结果如下图所示:【实例2】建立一个课程表代码如下:CREATE TABLE Course(Cno CHAR(4)PRIMARY KEY,Cname CHAR(40),Ccredit SMALLINT,FOREIGN KEY Cpno REFERENCES Course(Cno); 执行结果如下图所示:【实例3】建立
5、一个选课表表代码如下:CREATE TABLE SC (Sno CHAR(9),Cno CHAR(4),Grade SMALLINT,PRIMARY KEY(Sno,Cno),PRIMARY KEY(Sno) REFERENCES Student (Sno),PRIMARY KEY(Cno) REFERENCES Course (Cno); 执行结果如下图所示:2)基本表的删除(写出题目、sql语句)【实例4】删除Student表代码如下: DROP TABLEStudent ;执行结果如下图所示:【实例5】删除Course表代码如下: DROP TABLE Course ;执行结果如下图所示
6、:【实例6】删除SC表代码如下: DROP TABLE SC ;执行结果如下图所示:3)基本表的修改(写出题目、sql语句【实例7】向Student表增加“入学时间”列,其数据类型为日期型代码如下: ALTER TABLE Student ADD Scome DATETIME;执行结果如下图所示:【实例8】增加课程名称必须取唯一值的约束条件代码如下:ALTER TABLE Course ADD UNIQUE(Cname);执行结果如下图所示:【实例9】将年龄的数据类型有字符改为整数代码如下:ALTER TABLE Student ALTER CONMU Sage INT;执行结果如下图所示:4
7、 定义索引的语句1) create语句(阐述唯一索引和聚簇索引的区别)语句格式: CREATE UNIQUE CLUSTER INDEX ON (, ); UNIQUE表明此索引的每一个索引值只对应唯一的数据记录 CLUSTER表示要建立的索引是聚簇索引2) Drop语句语句格式:Create cluster index stusname on student(sname) DROP INDEX ; 删除索引时,系统会从数据字典中删去有关该索引的描述。5 索引的建立和删除1) 索引的建立(写出题目、sql语句)【实例10】在Student表的Sname列上建立一个聚簇索引代码如下:create
8、 index stusname on student (sname);执行结果如下图所示:2) 索引的删除(写出题目、sql语句)【实例11】删除student表的stusname索引。代码如下:Drop index stusname on student;执行结果如下图所示:完成情况: 1 完成了基本表的建立和增、删、改操作 2 完成了建立和删除索引出现的问题:(小四宋体)在完成基本表的建立和增、删、改操作任务时,遇到了代码没错但执行有误的情况,解决思路以模块为主,自行调整,顺利得到结果。English is the most widely spoken language in the hi
9、story of our planet, used in some way by at least one out of every seven human beings around the globe. Half of the worlds books are written in English, and the majority of international telephone calls are made in English. English is the language of over sixty percent of the worlds radio programs.
10、More than seventy percent of international mail is written and addressed in English, and eighty percent of all computer text is stored in English. English has acquired the largest vocabulary of all the worlds languages, perhaps as many as two million words, and has generated one of the noblest bodie
11、s of literature in the annals of the human it is now time to face the fact that English is a crazy language - the most lunatic and loopy and of all languages. In the crazy English language, the blackbird hen is brown, blackboards can be green or blue, and blackberries are green and then red before t
12、hey are ripe. Even if blackberries were really black and blueberries really blue, what are strawberries, cranberries, huckleberries, raspberries, and gooseberries supposed to look add to this insanity there is no butter in buttermilk, no egg in eggplant, no grape in grapefruit, no bread in shortbrea
13、d, neither worms nor wood in wormwood, neither mush nor room in mushroom, neither pine nor apple in pineapple, neither peas nor nuts in peanuts, and no ham in a hamburger. (In fact, if somebody invented a sandwich consisting of a ham patty in a bun, we would have a hard time finding a name for it.)T
14、o make matters worse, English muffins werent invented in England, fries in France, or Danish pastries in Denmark. And we discover even more culinary madness in the that sweetmeat is made from fruit, while sweetbread, which isnt sweet, is made from this unreliable English tongue, greyhounds arent alw
15、ays grey (or gray); panda bears and koala bears arent bears (theyre marsupials); a woodchuck is a groundhog, which is not a hog; a horned toad is a lizard; glowworms are fireflies, but fireflies are not flies (theyre beetles); ladybugs and lightning bugs are also beetles (and to, a significant propo
16、rtion of ladybugs must be male); a guinea pig is neither a pig nor from Guinea (its a South American rodent); and a titmouse is neither is like the air we breathe. Its invisible, inescapable, indispensable, and we take it for granted. But, when we take the time to step back and listen to the sounds
17、that escape from the holes in peoples faces and to ex- the paradoxes and vagaries of English, we find that hot dogs can be cold, darkrooms can be lit, homework can be done in school, nightmares can take place in broad daylight while morning sickness and daydreaming can take place at night, tomboys a
18、re girls and midwives can be men, hours - especially happy hours and rush hours - often last longer than sixty minutes, quick- sand works very slowly, boxing rings are square, silverware and glasses can be made of plastic and tablecloths of paper, most are dialed by being punched (or pushed?), and m
19、ost bathrooms dont have any baths in them. In fact, a dog can go to the bathroom under a tree - no bath, no room; its still going to the bathroom. And doesnt it seem a little bizarre that we go to the bathroom in order to go to the is it that a woman can man a station but as man cant woman one, that
20、 a man can father a movement but a woman cant mother one, and that a king rules a kingdom but a queen doesnt rule a? How did all those Renaissance men reproduce when there dont seem to have been any Renaissance writer is someone who writes, and a stinger is something that stings. But fingers dont gr
21、ocers dont, haberdashers dont, hammers dont ham, and humdingers dont the plural of tooth is teeth , shouldnt the plural of booth be ? One goose, two geese - so one moose, two One index, two indices - one Kleenex, two If people ring a bell today and rang a bell yesterday, why dont we say that they a
22、ball? If they wrote a letter, perhaps they also their tongue. If the teacher taught, why isnt it also true that the preacher? Why is it that the sun shone yesterday while I shined my shoes, that I treaded water and then trod on the beach, and that I flew out to see a World Series game in which my fa
23、vorite player flied we conceive a conception and receive at a reception, why dont we grieve a and believe a? If a horsehair mat is made from the hair of horses and a camels hair brush from the hair of camels, from what is a mohair coat made? If adults commit adultery, do infants commit infantry? If
24、olive oil is made from olives, what do they make baby oil from? If a vegetarian eats vegetables, what does a humanitarian eat? (And Im beginning to worry about those authoritarians.)And if pro and con are opposites, is congress the opposite of you have to believe that all English speakers should be
25、committed to an asylum for the verbally insane. In what other language do people drive in a parkway and park in a driveway? In what other language do people recite at a play and play at a recital? In what other language do privates eat in the general mess and generals eat in the private mess? In wha
26、t other language do people ship by truck and send cargo by ship? In what other language can your nose run and your feet can a slim chance and a fat chance be the same and a bad licking and a good licking be the same, while a wise man and a wise guy are opposites? How can sharp speech and blunt speec
27、h be the same and quite a lot and quite a few the same, while overlook and oversee are opposites? How can the weather be hot as hell one day and cold as hell the next? How can the expressions Whats going on? and Whats coming off? mean exactly the samton and unbutton and tie and untie are opposites,
28、why are loosen and unloosen and ravel and unravel he same? If bad is the opposite of good, hard the opposite of soft, and up the opposite of down, why are badly and goodly, hardly and softy, and upright and downright not opposing pairs? If harmless actions are the opposite of harmful why are shamefu
29、l and shameless behavior the same and pricey objects less expensive than priceless appropriate and inappropriate remarks and passable and impassable mountain trails are opposites, why are flammable and inflammable materials, heritable and inheritable property, and passive and impassive people the same and valuable objects less treasured than invaluable ones? If uplift is the same as lift up, why are upset and set up opposite in meaning? Why are pertinent and impertinent, canny and uncanny, and famous and infamous neither opposites nor the same? How
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 审计工作人员考核制度
- 商家运营团队风控制度
- 公司内部审计考核制度
- 上市审计制度
- 审计事务所四大八大制度
- 安全标准化绩效考核制度
- 企业内部会计审计制度
- 审计人员内训制度
- 审计要请报送制度
- 审计组成员制度
- 公路施工路基、桥梁施工台账模板
- 地质灾害与防治课件
- 世界水日中国水周知识竞赛试题及答案,世界水日中国水周线上答题活动答案
- 安徽医学高等专科学校2021年校考真题
- GB/T 42195-2022老年人能力评估规范
- YS/T 1018-2015铼粒
- GB/T 4450-1995船用盲板钢法兰
- GB/T 19812.3-2017塑料节水灌溉器材第3部分:内镶式滴灌管及滴灌带
- 110kV瓮北变110kV间隔扩建工程施工组织设计
- 听力检查及结果分析
- 电极的植入技巧-OK课件
评论
0/150
提交评论