一、查询时把两个字段拼接在一块儿sql
--sqlserver-- select Filed1+'@'+Filed2 from table --sqlite-- select Filed1||'@'||Filed2 from table
二、使用脚本添加字段,更改字段类型,删除字段sqlserver
--------添加字段---------- --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.[重命名表]
三、取前几条数据spa
--sqlsever-- SELECT TOP 10 * FROM table ORDER BY filed DESC --sqlite-- select * from table limit 0,10
四、判断插入数据
code
--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 )