君不见长松卧壑困风霜,时来屹立扶明堂。这篇文章主要讲述创建一个MySQL数据库中的datetime类型相关的知识,希望能为你提供帮助。
瀚高数据库
目录
环境
文档用途
详细信息
环境系统平台:Microsoft Windows (64-bit) 10版本:4.5
文档用途
介绍瀚高数据库中创建一个datetime类型的方法以及create domain 和create type的用法和区别。
详细信息
瀚高数据库中支持使用以下语句创建用户定义的数据类型:
- ?
CREATE DOMAIN
?:它创建了一个用户定义的数据类型,可以有可选的约束,基于其他基本类型,实质是定义一个域。
- ?
CREATE TYPE
?:它通常用于使用存储过程创建复合类型(两种或多种数据类型混合的数据类型)。
假如有以下表结构:
create table test_domain (id varchar,md5 text not null check(length(md5)=32));
|
highgo=# create domain md5 as highgo-# text not null highgo-# check ( highgo(# length(value) = 32 highgo(# ); CREATE DOMAIN highgo=# highgo=# \\dD md5 List of domains Schema | Name | Type | Collation | Nullable | Default | Check --------+------+------+-----------+----------+---------+---------------------------- public | md5 | text | | not null | | CHECK (length(VALUE) = 32) (1 row) highgo=# create table test_domain (id varchar,md5 md5); CREATE TABLE highgo=# insert into test_domain values(1,2); ERROR: value for domain md5 violates check constraint "md5_check" highgo=# insert into test_domain values(2,76a2173be6393254e72ffa4d6df1030a); INSERT 0 1 |
highgo=# create domain datetime as timestamp without time zone;
highgo=# create table t_time (id int,create_time datetime); CREATE TABLE highgo=# \\d+ t_time Table "public.t_time" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -------------+----------+-----------+----------+---------+---------+--------------+------------- id | integer | | | | plain | | create_time | datetime | | | | plain | | Access method: heap highgo=# insert into t_time values (1,now()),(2,now()); INSERT 0 2 highgo=# highgo=# select * from t_time; id | create_time ----+---------------------------- 1 | 2021-08-03 19:28:11.207324 2 | 2021-08-03 19:28:11.207324 (2 rows) |
CREATE TYPE name AS ( [ attribute_name data_type [ COLLATE collation ] [, ... ] ] ) CREATE TYPE name AS ENUM ( [ label [, ... ] ] ) CREATE TYPE name AS RANGE ( SUBTYPE = subtype [ , SUBTYPE_OPCLASS = subtype_operator_class ] [ , COLLATION = collation ] [ , CANONICAL = canonical_function ] [ , SUBTYPE_DIFF = subtype_diff_function ] ) CREATE TYPE name ( INPUT = input_function, OUTPUT = output_function [ , RECEIVE = receive_function ] [ , SEND = send_function ] [ , TYPMOD_IN = type_modifier_input_function ] [ , TYPMOD_OUT = type_modifier_output_function ] [ , ANALYZE = analyze_function ] [ , INTERNALLENGTH =internallength | VARIABLE] [ , PASSEDBYVALUE ] [ , ALIGNMENT = alignment ] [ , STORAGE = storage ] [ , LIKE = like_type ] [ , CATEGORY = category ] [ , PREFERRED = preferred ] [ , DEFAULT = default ] [ , ELEMENT = element ] [ , DELIMITER = delimiter ] [ , COLLATABLE = collatable ] ) CREATE TYPE name |
CREATE TYPE compfoo AS (f1 int, f2 text);
CREATE FUNCTION getfoo() RETURNS SETOF compfoo AS $$ SELECT fooid, fooname FROM foo $$ LANGUAGE SQL; CREATE TYPE bug_status AS ENUM (new, open, closed); CREATE TABLE bug ( id serial, description text, status bug_status ); 【创建一个MySQL数据库中的datetime类型】CREATE TYPE float8_range AS RANGE (subtype = float8, subtype_diff = float8mi); |
推荐阅读
- Doxygen(代码说明书生成神器)
- #yyds干货盘点# javascript学习系列(15):数组中的lastIndexOf方法
- #yyds干货盘点# Collection - LinkedList源码解析
- idea未识别出maven的pom.xml等一系列问题总结
- 全卷积网络(FCN)实战(使用FCN实现语义分割)
- Ansible的脚本------playbook剧本
- Nessus 主机漏洞扫描器安装配置使用
- SAP UI5 设备类型检测 Device API 的工作原理
- HarmonyOS - 方舟开发框架ArkUI 基于JSAPI实现五子棋游戏