カテゴリ：

# ST_ASWKB , ST_ASBINARY¶

Given a value of type GEOGRAPHY or GEOMETRY, return the binary representation of that value in WKB (well-known binary) format.

こちらもご参照ください。

ST_ASEWKB

## 構文¶

ST_ASWKB( <geography_or_geometry_expression> )

ST_ASBINARY( <geography_or_geometry_expression> )


## 引数¶

geography_or_geometry_expression

The argument must be an expression of type GEOGRAPHY or GEOMETRY.

BINARY 型の値。

## 使用上の注意¶

• ST_ASBINARY は、 ST_ASWKB のエイリアスです。

• 出力を EWKB 形式で返すには、代わりに ST_ASEWKB を使用します。

## 例¶

### GEOGRAPHY Examples¶

create table geospatial_table (id INTEGER, g GEOGRAPHY);
insert into geospatial_table values
(1, 'POINT(-122.35 37.55)'), (2, 'LINESTRING(-124.20 42.00, -120.01 41.99)');

select st_aswkb(g)
from geospatial_table
order by id;
+------------------------------------------------------------------------------------+
| ST_ASWKB(G)                                                                        |
|------------------------------------------------------------------------------------|
| 01010000006666666666965EC06666666666C64240                                         |
+------------------------------------------------------------------------------------+


### GEOMETRY Examples¶

The example below demonstrates how to use the ST_ASEWKB function. The example returns the EWKB representations of two geometries.

CREATE OR REPLACE TABLE geometry_table (g GEOMETRY);
INSERT INTO geometry_table VALUES
('POINT(-122.35 37.55)'), ('LINESTRING(0.75 0.75, -10 20)');

SELECT ST_ASWKB(g) FROM geometry_table;

+------------------------------------------------------------------------------------+
| ST_ASWKB(G)                                                                        |
|------------------------------------------------------------------------------------|
| 01010000006666666666965EC06666666666C64240                                         |
| 010200000002000000000000000000E83F000000000000E83F00000000000024C00000000000003440 |
+------------------------------------------------------------------------------------+