云数据库 GaussDB-执行SQL语句

时间:2023-11-01 16:18:27

执行SQL语句

  1. 创建一个表:

    EXEC SQL CREATE TABLE foo (number integer, ascii char(16));EXEC SQL CREATE UNIQUE INDEX num1 ON foo(number);

  2. 插入一行:

    EXEC SQL INSERT INTO foo (number, ascii) VALUES (9999, 'doodad');

  3. 删除一行:

    EXEC SQL DELETE FROM foo WHERE number = 9999;

  4. 更新表数据:

    EXEC SQL UPDATE foo SET ascii = 'foobar' WHERE number = 9999;

  5. 单行查询数据:

    EXEC SQL SELECT number INTO :FooBar FROM foo WHERE ascii = 'doodad';

  6. 展示运行时参数:

    EXEC SQL SHOW search_path INTO :foo;

    :foo形式的记号是宿主变量,即指向C程序中的变量,可参考宿主变量章节。

support.huaweicloud.com/centralized-devg-v3-opengauss/gaussdb-12-0215.html