> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ocient.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Integrity and Storage

export const Ocient = "Ocient®";

{Ocient} provides several capabilities to check on the quality of data on a node and to quarantine segment groups that are problematic for any reason. Also, you can manage pages by converting them to segments. Related to data integrity is the ability to rebuild tasks. For details, see [Distributed Tasks](/distributed-tasks).

## ALTER SEGMENT QUARANTINE

`ALTER SEGMENT QUARANTINE` isolates segment groups from segment generation or queries. Use this SQL statement if segments are causing unexpected results or crashes. The segments can be un-quarantined by setting `quarantine_level` to `none`. 

**Syntax**

```sql SQL theme={null}
-- To quarantine a single segment group:
ALTER SEGMENT QUARANTINE FOR { <quarantine_level> }
    WHERE SEGMENT_GROUP_ID = seg_id

-- To quarantine multiple segment groups:
ALTER SEGMENT QUARANTINE FOR { <quarantine_level> }
    WHERE SEGMENT_GROUP_ID in ( seg_id [,...] )

<quarantine_level> ::=
segment_generation | query | all | none
```

| **Parameter** | **Data type** | **Description**                                                                                                                                                                                                                                                                                                                              |
| ------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `seg_id`      | numeric       | The identification numbers for segment groups. <br />Depending on your `ALTER SEGMENT QUARANTINE` statement, the Ocient System quarantines the specified segment groups for having an existing quarantine removed. <br />For details about finding abnormal segments, see the [Guide to Rebuilding Segments](/guide-to-rebuilding-segments). |

### Using Quarantine Levels ( `<quarantine_level>` )

You can place quarantines at these segment levels.

| **Level**            | **Description**                                                                                                                                                                                                                                                |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `segment_generation` | Isolates the specified segments from segment generation.  <br />This statement prevents corrupt data from causing problems while still leaving the data available for future analysis.                                                                         |
| `query`              | Isolates segment groups from subsequent queries. <br />Data that is quarantined at the query level is not returned by database queries. This can be useful to prevent corrupt data from causing query problems while leaving it available for future analysis. |
| `all`                | Isolates the specified segments from segment generation and subsequent queries.                                                                                                                                                                                |
| `none`               | Removes any quarantines from the specified segments.                                                                                                                                                                                                           |

**Examples** 

This example quarantines a single segment group from `segment_generation`. 

```sql SQL theme={null}
ALTER SEGMENT QUARANTINE FOR segment_generation WHERE SEGMENT_GROUP_ID = 123456789;
```

This example quarantines multiple segment groups from `segment_generation`. 

```sql SQL theme={null}
ALTER SEGMENT QUARANTINE FOR segment_generation WHERE SEGMENT_GROUP_ID IN (1,2,3,4,5);
```

This example removes a quarantine from a single-segment group.

```sql SQL theme={null}
ALTER SEGMENT QUARANTINE FOR none WHERE SEGMENT_GROUP_ID = 123456789;
```

This example removes a quarantine from multiple segment groups.

```sql SQL theme={null}
ALTER SEGMENT QUARANTINE FOR none WHERE SEGMENT_GROUP_ID IN (1,2,3,4,5);
```

This example quarantines at the `query` level.

```sql SQL theme={null}
ALTER SEGMENT QUARANTINE FOR query WHERE SEGMENT_GROUP_ID = 123456789;
```

This example removes a quarantine at the `query` level.

```sql SQL theme={null}
ALTER SEGMENT QUARANTINE FOR none WHERE SEGMENT_GROUP_ID = 123456789;
```

This example quarantines at both the query and segment-group levels.

```sql SQL theme={null}
ALTER SEGMENT QUARANTINE FOR all WHERE SEGMENT_GROUP_ID = 123456789;
```

## DRAIN PAGES

The `DRAIN PAGES` SQL statement instructs the Ocient System to immediately convert buffered pages into segments on one or more Loader Nodes. During normal operation, the system converts pages to segments automatically based on internal thresholds and timeouts, so the `DRAIN PAGES` statement is usually needed only in special circumstances. For example, draining pages can be useful before performing planned maintenance on Loader Nodes.

The SQL statement targets all Loader Nodes by default. You can optionally scope the operation to a specific storage scope or table, and you can restrict it to a subset of Loader Nodes.

<Warning>
  The `DRAIN PAGES` statement forces the immediate restructuring of buffered data into durable segments, which can affect system resource utilization and loading performance. Contact Ocient Support before using this SQL statement.
</Warning>

**Required Privileges**

* To drain all pages or drain pages for a specific storage scope, you must have `UPDATE` privileges on the system.
* To drain pages for a specific table, you must have `UPDATE` privileges on the system or `DELETE` privileges on the database that contains the table.

**Syntax**

```sql SQL theme={null}
DRAIN PAGES
    [ FOR { SCOPE UUID = scope_uuid
          | TABLE UUID = table_uuid } ]
    [ WITH LOADERS loader_name [, loader_name [, ...] ] ]
```

| **Parameter** | **Type** | **Description**                                                                                                                                                                                                                                                                                                                                  |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scope_uuid`  | string   | The Universally Unique IDentifier (UUID) of a storage scope. When you specify this value, the system converts only pages that belong to this storage scope. This value is mutually exclusive with the `table_uuid` value. To find storage scope UUIDs, query the [sys.storage\_scopes](/system-catalog#sys-storage_scopes) system catalog table. |
| `table_uuid`  | string   | The UUID of a table. When you specify this value, the system converts only pages that belong to this table. This value is mutually exclusive with the `scope_uuid` value. To find table UUIDs, query the [sys.tables](/system-catalog#sys-tables) system catalog table.                                                                          |
| `loader_name` | string   | The name of a Loader Node. When you specify one or more loader names, the system sends the drain request only to those nodes. <br /><br />By default, the system sends the request to all Loader Nodes.                                                                                                                                          |

**Examples**

**Drain All Pages**

This example converts all buffered pages to segments across every Loader Node.

```sql SQL theme={null}
DRAIN PAGES;
```

**Drain Pages for a Storage Scope**

This example converts only pages associated with the storage scope identified by the UUID `a1b2c3d4-e5f6-7890-abcd-ef1234567890`.

```sql SQL theme={null}
DRAIN PAGES
    FOR SCOPE UUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890';
```

**Drain Pages for a Table**

This example converts only pages associated with the table identified by the UUID `12345678-abcd-ef01-2345-6789abcdef01`.

```sql SQL theme={null}
DRAIN PAGES
    FOR TABLE UUID = '12345678-abcd-ef01-2345-6789abcdef01';
```

**Drain Pages on Specific Loader Nodes**

This example sends the drain request to the `loader-node-1` and `loader-node-2` Loader Nodes.

```sql SQL theme={null}
DRAIN PAGES
    WITH LOADERS 'loader-node-1', 'loader-node-2';
```

**Drain Pages for a Table on a Specific Loader Node**

This example converts only pages associated with the table identified by the UUID `12345678-abcd-ef01-2345-6789abcdef01` on the `loader-node-1` Loader Node.

```sql SQL theme={null}
DRAIN PAGES
    FOR TABLE UUID = '12345678-abcd-ef01-2345-6789abcdef01'
    WITH LOADERS 'loader-node-1';
```

## Related Links

[Errors and Warnings](/errors-and-warnings)
