ά»¤SQL serverµÄ28¸öСÎÊÌâ
1.ÈçºÎ´´½¨Êý¾Ý¿â
CREATE DATABASE student
2.ÈçºÎɾ³ýÊý¾Ý¿â
DROP DATABASE student
3.ÈçºÎ±¸·ÝÊý¾Ý¿âµ½´ÅÅÌÎļþ
BACKUP DATABASE student to disk=´c:S4.bak´
4.ÈçºÎ´Ó´ÅÅÌÎļþ»¹ÔÊý¾Ý¿â
RESTORE DATABASE studnet from DISK = ´c:S4.bak´
5.ÔõÑù´´½¨±í£¿
CREATE TABLE Students (
ID int IDENTITY ( 1, 1), --×ÔÔö×Ö¶Î,»ùÊý1,²½³¤1
StudentID char (4) NOT NULL ,
Name char (10) NOT NULL ,
Age int NULL ,
Birthday datetime NULL,
CONSTRAINT PK_Students PRIMARY KEY (StudentID) --ÉèÖÃÖ÷¼ü
)
CREATE TABLE Subjects (
ID int IDENTITY ( 1, 1), --×ÔÔö×Ö¶Î,»ùÊý1,²½³¤1
ClassID char (4) NOT NULL ,
ClassName char (10) NOT NULL,
CONSTRAINT PK_Subjects PRIMARY KEY (ClassID) --ÉèÖÃÖ÷¼ü
)
CREATE TABLE Scores (
ID int IDENTITY ( 1, 1), --×ÔÔö×Ö¶Î,»ùÊý1,²½³¤1
StudentID char (4) NOT NULL ,
ClassID char (4) NOT NULL ,
Score float NOT NULL,
CONSTRAINT FK_Scores_Students FOREIGN KEY (StudentID) REFERENCES Students(StudentID), --ÉèÖÃÍâ¼ü
CONSTRAINT FK_Scores_Subjects FOREIGN KEY (ClassID) REFERENCES Subjects(ClassID), --ÉèÖÃÍâ¼ü
CONSTRAINT PK_Scores PRIMARY KEY (StudentID,ClassID) --ÉèÖÃÖ÷¼ü
)
6.ÔõÑùɾ³ý±í£¿
DROP TABLE Students
7.ÔõÑù´´½¨ÊÓͼ£¿
CREATE VIEW s_s_s
AS
SELECT Students.Name, Subjects.ClassName, Scores.Score
from Scores INNER JOIN
Students ON Scores.StudentID = Students.StudentID INNER JOIN
Subjects ON Scores.ClassID = Subjects.ClassID
8.ÔõÑùɾ³ýÊÓͼ£¿
DROP VIEW s_s_s
9.ÈçºÎ´´½¨´æ´¢¹ý³Ì?
CREATE PROCEDURE GetStudent
@age INT,
@birthday DATETIME
AS
SELECT *
from students
WHERE Age = @age AND Birthday = @birthday
GO
10.ÈçºÎɾ³ý´
Ïà¹ØÎĵµ£º
¼ÙÈçÄãд¹ýºÜ¶à³ÌÐò£¬Äã¿ÉÄÜż¶û»áÅöµ½ÒªÈ·¶¨×Ö·û»ò×Ö·û´Ü´®·ñ°üº¬ÔÚÒ»¶ÎÎÄ×ÖÖУ¬ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ½«ÌÖÂÛʹÓÃCHARINDEXºÍPATINDEXº¯ÊýÀ´ËÑË÷ÎÄ×ÖÁкÍ×Ö·û´®¡£ÎÒ½«¸æËßÄãÕâÁ½¸öº¯ÊýÊÇÈçºÎÔËתµÄ£¬½âÊÍËûÃǵÄÇø±ð¡£Í¬Ê±ÌṩһЩÀý×Ó£¬Í¨¹ýÕâЩÀý×Ó£¬Äã¿ÉÒÔ¿ÉÒÔ¿¼ÂÇʹÓÃÕâÁ½¸öº¯ÊýÀ´½â¾öºÜ¶à²»Í¬µÄ×Ö·ûËÑË÷µÄÎÊÌâ¡£
&nb ......
Ò»¡¢×Ö·ûת»»º¯Êý
1¡¢ASCII()
·µ»Ø×Ö·û±í´ïʽ×î×ó¶Ë×Ö·ûµÄASCII ÂëÖµ¡£ÔÚASCII£¨£©º¯ÊýÖУ¬´¿Êý×ÖµÄ×Ö·û´®¿É²»ÓÑ’À¨ÆðÀ´£¬µ«º¬ÆäËü×Ö·ûµÄ×Ö·û´®±ØÐëÓÑ’À¨ÆðÀ´Ê¹Ó㬷ñÔò»á³ö´í¡£
2¡¢CHAR()
½«ASCII Âëת»»Îª×Ö·û¡£Èç¹ûûÓÐÊäÈë0 ~ 255 Ö®¼äµÄASCII ÂëÖµ£¬CHAR£¨£© ·µ»ØNULL ¡£
3¡¢LO ......
×ö¿ª·¢¹ý³ÌÖУ¬¾³£»áÓõ½½«ExcelÖÐÊý¾Ýµ¼³öµ½SQL ServerÖеÄÇé¿ö£¬Äã¿ÉÒÔÀûÓÃSQL SERVER ÖÐ×Ô´øµÄµ¼ÈëÊý¾ÝµÄ·½Ê½£¬µ«ÕâÖÖ·½Ê½£¬ÓÐʱ»á·¢ÏÖÊý¾Ýµ¼Èëºó£¬¿ÉÄÜΪ¿Õ£¬¿ÉÄÜ¿ªÍ·ÉÙ¸öÁ㣬´ËÖÖÇé¿ö¶à³öÏÖÓÚÊýÖµÐ͵ÄÁУ¬½ñÌìÔÚCSDNÉÏÏй䣬ż¶û·¢ÏÖÁËÒ»¸öÌû×Ó£¬½éÉܵÄÒÔÏÂÕâÖÖ·½·¨£¬±¾ÈËÇ¡ÆßÒò×î½ü¹«Ë¾×¼±¸ÉÏÊУ¬Éó¼Æ¾ÖÔÚ×öÉó¼Æ£¬¼¼ ......
1. SELECT
ʵÀý105
SELECT ID "±àºÅ",Name ÐÕÃû,
Math_Score 'Êýѧ³É¼¨', //ÔõôÓеÄÓÐAS,ÓеÄûÓÐ
Music_Score AS ÒôÀֳɼ¨,
English_Score AS Ó¢Îijɼ¨
f ......