zoukankan      html  css  js  c++  java
  • sqlite与sqlserver区别

    1、查询时把两个字段拼接在一起

    --sqlserver--
    select Filed1+'@'+Filed2 from table
    
    --sqlite--
    select Filed1||'@'||Filed2 from table


    2、使用脚本添加字段,更改字段类型,删除字段

    --------添加字段----------
    
    --sqlserver--
    IF not exists 
        (select * from syscolumns where id=object_id('表名') and name='字段')
    BEGIN
        alter table 表名 add 字段 int
    end
    
    --sqlite--
    alter table 表名 add 字段 int
    
    
    --------更改字段类型----------
    
    --sqlserver--
    alter table table alter column filed nvarchar(256)
    
    --sqlite中需要把旧表重命名,创建新表(这个时候更改字段类型),然后再把数据导入到新表中,删除旧表--
    ALTER TABLE  表名  RENAME TO "重命名"
    
    Create TABLE "表名"(
    [Id] bigint NOT NULL
    ,[Name] nvarchar(16) 
    , Primary Key(Id)   
    )
    
    Insert Into '重命名' ([Id],[Name])  Select [Id],[Name] From MAIN.['表名']
    
    Drop Table MAIN.[重命名表]

     3、取前几条数据

      

    --sqlsever--
    SELECT TOP 10 * FROM table ORDER BY filed DESC
    
    --sqlite--
    select * from table limit 0,10

    4、判断插入数据
      

      

    --sqlserver--
    IF NOT EXISTS (select * from table where FID=6)  
    BEGIN 
    insert into table(FName,FIsDelete) select 't',0 
    END
    
    --sqlite--
    insert into table(FName,FIsDelete)
    select 'tt',0 where not exists(
    select * from table where FID=6
    )
  • 相关阅读:
    p67 把特定位置的位变成0,进行与运算
    p65 逻辑与运算
    JavaScript对象和初始面向对象
    JavaScript操作DOM对象
    JavaScript操作BOM对象
    JavaScript基础
    DAO模式
    使用ADO.NET访问数据库
    连接查询和分组查询
    模糊查询和聚合函数
  • 原文地址:https://www.cnblogs.com/tianboblog/p/4200685.html
Copyright © 2011-2022 走看看