??xml version="1.0" encoding="utf-8" standalone="yes"?>图片区亚洲欧美小说区,国产在线免费观看,美州a亚洲一视本频v色道http://www.aygfsteel.com/jlin/archive/2016/08/16/431599.htmlflyflyTue, 16 Aug 2016 10:46:00 GMThttp://www.aygfsteel.com/jlin/archive/2016/08/16/431599.htmlhttp://www.aygfsteel.com/jlin/comments/431599.htmlhttp://www.aygfsteel.com/jlin/archive/2016/08/16/431599.html#Feedback0http://www.aygfsteel.com/jlin/comments/commentRss/431599.htmlhttp://www.aygfsteel.com/jlin/services/trackbacks/431599.html首先Qmysql需要数据库q接配置&allowMultiQueries=true

jdbc:mysql://127.0.0.1:3306/mybank?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true

oracle下支持执行多条语句,下面3个相?/p>

<update id="batchUpdate" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";" > 
            update T_EMP_1 
            <set>       
                age = #{item.age}+1,name=#{item.name}
            </set>
            where id = #{item.id}
        </foreach>
</update>

<update id="batchUpdate" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" open="begin" close="end;" separator="" > 
            update T_EMP_1 
            <set>       
                age = #{item.age}+1,name=#{item.name}
            </set>
            where id = #{item.id};
        </foreach>
    </update>

<update id="batchUpdate" parameterType="java.util.List">
        begin
        <foreach collection="list" item="item" index="index" separator="" > 
            update T_EMP_1 
            <set>       
                age = #{item.age}+1,name=#{item.name}
            </set>
            where id = #{item.id};
        </foreach>
        end;
    </update>

foreach的主要用在构建in条g中,它可以在SQL语句中进行P代一个集合。foreach元素的属性主要有 itemQindexQcollectionQopenQseparatorQclose。item表示集合中每一个元素进行P代时的别名,index?定一个名字,用于表示在P代过E中Q每ơP代到的位|,open表示该语句以什么开始,separator表示在每ơ进行P代之间以什么符号作为分?W,close表示以什么结束,在用foreach的时候最关键的也是最Ҏ出错的就是collection属性,该属性是必须指定的,但是在不同情?下,该属性的值是不一LQ主要有一?U情况: 
1. 如果传入的是单参C参数cd是一个List的时候,collection属性gؓlist 
2. 如果传入的是单参C参数cd是一个array数组的时候,collection的属性gؓarray 
3. 如果传入的参数是多个的时候,我们需要把它们装成一个Map了,当然单参C可以装成mapQ实际上如果你在传入参数的时候,在breast里面也是会把它封装成一个Map的,map的key是参数名,所以这个时候collection属性值就是传入的List或array对象在自己封装的map里面的key

 扚w删除

<delete id="batchDeleteStudent" parameterType="List">
DELETE FROM STUDENT WHERE id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
     #{item}
</foreach>
</delete>

扚w更新 注意Qoracle?形如 update *** set *** where ** in(....) q种语句 in所在的集合有条数限??000?/p>

<update id="batchUpdateStudent" parameterType="List">      
UPDATE STUDENT SET name = "5566" WHERE id IN
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</update>

<update id="batchUpdateStudentWithMap" parameterType="Map" > 
UPDATE STUDENT SET name = #{name} WHERE id IN
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>

扚w插入  mysql和oracle不一?/p>

mysqlQ?/span>
<insert id="batchInsertStudent" parameterType="java.util.List">  
    INSERT INTO STUDENT (id,name,sex,tel,address)  
    VALUES   
    <foreach collection="list" item="item" index="index" separator="," >  
        (#{item.id},#{item.name},#{item.sex},#{item.tel},#{item.address})  
    </foreach>  
</insert>

oracleQ?/div>
<insert id="insertBatch4Oracle" parameterType="List">
        insert into aa(a,b)
        <foreach collection="list" item="item" index="index" separator="union all" >
           select  #{item.a},#{item.b} from dual
        </foreach>
 </insert>


fly 2016-08-16 18:46 发表评论
]]>myBatis扚wdQ修改和删除(?http://www.aygfsteel.com/jlin/archive/2015/07/13/426196.htmlflyflyMon, 13 Jul 2015 08:39:00 GMThttp://www.aygfsteel.com/jlin/archive/2015/07/13/426196.htmlhttp://www.aygfsteel.com/jlin/comments/426196.htmlhttp://www.aygfsteel.com/jlin/archive/2015/07/13/426196.html#Feedback0http://www.aygfsteel.com/jlin/comments/commentRss/426196.htmlhttp://www.aygfsteel.com/jlin/services/trackbacks/426196.html1、批量添加元素session.insert(String stringQObject o)
  1. public void batchInsertStudent(){  
  2.     List<Student> ls = new ArrayList<Student>();  
  3.     for(int i = 5;i < 8;i++){  
  4.         Student student = new Student();  
  5.         student.setId(i);  
  6.         student.setName("maoyuanjun" + i);  
  7.         student.setSex("man" + i);  
  8.         student.setTel("tel" + i);  
  9.         student.setAddress("江? + i);  
  10.         ls.add(student);  
  11.     }  
  12.     SqlSession session = SessionFactoryUtil.getSqlSessionFactory().openSession();  
  13.     session.insert("mybatisdemo.domain.Student.batchInsertStudent", ls);  
  14.     session.commit();  
  15.     session.close();  
  16. }  
  17.   
  18. <insert id="batchInsertStudent" parameterType="java.util.List">  
  19.     INSERT INTO STUDENT (id,name,sex,tel,address)  
  20.     VALUES   
  21.     <foreach collection="list" item="item" index="index" separator="," >  
  22.         (#{item.id},#{item.name},#{item.sex},#{item.tel},#{item.address})  
  23.     </foreach>  
  24. </insert>  
2、批量修改session. insert (String string,Object o)
  1. 实例1Q?nbsp; 
  2. public void batchUpdateStudent(){  
  3.     List<Integer> ls = new ArrayList<Integer>();  
  4.     for(int i = 2;i < 8;i++){  
  5.         ls.add(i);  
  6.     }  
  7.     SqlSession session = SessionFactoryUtil.getSqlSessionFactory().openSession();  
  8.     session.insert("mybatisdemo.domain.Student.batchUpdateStudent",ls);  
  9.     session.commit();  
  10.     session.close();  
  11. }  
  12. <update id="batchUpdateStudent" parameterType="java.util.List">  
  13.     UPDATE STUDENT SET name = "5566" WHERE id IN  
  14.     <foreach collection="list" item="item" index="index" open="(" separator="," close=")" >  
  15.         #{item}  
  16.     </foreach>  
  17. </update>  
  18.   
  19. 实例2Q?nbsp; 
  20. public void batchUpdateStudentWithMap(){  
  21.     List<Integer> ls = new ArrayList<Integer>();  
  22.     for(int i = 2;i < 8;i++){  
  23.         ls.add(i);  
  24.     }  
  25.     Map<String,Object> map = new HashMap<String,Object>();  
  26.     map.put("idList", ls);  
  27.     map.put("name", "mmao789");  
  28.     SqlSession session = SessionFactoryUtil.getSqlSessionFactory().openSession();  
  29.     session.insert("mybatisdemo.domain.Student.batchUpdateStudentWithMap",map);  
  30.     session.commit();  
  31.     session.close();  
  32. }  
  33. <update id="batchUpdateStudentWithMap" parameterType="java.util.Map" >  
  34.     UPDATE STUDENT SET name = #{name} WHERE id IN   
  35.     <foreach collection="idList" index="index" item="item" open="(" separator="," close=")">   
  36.         #{item}   
  37.     </foreach>  
  38. </update>  

3、批量删除session.delete(String string,Object o)
  1. public void batchDeleteStudent(){  
  2.     List<Integer> ls = new ArrayList<Integer>();  
  3.     for(int i = 4;i < 8;i++){  
  4.         ls.add(i);  
  5.     }  
  6.     SqlSession session = SessionFactoryUtil.getSqlSessionFactory().openSession();  
  7.     session.delete("mybatisdemo.domain.Student.batchDeleteStudent",ls);  
  8.     session.commit();  
  9.     session.close();  
  10. }  
  11. <delete id="batchDeleteStudent" parameterType="java.util.List">  
  12.     DELETE FROM STUDENT WHERE id IN  
  13.     <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   
  14.         #{item}   
  15.     </foreach>  
  16. </delete>  

转自Q?nbsp;http://blog.csdn.net/myjlvzlp/article/details/8434376



fly 2015-07-13 16:39 发表评论
]]>
oracle 多行转一列,一列{多行(?http://www.aygfsteel.com/jlin/archive/2015/01/23/422382.htmlflyflyFri, 23 Jan 2015 03:46:00 GMThttp://www.aygfsteel.com/jlin/archive/2015/01/23/422382.htmlhttp://www.aygfsteel.com/jlin/comments/422382.htmlhttp://www.aygfsteel.com/jlin/archive/2015/01/23/422382.html#Feedback0http://www.aygfsteel.com/jlin/comments/commentRss/422382.htmlhttp://www.aygfsteel.com/jlin/services/trackbacks/422382.html阅读全文

fly 2015-01-23 11:46 发表评论
]]>
SQL查询重复记录-?/title><link>http://www.aygfsteel.com/jlin/archive/2014/10/09/418564.html</link><dc:creator>fly</dc:creator><author>fly</author><pubDate>Thu, 09 Oct 2014 11:05:00 GMT</pubDate><guid>http://www.aygfsteel.com/jlin/archive/2014/10/09/418564.html</guid><wfw:comment>http://www.aygfsteel.com/jlin/comments/418564.html</wfw:comment><comments>http://www.aygfsteel.com/jlin/archive/2014/10/09/418564.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jlin/comments/commentRss/418564.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jlin/services/trackbacks/418564.html</trackback:ping><description><![CDATA[<blockquote style="margin-right: 0px; padding-top: 10px; padding-right: 60px; padding-left: 60px; min-height: 35px; line-height: 1.6em; font-family: Verdana, Arial, Helvetica, sans-serif; background-color: #faf7ef;"><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">假设现有一张h员表Q表名:PersonQ,若想姓名、n份证受住址q三个字D完全相同的记录查找出来Q?/p><div style="margin: 0px; font-size: small; color: black; font-family: consolas, 'Courier New', courier, monospace; background-color: #ffffff;"><pre style="margin: 0em; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: consolas, 'Courier New', courier, monospace;"><span style="margin: 0px; padding: 0px; color: #606060;"> 1: </span><span style="margin: 0px; padding: 0px; color: #0000ff;">SELECT</span> p1.* </pre><pre style="margin: 0em; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: consolas, 'Courier New', courier, monospace;"><span style="margin: 0px; padding: 0px; color: #606060;"> 2: </span><span style="margin: 0px; padding: 0px; color: #0000ff;">FROM</span> persons p1,persons p2 </pre><pre style="margin: 0em; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: consolas, 'Courier New', courier, monospace;"><span style="margin: 0px; padding: 0px; color: #606060;"> 3: </span><span style="margin: 0px; padding: 0px; color: #0000ff;">WHERE</span> p1.id<>p2.id </pre><pre style="margin: 0em; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: consolas, 'Courier New', courier, monospace;"><span style="margin: 0px; padding: 0px; color: #606060;"> 4: </span><span style="margin: 0px; padding: 0px; color: #0000ff;">AND</span> p1.cardid = p2.cardid </pre><pre style="margin: 0em; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: consolas, 'Courier New', courier, monospace;"><span style="margin: 0px; padding: 0px; color: #606060;"> 5: </span><span style="margin: 0px; padding: 0px; color: #0000ff;">AND</span> p1.pname = p2.pname </pre><pre style="margin: 0em; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: consolas, 'Courier New', courier, monospace;"><span style="margin: 0px; padding: 0px; color: #606060;"> 6: </span><span style="margin: 0px; padding: 0px; color: #0000ff;">AND</span> p1.address = p2.address</pre></div><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"></p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">可以实现该功能?/p></blockquote><blockquote style="margin-right: 0px; padding-top: 10px; padding-right: 60px; padding-left: 60px; min-height: 35px; line-height: 1.6em; font-family: Verdana, Arial, Helvetica, sans-serif; background-color: #faf7ef;"><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"><strong style="margin: 0px; padding: 0px;">删除重复记录的SQL语句</strong></p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">1.用rowidҎ</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">2.用group byҎ</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">3.用distinctҎ</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"> </p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"><strong style="margin: 0px; padding: 0px;">1。用rowidҎ</strong></p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">据据oracle带的rowid属性,q行判断Q是否存在重?语句如下Q?nbsp;<br style="margin: 0px; padding: 0px;" /><strong style="margin: 0px; padding: 0px;">查数? <br style="margin: 0px; padding: 0px;" /></strong>     select * from table1 a where rowid !=(select   max(rowid)   <br style="margin: 0px; padding: 0px;" />     from table1 b where a.name1=b.name1 and a.name2=b.name2......) <br style="margin: 0px; padding: 0px;" /><strong style="margin: 0px; padding: 0px;">删数据:</strong> <br style="margin: 0px; padding: 0px;" />    delete   from table1 a where rowid !=(select   max(rowid)   <br style="margin: 0px; padding: 0px;" />     from table1 b where a.name1=b.name1 and a.name2=b.name2......)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"><strong style="margin: 0px; padding: 0px;">2.group byҎ</strong></p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">查数? <br style="margin: 0px; padding: 0px;" />select count(num), max(name) from student --列出重复的记录数Qƈ列出他的name属?nbsp;<br style="margin: 0px; padding: 0px;" />group by num <br style="margin: 0px; padding: 0px;" />having count(num) >1 --按num分组后找中num列重复,卛_现次数大于一?nbsp;<br style="margin: 0px; padding: 0px;" />删数据: <br style="margin: 0px; padding: 0px;" />delete from student <br style="margin: 0px; padding: 0px;" />group by num <br style="margin: 0px; padding: 0px;" />having count(num) >1 <br style="margin: 0px; padding: 0px;" />q样的话把所有重复的都删除了?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"><strong style="margin: 0px; padding: 0px;">3.用distinctҎ</strong> -对于的表比较有?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">create table table_new as   select distinct *   from table1 minux <br style="margin: 0px; padding: 0px;" />truncate table table1; <br style="margin: 0px; padding: 0px;" />insert into table1 select * from table_new;</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"> </p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;"><strong style="margin: 0px; padding: 0px;">查询及删除重复记录的Ҏ大全</strong> <br style="margin: 0px; padding: 0px;" />1、查找表中多余的重复记录Q重复记录是Ҏ单个字段QpeopleIdQ来判断</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select * from people <br style="margin: 0px; padding: 0px;" />where peopleId in (select  peopleId  from  people  group  by  peopleId  having  count(peopleId) > 1)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">2、删除表中多余的重复记录Q重复记录是Ҏ单个字段QpeopleIdQ来判断Q只留有rowid最的记录 <br style="margin: 0px; padding: 0px;" />delete from people <br style="margin: 0px; padding: 0px;" />where peopleId  in (select  peopleId  from people  group  by  peopleId   having  count(peopleId) > 1) <br style="margin: 0px; padding: 0px;" />and rowid not in (select min(rowid) from  people  group by peopleId  having count(peopleId )>1)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">3、查找表中多余的重复记录Q多个字D) <br style="margin: 0px; padding: 0px;" />select * from vitae a <br style="margin: 0px; padding: 0px;" />where (a.peopleId,a.seq) in  (select peopleId,seq from vitae group by peopleId,seq  having count(*) > 1)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">4、删除表中多余的重复记录Q多个字D)Q只留有rowid最的记录 <br style="margin: 0px; padding: 0px;" />delete from vitae a <br style="margin: 0px; padding: 0px;" />where (a.peopleId,a.seq) in  (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) <br style="margin: 0px; padding: 0px;" />and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">5、查找表中多余的重复记录Q多个字D)Q不包含rowid最的记录 <br style="margin: 0px; padding: 0px;" />select * from vitae a <br style="margin: 0px; padding: 0px;" />where (a.peopleId,a.seq) in  (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1) <br style="margin: 0px; padding: 0px;" />and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">(? 比方?在A表中存在一个字D?#8220;name”Q?nbsp;<br style="margin: 0px; padding: 0px;" />而且不同记录之间?#8220;name”值有可能会相同, <br style="margin: 0px; padding: 0px;" />现在是需要查询出在该表中的各记录之间Q?#8220;name”值存在重复的; <br style="margin: 0px; padding: 0px;" />Select Name,Count(*) From A Group By Name Having Count(*) > 1</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">如果q查性别也相同大则如? <br style="margin: 0px; padding: 0px;" />Select Name,sex,Count(*) From A Group By Name,sex Having Count(*) > 1</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">(? Ҏ一</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">declare @max integer,@id integer</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">declare cur_rows cursor local for select dD?count(*) from 表名 group by dD?having count(*) >Q?1</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">open cur_rows</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">fetch cur_rows into @id,@max</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">while @@fetch_status=0</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">begin</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select @max = @max -1</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">set rowcount @max</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">delete from 表名 where dD?= @id</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">fetch cur_rows into @id,@max</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">end</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">close cur_rows</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">set rowcount 0</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">Ҏ?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">Q重复记录"有两个意义上的重复记录,一是完全重复的记录Q也x有字D均重复的记录,二是部分关键字段重复的记录,比如Name字段重复Q而其他字D不一定重复或都重复可以忽略?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">1、对于第一U重复,比较Ҏ解决Q?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select distinct * from tableName</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">可以得到无重复记录的结果集?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">如果该表需要删除重复的记录Q重复记录保?条)Q可以按以下Ҏ删除</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select distinct * into #Tmp from tableName</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">drop table tableName</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select * into tableName from #Tmp</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">drop table #Tmp</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">发生q种重复的原因是表设计不周生的Q增加唯一索引列即可解冟?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">2、这c重复问题通常要求保留重复记录中的W一条记录,操作Ҏ如下</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">假设有重复的字段为Name,AddressQ要求得到这两个字段唯一的结果集</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select identity(int,1,1) as autoID, * into #Tmp from tableName</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select min(autoID) as autoID into #Tmp2 from #Tmp group by Name,autoID</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select * from #Tmp where autoID in(select autoID from #tmp2)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">最后一个select卛_CNameQAddress不重复的l果集(但多了一个autoID字段Q实际写时可以写在select子句中省L列)</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">(? 查询重复</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select * from tablename where id in (</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">select id from tablename</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">group by id</p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px;">having count(id) > 1)</p></blockquote><img src ="http://www.aygfsteel.com/jlin/aggbug/418564.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jlin/" target="_blank">fly</a> 2014-10-09 19:05 <a href="http://www.aygfsteel.com/jlin/archive/2014/10/09/418564.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ORA-01034: ORACLE not available http://www.aygfsteel.com/jlin/archive/2014/07/22/416094.htmlflyflyTue, 22 Jul 2014 10:43:00 GMThttp://www.aygfsteel.com/jlin/archive/2014/07/22/416094.htmlhttp://www.aygfsteel.com/jlin/comments/416094.htmlhttp://www.aygfsteel.com/jlin/archive/2014/07/22/416094.html#Feedback0http://www.aygfsteel.com/jlin/comments/commentRss/416094.htmlhttp://www.aygfsteel.com/jlin/services/trackbacks/416094.html startup ORACLE 例程已经启动? Total System Global Area 535662592 bytes Fixed Size 1375792 bytes Variable Size 293601744 bytes Database Buffers 234881024 bytes Redo Buffers 5804032 bytes 数据库装载完毕? ORA-03113: 通信通道的文件结? q程 ID: 5412 会话 ID: 5 序列? 5 出现一个新错误QORA-03113: 通信通道的文件结;分析可能׃昨晚数据库强制关闭,D文g状态可能不一_因ؓ正常关闭数据库会同步校验各文Ӟ使得重新启动的时候文件时间点一致? 扑ֈ解决Ҏ如下Q? SQL> conn / as sysdba 已连接到I闲例程? SQL> startup mount ORACLE 例程已经启动? Total System Global Area 535662592 bytes Fixed Size 1375792 bytes Variable Size 293601744 bytes Database Buffers 234881024 bytes Redo Buffers 5804032 bytes 数据库装载完毕? SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC ---------- ---------- ---------- ---------- ---------- ---------- --- STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME ---------------- ------------- -------------- ------------ ------------- 1 1 340 52428800 512 1 NO INACTIVE 8474486 02-4?-11 8522856 02-4?-11 3 1 342 52428800 512 1 NO INACTIVE 8555222 06-4?-11 8565162 11-4?-11 2 1 343 52428800 512 1 NO CURRENT 8565162 11-4?-11 2.8147E+14 SQL> alter database open resetlogs 2 ; alter database open resetlogs * W?1 行出现错? ORA-01139: RESETLOGS 选项仅在不完全数据库恢复后有? SQL> recover database until time '2011-04-11 12:12:12' 完成介质恢复? SQL> alter database open resetlogs; 数据库已更改? SQL> shutdown 数据库已l关闭? 已经卸蝲数据库? ORACLE 例程已经关闭? SQL> startup ORACLE 例程已经启动? Total System Global Area 535662592 bytes Fixed Size 1375792 bytes Variable Size 293601744 bytes Database Buffers 234881024 bytes Redo Buffers 5804032 bytes 数据库装载完毕? 数据库已l打开? 解决ҎQ二 我顶 字号Q大 ? ? 在试囄录pl/sql?输入用户名(system/pwd)后,Oracle报告下列错误Q? ERROR: ORA-27101 Shared memory realm does not exist ORA-01034 ORACLE not available &<60; 查阅了相? ORA-27101 Shared memory realm does not exist ORA-01034 ORACLE not available &<60; 的说明,解释为ORACLE_HOME或者ORACLE_SID讄不正? 但检查bash_profile以后没有发现错误; 錯誤點,沒有開啟oracle服務Q? 解決辦法Q直接開啟oracle盔R數據庫的服務Q? 或按照下面的步驟操作: lsnrctl start sqlplus '/as sysdba' sql> startup emctl start dbconsole isqlplusctl start

fly 2014-07-22 18:43 发表评论
]]>
【故障处理】ORA-00119: invalid specification for system parameter LOCAL_LISTENERhttp://www.aygfsteel.com/jlin/archive/2014/07/22/416093.htmlflyflyTue, 22 Jul 2014 10:38:00 GMThttp://www.aygfsteel.com/jlin/archive/2014/07/22/416093.htmlhttp://www.aygfsteel.com/jlin/comments/416093.htmlhttp://www.aygfsteel.com/jlin/archive/2014/07/22/416093.html#Feedback0http://www.aygfsteel.com/jlin/comments/commentRss/416093.htmlhttp://www.aygfsteel.com/jlin/services/trackbacks/416093.html

fly 2014-07-22 18:38 发表评论
]]>
oracle数据库导入导出命??http://www.aygfsteel.com/jlin/archive/2014/07/17/415961.htmlflyflyThu, 17 Jul 2014 12:51:00 GMThttp://www.aygfsteel.com/jlin/archive/2014/07/17/415961.htmlhttp://www.aygfsteel.com/jlin/comments/415961.htmlhttp://www.aygfsteel.com/jlin/archive/2014/07/17/415961.html#Feedback0http://www.aygfsteel.com/jlin/comments/commentRss/415961.htmlhttp://www.aygfsteel.com/jlin/services/trackbacks/415961.htmloracle数据库导入导出命令!

Oracle数据导入导出imp/exp 
功能QOracle数据导入导出imp/expq当与oracle数据q原与备份?br /> 
大多情况都可以用Oracle数据导入导出完成数据的备份和q原Q不会造成数据的丢失)?br /> Oracle有个好处Q虽然你的电脑不是服务器Q但是你装了oracle客户端,q徏立了q接
 Q通过Net Configuration Assistantd正确的服务命名,其实你可以想成是客户端与服务器端 修了条\Q然后数据就可以被拉q来了)
 q样你可以把数据导出到本圎ͼ虽然可能服务器离你很q?br /> 你同样可以把dmp文g从本地导入到q处的数据库服务器中?br /> 利用q个功能你可以构Z个相同的数据库,一个用来测试,一个用来正式用?br /> 
执行环境Q可以在SQLPLUS.EXE或者DOSQ命令行Q中执行Q?br /> DOS中可以执行时׃ 在oracle 8i ?nbsp; 安装目录\$ora10g\BIN被设|ؓ全局路径Q?br /> 该目录下有EXP.EXE与IMP.EXE文g被用来执行导入导出?br /> oracle用java~写Q我想SQLPLUS.EXE、EXP.EXE、IMP.EXEq俩个文件是被包装后的类文g?br /> SQLPLUS.EXE调用EXP.EXE、IMP.EXE他们所包裹的类Q完成导入导出功能?br /> 
下面介绍的是导入导出的实例,向导入导出看实例基本上就可以完成Q因为导入导出很单?br />数据导出Q?br /> 1 数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp?br />   exp system/manager@TEST file=d:\daochu.dmp full=y
 2 数据库中system用户与sys用户的表导出
   exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)
 3 数据库中的表table1 、table2导出
   exp system/manager@TEST file=d:\daochu.dmp tables=(table1,table2) 
 4 数据库中的表table1中的字段filed1?00"打头的数据导?br />   exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=\" where filed1 like  '00%'\"
  
     上面是常用的导出Q对于压~我不太在意Q用winzip把dmp文g可以很好的压~?br />                     不过在上面命令后?加上 compress=y  可以了

数据的导?br /> 1 D:\daochu.dmp 中的数据导入 TEST数据库中?br />   imp system/manager@TEST  file=d:\daochu.dmp
   上面可能有点问题Q因为有的表已经存在Q然后它报错,对该表就不进行导入?br />   在后面加?ignore=y 可以了?br /> 2 d:\daochu.dmp中的表table1 导入
 imp system/manager@TEST  file=d:\daochu.dmp  tables=(table1) 
 
 基本上上面的导入导出够用了。不情冉|是将表彻底删除,然后导入?br /> 
注意Q?br /> 你要有够的权限Q权限不够它会提CZ?br /> 数据库时可以q上的。可以用tnsping TEST 来获得数据库TEST能否q上?/p>

 

数据导出Q?br />exp hkb/hkb@boss_14 full=y file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbfull.log;

导出注意事项Q导出的是当前用L的数据,当前用户如果有DBA的权限,则导出所有数据!

同名用户之间的数据导入:
imp hkb/hkb@xe  file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbimp.log full=y

不同名之间的数据导入Q?br />imp system/test@xe fromuser=hkb touser=hkb_new file=c:\orabackup\hkbfull.dmp

log=c:\orabackup\hkbimp.log;



fly 2014-07-17 20:51 发表评论
]]>
վ֩ģ壺 | | | | | | | | ÷| | | | ̨| | ض| | | | ˫| | ɽ| ɳ| | ʯɽ| | غ| ˿| ˮ| | | ޻| | | | | | κ| ǿ| | | |