中文字幕天天躁日日躁狠狠躁,最近中文字幕大全免费版在线,最近2019免费中文字幕视频三,亚洲精品无码你懂的,亚洲国产精品成人精品小说

  • 相關(guān)軟件
    >USER 創(chuàng)建者:webmaster 更新時間:2006-02-16 15:51

    當未指定默認值時,允許將系統(tǒng)為當前用戶的數(shù)據(jù)庫用戶名提供的值插入表內(nèi)。



    語法


    USER



    返回類型


    char



    注釋


    USER 提供與 USER_NAME 系統(tǒng)函數(shù)相同的功能。



    在 CREATE TABLE 或 ALTER TABLE 語句中將 USER 和 DEFAULT 約束一起使用,或者將 USER 作為任何標準函數(shù)使用。



    示例


    A. 使用 USER 返回當前用戶的數(shù)據(jù)庫用戶名


    本示例聲明一個 char 類型的變量,將 USER 的當前值賦給它,然后打印該變量以及文本說明。



    DECLARE @usr char(30)
    SET @usr = user
    SELECT 'The current user's database username is: '+ @usr
    GO


    下面是結(jié)果集:



    ----------------------------------------------------------------------- 
    The current user's database username is: dbo                  

    (1 row(s) affected)


    B. 將 USER 和 DEFAULT 約束一起使用


    本示例生成一個表,將 USER 用作銷售行的銷售員的 DEFAULT 約束。



    USE pubs
    GO
    CREATE TABLE inventory2
    (
    part_id int IDENTITY(100, 1) NOT NULL,
    description varchar(30) NOT NULL,
    entry_person varchar(30) NOT NULL DEFAULT USER
    )
    GO
    INSERT inventory2 (description)
    VALUES ('Red pencil')
    INSERT inventory2 (description)
    VALUES ('Blue pencil')
    INSERT inventory2 (description)
    VALUES ('Green pencil')
    INSERT inventory2 (description)
    VALUES ('Black pencil')
    INSERT inventory2 (description)
    VALUES ('Yellow pencil')
    GO


    下面是從表 inventory2 中選擇所有信息的查詢:



    SELECT * 
    FROM inventory2
    ORDER BY part_id
    GO


    下面是結(jié)果集(注意 entry-person 的值):



    part_id     description                    entry_person                   
    ----------- ------------------------------ -----------------------------
    100       Red pencil               dbo                  
    101       Blue pencil             dbo                  
    102       Green pencil             dbo                  
    103       Black pencil             dbo                  
    104       Yellow pencil             dbo                  

    (5 row(s) affected)
    相關(guān)文章
    本頁查看次數(shù):