In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to create a MySQL database to create a datetime type of related knowledge, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you will learn something after reading this article, let's take a look at it.
Environment system platform: Microsoft Windows (64-bit) version 10: 4.5
The creation of user-defined data types is supported in the Henkel database using the following statements:
CREATE DOMAIN: it creates a user-defined data type with optional constraints, based on other basic types, essentially defining a domain.
CREATE TYPE: this is typically used to create composite types (mixed data types of two or more data types) using stored procedures.
I. usage and examples of domain
If you have the following table structure:
Create table test_domain (id varchar,md5 text not null check (length (md5) = 32))
The types and constraints of md5 columns can be abstracted by defining a domain, as follows:
Highgo=# create domain md5 ashighgo-# text not nullhighgo-# check (highgo (# length (value) = 32highgo) CREATE DOMAINhighgo=# 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 TABLEhighgo=# insert into test_domain values; ERROR: value for domain md5 violates check constraint "md5_check" highgo=# insert into test_domain values; INSERT 012. Create datetime type highgo=# create domain datetime as timestamp without time zone;highgo=# create table t_time (id int,create_time datetime) in MySQL. CREATE TABLEhighgo=#\ 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: heaphighgo=# insert into t_time values (1) Now (), (2MagneNow ()) INSERT 0 2highgo=# highgo=# select * from t_time Id | create_time-+-- 1 | 2021-08-03 19V 28 create type 11.207324 2 | 2021-08-03 19V 28 CREATE TYPE name AS 11.207324 (2 rows) 3. Create type usage and sample 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 an example:
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); CREATE TYPE float8_range AS RANGE (subtype = float8, subtype_diff = float8mi) These are all the contents of the article "how to create a datetime type in a MySQL database". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.