连接到数据库:
CONNECT TO database_name;
创建表:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);
插入数据:
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
查询数据:
SELECT column1, column2, ...
FROM table_name
WHERE condition;
更新数据:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
删除数据:
DELETE FROM table_name WHERE condition;
子查询:
SELECT column1
FROM table1
WHERE column2 IN (SELECT column2 FROM table2);
连接查询:
SELECT *
FROM table1
INNER JOIN table2 ON table1.column = table2.column;
聚合函数:
SELECT COUNT(column1), AVG(column2), SUM(column3)
FROM table_name
WHERE condition
GROUP BY column1;
排序和限制:
SELECT column1, column2
FROM table_name
ORDER BY column1 DESC
LIMIT 10;
创建索引:
CREATE INDEX index_name ON table_name (column1, column2);
删除表或索引:
DROP TABLE table_name;
DROP INDEX index_name;
事务控制:
BEGIN; -- 开始事务
-- 执行一系列SQL语句
COMMIT; -- 提交事务
其他操作:
SHOW TABLES; -- 显示所有表
DESCRIBE table_name; -- 显示表结构
这些是一些OceanBase通用的SQL语法示例。请注意,具体的SQL语法和功能可能会受到OceanBase的版本和配置的影响,建议查阅OceanBase的官方文档以获取准确的信息。
转载请注明出处:http://www.zyzy.cn/article/detail/11498/OceanBase