回覆列表
  • 1 # 使用者834195712159

    程式碼示例:

    -1--

    create database test2

    on(name="test2_dat",filename="D:\SQLDB\test2.mdf",size=3MB,maxsize=9MB,filegrowth=8%)

    log on(name="test2_log",filename="D:\SQLDB\test2_log.ldf",size=1MB,maxsize=5MB,filegrowth=0)

    --2.1--

    use test2

    create table XSZG1(工號 char(4),姓名bai char(8),性別 char(2),婚否 char(4),年齡 int,基本工資du int)

    --2.2--

    insert into XSZG1

    select 1001,"李小新","男","已婚",33, 1800 union

    select 1002,"趙小蕊","女","未婚",28, 2200 union

    select 1003,"錢學塘zhi","男","已婚",45, 3500 union

    select 1004,"李明啟","男","已婚",56, 5500 union

    select 1005,"肖小風","女","未婚",27, 1800 union

    select 1006,"黃興民dao","男","已婚",46, 3300

    --2.3--

    create table XSZG2(工號 char(4), 職稱 char(12), 獎金 int)

    --2.4--

    insert into XSZG2

    select 1001,"普通員工",300 union

    select 1002,"技師",600 union

    select 1003,"工程師",800 union

    select 1004,"高階技師",1400 union

    select 1005,"工程師",800 union

    select 1006,"技師",600

    --3--

    create clustered index gh on XSZG1(工號 asc) with (fillfactor=30)

    go

    --4--

    create view XSZG

    as

    select XSZG1.工號,姓名,年齡,職稱,獎金 from XSZG1,XSZG2 where XSZG1.工號=XSZG2.工號

    go

    --5--

    select 工號 as "年齡低於平均年齡者",姓名,年齡 from XSZG1 where 年齡<(select AVG(年齡) from XSZG1)

  • 中秋節和大豐收的關聯?
  • 在真實戰場上傘兵降落後,怎麼處理傘?