如何管理可选和必需的列 [英] How to manage a optional and mandatory columns

查看:71
本文介绍了如何管理可选和必需的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个产品表,其中一些字段是固定的,一些可选的如何管理那些字段如

他们已经过期的一些产品日期和一些产品他们没有如何设计的桌子结构



我的尝试:



我刚创建产品表列中的产品表是

Productid

产品名称

金额

数量

Netamount

I have a product tables some of it fields are fixed and some of optional how to manage thats fields like
Some of product they have expired date and some of product they don't have how to designed table structure

What I have tried:

I just create product table in the product table column is
Productid
Productname
Amount
Quantity
Netamount

推荐答案

create table showExample



Productid int not null,

Productname varchar(50)not null,

金额,

数量int,

Netamount money







上述语句可帮助您创建一个包含可空列和不可空列的表。默认情况下,列接受null值,直到除非应用not null/主键约束。

因此,在表showExample中,字段Productid和Productname是必需的,而其他字段可以具有null值。

我希望这可以解决这个问题。
create table showExample
(
Productid int not null,
Productname varchar(50) not null,
Amount money,
Quantity int,
Netamount money
)


Above statement helps you to create a table which have both nullable and non nullable columns. By default a column accepts null value untill and unless "not null"/primary key constraint is applied.
So, in Table showExample, fields Productid and Productname are mandatory while others can have null value.
I hope this solves the confusion.


将所有字段设为非Null,这些字段是固定的和强制性的。

所有其他都是Null是可选的。
Make all fields as Not Null which are fixed and mandatory.
all others are Null that is optional.


这篇关于如何管理可选和必需的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆