SQL server基本操作(一)
--1.create database CREATE DATABASE MyDB GO --2.use database USE MyDB GO --3.create table CREATE TABLE Teacher ( id INT IDENTITY PRIMARY KEY, tname VARCHAR(10) NOT NULL, tsex BIT NOT NULL, tage INT CHECK(tage>18 AND tage<80) ) GO --4.insert data INSERT INTO Teacher values('张老师',0,25) INSERT INTO Teacher values('王老师',1,45) INSERT INTO Teacher values('李老师',0,30) GO --5.select data SELECT * FROM Teacher GO --6.select data as other name SELECT id AS '编号',tname AS '称谓',tsex AS '性别',tage AS '年龄' FROM Teacher GO --7.select data as other value SELECT id AS '编号',tname AS '称谓',CASE tsex WHEN 0 THEN '女' ELSE '男' END AS '性别',tage AS '年龄' FROM Teacher