新手求助,每次都要一句句把sql语句复制到splplus里面执行,很麻烦,我要怎么把下面的语句改成一篇完整的脚本啊?直接运行这段脚本就可以了,下面的句子都可以直接运行
--首先我们是进入默认的orcl数据库
conn / as sysdba --然后建立一个新的用户ourTeam
create user ourTeam identified by ASdf1234--然后赋予ourTeam数据库管理员的权限
grant dba to ourTeam--然后我们就可以在这个用户下建立这次要做的网站的全部表了--登录ourTeam用户
conn ourTeam / ASdf1234--首先创建一个自增数列,用于newstype 的ID自增
create sequence newsTyoeIdIncrease 
increment  by 1 
start with 10001  
noMaxValue
noCycle
noCache--建立  新闻类型表
create table newstype 
(
    typeid int not null , 
    typename  varchar2(30) not null ,
    
    constraint pkNewsType primary key (typename )
)
--当newstype表需要增加元组的时候,用下面语句:
--insert into table_name 
--values ( newsTyoeIdIncrease.nextVal  ,  typename )
--建立第二个自增 , 用于adid 的自增
create sequence adidIncrease
increment by 1
start with 1001
noMaxValue
noCycle
noCache--建立  新闻表
create table news
(
    adid  int not null ,
    adname varchar2 (50)  null ,
    adsubject  varchar2 (20)  null  ,
    adtype varchar2(20)  null  ,
    adcontent varchar2 (1000) null ,
    adhit int  null ,  --点击率
    addata  date null 
    --其实这里作者写错了,应该是addate,不过既然我们也不做修改了
    --将错就错
)--同样插入news表的时候
--insert into news (adid , ......)
--values (adidIncrease.nextVal , ....)
--然后建立第三个自增,是给uid 自增用的
create sequence uidIncrease
increment by 1 
start with 10001 
noMaxValue
noCycle
noCache--然后是用户表users
create table  users
(
    --因为原来的uid 是oracle的关键字,所以要改为user_id
    user_id  int not  null , 
    uname varchar2 (20)  not  null  ,
    upass varchar2 (20)  null ,
    umail  varchar2 (20) null ,
    usex varchar2 (8)  null ,
    uage  int null ,
    uphone varchar2 (12)  null , 
    uadd varchar2 (50)  null ,
    uqq varchar2 (10) null , 
    uadmin int  null  ,
    
    constraint pkUSer primary key (user_id) 
)
--同样插入users的时候也要用uidIncrease--再创建一个自增,用于comment_id自增
create sequence commentIdIncrease
increment by 1 
start with 100001 
noMaxValue 
noCycle
noCache
--创建评论表 comment 
--因为原来的comment 也是一个关键字,所以要改
create table newscomment 
(
    comment_id  int  not null , 
    comment_name varchar2 (40)  null  ,
    comment_newsid  int  null , 
    comment_content   varchar2 (1000)  null  ,
    comment_ip  varchar2 (15)  null  ,
    comment_time date null ,
    
    constraint pkNewsComment primary key (comment_id)
)
--同样这个表插入的时候也要用commentIdIncrease--下面是部分测试用例:
insert into newstype (  typeid , typename )
values ( newsTyoeIdIncrease.nextVal  ,  '体育') insert into newstype (  typeid , typename )
values ( newsTyoeIdIncrease.nextVal  ,  '政治')insert into newstype (  typeid , typename )
values ( newsTyoeIdIncrease.nextVal  ,  '养生')  
--记得commit
insert into news ( adid , adname  , adsubject ,
adtype ,  adcontent  , adhit , addata )
values (adidIncrease .nextVal ,  '习近平会见朝鲜'  ,'习近平' ,'政治', '习近平政治  习近平:不管局势如何变化都应坚持无核化目标;崔龙海:朝方真诚希望发展经济,改善民生
范长龙会见金正恩特使崔龙海,称围绕朝核问题各方战略矛盾加剧,危及半岛和平稳定
综合新华社电 中共中央总书记、国家主席习近平24日下午在人民大会堂会见朝鲜劳动党第一书记金正恩特使、
朝鲜劳动党中央政治局常委崔龙海。崔龙海转交了金正恩第一书记给习近平总书记的亲笔信。
朝特使称愿六方会谈' , 500 , to_date('20130512' , 'yyyymmdd')  )
 
 
 
 
 
 insert into news ( adid , adname  , adsubject ,
adtype ,  adcontent  , adhit , addata )
values (adidIncrease .nextVal ,  '17+5热火真巨头今夜可免责 '  ,'詹姆斯' ,'体育', '  新浪体育讯 在刚刚结束的NBA[微博]季后赛东区决赛中,
迈阿密热火[微博]在主场以93-97不敌印第安纳步行者,大比分被扳成1-1平。
热火内线轴心克里斯-波什[微博]出战37分钟,14投6中得到17分5篮板1助攻1抢断,表现中规中矩。
  其实从系列赛第一战热火赢球的艰难程度就可以看出,步行者和热火的比赛很难有更多的变化,
ESPN五人专家团在被问到“你们对第二场有比赛有什么预期”时,就有专家直言:
“大部分还是一样的——步行者强硬的防守,低下的进攻效率。而热火需要更好的应付步行者的防守。”' , 500 , to_date('20130422' , 'yyyymmdd')  )
 
  
  insert into news ( adid , adname  , adsubject ,
adtype ,  adcontent  , adhit , addata )
values (adidIncrease .nextVal ,  '三种夏季水果忍忍再吃 '  ,'水果' ,'养生', '都说蔬果要吃当季的,可就有这么三款夏季水果是特例。据台湾《康健》杂志载文称,夏季盛产水果中,荔枝、龙眼和榴莲,更适合秋天食用。
  这是因为,荔枝、龙眼属温热水果,榴莲过于油腻,夏天吃容易上火,尤其对于体质偏热的人要少吃。
  夏季是天地间暑气最盛、气温最高的季节,呈现出“暑邪”和“湿邪”并存的状况,
而这两种邪气都对肠胃功能有直接的不良影响。所以,夏天最容易吃坏肚子。
  最适合夏季的菜单,应该是清热、去湿、消暑、健脾的清淡食物。
例如夏季最丰富的新鲜蔬菜水果,富含大量水分和纤维质等养分,可防止脱水、
清除宿便。其实,除了适合秋天温补的荔枝、龙眼,和过于油腻的榴莲外,夏季水果都能充分消除暑气,其中尤以瓜类最佳。' , 500 , to_date('20130422' , 'yyyymmdd')  )insert into users (user_id ,  uname , upass  ,uadmin)
values (uidIncrease.nextVal  , 'admin',  'admin' , 1 )
insert into users (user_id ,  uname , upass  )
values (uidIncrease.nextVal  , 'Tom' , 'Tom'  )insert into users (user_id ,  uname , upass  )
values (uidIncrease.nextVal  , 'Mary' , 'Mary'  )
Oracle

解决方案 »

  1.   

    每个语句 后面带上分号,然后保存为d:\a.sql;连接上数据库后,@d:\sql  执行即可。
      

  2.   

    把你每一个单独的语句后面加;或者/,存为name.sql格式,sqlplus user/password@sid 后@name.sql就可以了。linux下可以写成shell运行
      

  3.   

    楼上的说的已经比较详尽了
    另外,在DML语句后加上合适的COMMIT
      

  4.   

    这种方式可以执行多个sql,并且将执行结果输出到一个文本文件中。
    test1.sql:比如是数据表结构脚本
    test2.sql:比如是触发器脚本
    test3.sql:比如是测试数据脚本spool 执行结果.txt  
      
    @test1.sql @[email protected] 
      
    spool off  
      
    commit;  
    假设上述代码被保存为@main.sql这样使用:sqlplus进入main.sql的绝对路径中,然后@main.sql,就可以执行test2.sql、test2.sql、test3.sql多个脚本并将执行结果导出到执行结果.txt中。
      

  5.   


    纠正个错误,被保存为main.sql