MySQL建表設定預設值 取值範圍

2021-10-10 19:39:15 字數 575 閱讀 5803

一、設定預設值

設定預設值採用default,如**所示:

二、設定取值範圍

設定取值範圍採用check,如**所示:

create

table student(

id int

notnull

primary

keyauto_increment

,name varchar(32

)not

null

,*** varchar(8

)default

('男'),

#設定預設值

age int

notnull

check

(age between

10and50)

,#設定取值範圍

class_id int

notnull

references class(id)

,stu_num varchar(32

),constraint stu_u unique

(stu_num)

);

mysql建表date型別不能設定預設值

如題,mysql建表date型別的不能設定乙個預設值,比如我這樣 create table new table biryhday datetime null default 1996 01 23 會得到錯誤資訊 invalid default value for biryhday 原因 mysql ...

MySQL 建表時 date 型別的預設值設定

在執行下面 sql 語句時發現報錯 create table jc site access pages access date date notnull default 0000 00 00 comment 訪問日期 access time time notnull comment 訪問時間 eng...

select2 取值 遍歷 設定預設值

本章內容主要介紹select2 的初始化,獲取選中值,設定預設值,三個方法。select2 美化了單選框,核取方塊和下拉框,特別是下拉框多選的問題。但同時,select2也有很多吭。效果圖 使用select2實現下拉框多選,並獲取選中值,初始設定預設值 技術 select2.js prototype...