日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

在SQL中使用DEFAULT约束

發布時間:2023/12/1 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在SQL中使用DEFAULT约束 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

DEFAULT constraint is used to insert default value into a column on a table and if no any value is stored in any place of a column then default value will be added into it.

DEFAULT約束用于將默認值插入到表的列中,如果列的任何位置均未存儲任何值,則將默認值添加到其中。

How to use DEFAULT with example?

如何在示例中使用DEFAULT?

CREATE TABLE EMployees (E_Id int NOT NULL,E_Name varchar(25) NOT NULL, Contact number(10),Address varchar(50), City varchar(20) DEFAULT 'Gwaloir');

We can also achieve DEFAULT value property by using GETDATE() function:

我們還可以通過使用GETDATE()函數來實現DEFAULT值屬性:

CREATE TABLE Employees (E_Id int NOT NULL,E_name varchar(50), E_Join_Date date DEFAULT GETDATE());

USE of ALTER to ADD DEFAULT constraint when table is already created:

已創建表時,使用ALTER來添加DEFAULT約束:

There is different way to add DEFAULT constraint in different database language:

有不同的方法可以用不同的數據庫語言添加DEFAULT約束 :

  • MYSQL

    MySQL數據庫

ALTER table EmployeesALTER E_name SET DEFAULT 'Bharti';
  • SQL

    SQL

  • ALTER TABLE Employees ALTER COLUMN City SET DEFAULT 'Gwalior';
  • Oracle

    Oracle

  • ALTER TABLE Employees MODIFY Contact DEFAULT '0000';

    How to DROP DEFAULT constraint from a table?

    如何從表中刪除默認約束?

    ALTER TABLE Employees ALTER COLUMN City DROP DEFAULT;

    Conclusion:

    結論:

    In this article we have learnt what DEFAULT constraint is, how to use it with example and how we can alter and drop DEFAULT on a table? If you have any doubt/query, feel free to ask in comment section.

    在本文中,我們了解了什么是DEFAULT約束 ,如何在示例中使用它,以及如何在表上更改和刪除DEFAULT ? 如果您有任何疑問/疑問,請隨時在評論部分提問。

    翻譯自: https://www.includehelp.com/sql/DEFAULT-Constraint.aspx

總結

以上是生活随笔為你收集整理的在SQL中使用DEFAULT约束的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。