企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 语言基础 - 数据类型 integer 带符号整数 real 浮点数 text 文本字符串 blob 输入存储 其他支出 int char - 运算符 == = != > >= < <= and or is等于 is not不等于 like %一个或多个 \_只有一个 in() not in() between 25 and 27 limit 3 offset 2 从第二个开始取三条数据 order by NAME desc, SALARY asc; 排序 exists() 子查询 group by NAME having 条件 分组 select distinct 去重复 - 创建表,删除表,插入数据,查找,更新 ``` <pre class="calibre14">``` DROP TABLE IF EXISTS <span class="token4">"t"</span><span class="token2">;</span> CREATE TABLE <span class="token4">"t"</span> <span class="token2">(</span> <span class="token4">"id"</span> integer NOT NULL PRIMARY KEY AUTOINCREMENT<span class="token2">,</span> <span class="token4">"ip"</span> <span class="token1">char</span><span class="token2">(</span><span class="token3">15</span><span class="token2">)</span> NOT NULL<span class="token2">,</span> <span class="token4">"money"</span> real NOT NULL <span class="token2">)</span><span class="token2">;</span> insert into <span class="token1">t</span><span class="token2">(</span>id<span class="token2">,</span>ip<span class="token2">,</span>money<span class="token2">)</span> <span class="token1">values</span><span class="token2">(</span><span class="token5">null</span><span class="token2">,</span><span class="token3">1</span><span class="token2">,</span><span class="token3">1.1</span><span class="token2">)</span> select <span class="token">*</span> from t update t set ip<span class="token">=</span><span class="token3">3</span> where id<span class="token">=</span><span class="token3">1</span> delete from t where id<span class="token">=</span><span class="token3">1</span> ``` ``` - 高级语句 ``` <pre class="calibre16">``` select <span class="token">*</span> from a cross join b 交叉连接 select <span class="token">*</span> from a inner join b on 条件 内连接 select <span class="token">*</span> from a left outer join b on 条件 左连接<span class="token2">,</span>不支持全链接右链接 select <span class="token">*</span> from a union select <span class="token">*</span> from b 合并结果<span class="token2">,</span>union all包括重复行 select ids id from table t<span class="token2">;</span>支持别名可以省略as create index i on <span class="token1">t</span><span class="token2">(</span>id<span class="token2">)</span> 单列索引 唯一索引 create unique index 不能重复数据 create index i on <span class="token1">t</span><span class="token2">(</span>id<span class="token2">,</span>id2<span class="token2">)</span> 组合索引 drop index i 删除索引 alter table t rename to t1 重命名 alter table t add column id 添加列 不支持其他功能alter begin 开始事务 rollback 回滚 commit 提交事务 ``` ```