请问如何为数据库表中的字段设定缺省值?(100分)

  • 主题发起人 主题发起人 丑小鸭
  • 开始时间 开始时间

丑小鸭

Unregistered / Unconfirmed
GUEST, unregistred user!
可以用Sql,email :gaoylqilin@sohu.com
 
您指手工创建表格还是动态创建啊,是手工得话,肯定有个地方直接设定啊,比如sql中
就是可以的可能叫:既定值:吧
否则,你可以用sql语言创建,象这样
CREATE TABLE employee
(
emp_id empid
CONSTRAINT PK_emp_id PRIMARY KEY NONCLUSTERED
CONSTRAINT CK_emp_id CHECK (emp_id LIKE
'[A-Z][A-Z][A-Z][1-9][0-9][0-9][0-9][0-9][FM]' or
emp_id LIKE '[A-Z]-[A-Z][1-9][0-9][0-9][0-9][0-9][FM]'),
/* Each employee ID consists of three characters that
represent the employee's initials, followed by a five
digit number ranging from 10000 through 99999 and then the
employee's gender (M or F). A (hyphen) - is acceptable
for the middle initial. */
fname varchar(20) NOT NULL,
minit char(1) NULL,
lname varchar(30) NOT NULL,
job_id smallint NOT NULL
DEFAULT 1
/* Entry job_id for new hires. */
REFERENCES jobs(job_id),
job_lvl tinyint
DEFAULT 10,
/* Entry job_lvl for new hires. */
pub_id char(4) NOT NULL
DEFAULT ('9952')
REFERENCES publishers(pub_id),
/* By default, the Parent Company Publisher is the company
to whom each employee reports. */
hire_date datetime NOT NULL
DEFAULT (getdate())
/* By default, the current system date is entered. */
)
使用default语句就是了,上面的例子还教你别的呢,看了觉得不错把

 
多谢lvxq!献上100分![^]
 
后退
顶部