2016-04-22 42 views
2
CREATE TABLE STUDENT(
    STUDENTID INT    NOT NULL, 
    STUDENTNAME VARCHAR (50)  NOT NULL, 
    AGE INT    NOT NULL, 
    ADDRESS VARCHAR (50)  NOT NULL, 
    STATE VARCHAR (50)  NOT NULL,  
    ZIPCODE INT    NOT NULL, 
    CONTACTNO INT    NOT NULL, 
    DOB INT    NOT NULL, 
    SEX VARCHAR (25)  NOT NULL, 
    PRIMARY KEY (STUDENTID) 
); 

我無法在表格中創建多個條目,例如電話聯繫號碼,用戶可以有兩個不同的號碼。如何在此表中創建多選屬性。什麼是我們的最佳腳本: -如何使用Microsoft SQL Server Management 2012爲客戶創建多選屬性

回答

1

如果你想存儲兩個數的最大值,你可以在表中創建兩個列,它們存儲像下面

CREATE TABLE STUDENT(
    STUDENTID INT    NOT NULL, 
    STUDENTNAME VARCHAR (50)  NOT NULL, 
    AGE INT    NOT NULL, 
    ADDRESS VARCHAR (50)  NOT NULL, 
    STATE VARCHAR (50)  NOT NULL,  
    ZIPCODE INT    NOT NULL, 
    CONTACTNO1 INT    NOT NULL, 
    CONTACTNO2 INT    NOT NULL, 
    DOB INT    NOT NULL, 
    SEX VARCHAR (25)  NOT NULL, 
    PRIMARY KEY (STUDENTID) 
); 
相關問題