Syntax
Table of Contents
Overview
The Katzebase SQL (KBSQL) is very similar to T-SQL. Each statement is self-terminating and does not require delimiters or terminators. It can be used to create and alter objects, schema and indexes. Create, read and delete data. Execute procedures and functions, evaluate engine state and perform various calculations.
The statements are broken down into two types (1) DML or (data manipulation language) which is for selecting, updating, inserting and deleting data and (2) DDL or (data definition language) which are used for modifying database "objects" like schema, procedures and indexes.
That's really it for the basics. There are certainly more advanced topics such as index analysis, partitioning and system functions, but those are addressed in individual topics.
Basic DML Statements
Select
SELECT * FROM WordList:Word
SELECT
Id, Text, LanguageId
FROM
WordList:Word
SELECT
Id, Text, LanguageId
FROM
WordList:Word
WHERE
Text = 'Dog'
Insert
INSERT INTO WordList:Word
(
Text = 'Sarah',
LanguageId = 1
)
You can repeat as many of these sets as you like. Notice that the fields can vary per-set.
INSERT INTO WordList:Word
(
Id = 0,
Text = 'Sarah',
LanguageId = 1
),
(
Id = 1,
Text = 'Brightman'
)
Update
UPDATE
WordList:Word
SET
Text = 'Neward',
LanguageId = 2
WHERE
Id = 0
Execute
EXEC WordList:Word:CreateAndGetWord('Neward')
Delete
DELETE FROM
WordList:Word
WHERE
Text = 'Neward'
Basic DDL Statements
Create Schema
CREATE SCEHMA WordList:Definitions
For more information, see PageSize.
CREATE SCEHMA WordList:Definitions WITH (PageSize = 10000)
Drop Schema
DROP SCEHMA WordList:Definitions
Create Procedure
CREATE PROCEDURE CreateAndGetWord
(
@Word as string
) ON WordList:Word AS
(
INSERT INTO WordList:Word
(
Text = @Word,
GUID = Guid(),
LanguageId = 1
)
SELECT * FROM WordList:Word WHERE Text = @Word
DELETE FROM WordList:Word WHERE Text = @Word
)
Create Index
CREATE INDEX IX_Word_Text(
LanguageId,
Text
) ON WordList:Word
For more information, see partitions and Rebuild_Index.
CREATE INDEX IX_Word_Text(
LanguageId,
Text
) ON WordList:Word WITH(Partitions = 1000)
Drop Index
DROP INDEX IX_Word_Text ON WordList:Word
Related
- Home - The home page