云数据库 GAUSSDB-网络地址类型:macaddr

时间:2024-11-02 18:45:26

macaddr

macaddr类型存储MAC地址,也就是以太网卡硬件地址(尽管MAC地址还用于其它用途)。可以接受下列格式:

'08:00:2b:01:02:03'
'08-00-2b-01-02-03'
'08002b:010203'
'08002b-010203'
'0800.2b01.0203'
'08002b010203'

以上示例都表示同一个地址。对于数据位a到f,大小写均可。输出时都是以第一种形式展示。

示例:

gaussdb=# CREATE TABLE macaddr_test(id int, m macaddr);
CREATE TABLE
gaussdb=# INSERT INTO macaddr_test VALUES (1, '08:00:2b:01:02:03');
INSERT 0 1
gaussdb=# INSERT INTO macaddr_test VALUES (2, '08-00-2b-01-02-03');
INSERT 0 1
gaussdb=# INSERT INTO macaddr_test VALUES (3, '08002b:010203');
INSERT 0 1
gaussdb=# INSERT INTO macaddr_test VALUES (4, '08002b-010203');
INSERT 0 1
gaussdb=# INSERT INTO macaddr_test VALUES (5, '0800.2b01.0203');
INSERT 0 1
gaussdb=# INSERT INTO macaddr_test VALUES (6, '08002b010203');
INSERT 0 1
gaussdb=# SELECT * FROM macaddr_test ORDER BY id;
 id |         m         
----+-------------------
  1 | 08:00:2b:01:02:03
  2 | 08:00:2b:01:02:03
  3 | 08:00:2b:01:02:03
  4 | 08:00:2b:01:02:03
  5 | 08:00:2b:01:02:03
  6 | 08:00:2b:01:02:03
(6 rows)

gaussdb=# DROP TABLE macaddr_test;
DROP TABLE
support.huaweicloud.com/centralized-devg-v8-gaussdb/gaussdb-42-0330.html