SQLÊý¾Ý¿â»¹ÔÓï¾ä
---¸½¼ÓÊý¾Ý¿â
sp_attach_db 'Êý¾Ý¿âÃû','Êý¾Ý¿âȫ·¾¶','Êý¾Ý¿âÈÕ־ȫ·¾¶'
---²é¿´Êý¾Ý¿âÂß¼ÎļþÃû
RESTORE FILELISTONLY from disk = '±¸·ÝÎļþ'
---»¹ÔÊý¾Ý¿â
restore database hzrb from disk = '±¸·ÝÎļþ'
with move 'Ö÷Âß¼Ãû' to '´æ·Åmdf·¾¶'
,move 'ÈÕÖ¾Âß¼Ãû' to '´æ·Åldf·¾¶'
--ÐÞ¸ÄÊý¾Ý¿âµÄÂß¼ÎļþÃû£¨Êý¾Ý£©
ALTER DATABASE NEW
MODIFY FILE(NAME='Old_Data',NEWNAME='New_Data')
GO
--ÐÞ¸ÄÊý¾Ý¿âµÄÂß¼ÎļþÃû£¨ÈÕÖ¾£©
ALTER DATABASE NEW
MODIFY FILE(NAME='Old_Log',NEWNAME='New_Log')
GO
Ïà¹ØÎĵµ£º
1¡¢¶ÔÏóÀàÐ͹淶
´´½¨¶ÔÏóÀàÐ͹淶µÄÓï·¨ÈçÏÂ
CREATE [OR REPLACE] TYPE [schema.] type_name
[AUTHID {CURRENT_USER|DEFINER}] AS OBJECT (
Attribute1 datatype,
[attribute2 datatype,…]
[method 1]
[method 2]);
/
ÆäÖÐAUTHIDָʾ½«À´Ö´Ðи÷½·¨Ê±£¬ ......
Differring Constraints:
Constraints can have the following attributes: DEFFERRABLE / NOT DEFFERRABLE, INITIALLY DEFFERRED / INITIALLY IMMEDIATE.
e.g.:
alter table dept2 add constraint dept2_id_pk primary key (department_id) deferrable initially deferred; // deferring constraint on creation. ......
Merge statement
function benefits: 1) provides the ability to conditionally update, insert or delete data into a database table. 2) performs an update if the row exists, and an insert if it is a new row. --> 1) avoids seperate updates, 2) increase performance and ease of use. 3) is useful in dat ......
Group functions
SELECT [column,] group_function(column) ... from table [WHERE condition] [GROUP BY group_by_expression] [ORDER BY column];
e.g.:
SELECT department_id, job_id, SUM(salary), COUNT(employee_id) from employees GROUP BY department_id, job_id ;
SELECT [column,] group_function(column).. ......
WAITFOR
Ö¸¶¨´¥·¢Óï¾ä¿é¡¢´æ´¢¹ý³Ì»òÊÂÎñÖ´ÐеÄʱ¼ä¡¢Ê±¼ä¼ä¸ô»òʼþ¡£
Óï·¨
WAITFOR { DELAY 'time' | TIME
'time' }
²ÎÊý
DELAY
ָʾ Microsoft® SQL Server™ Ò»Ö±µÈµ½Ö¸¶¨µÄʱ¼ä¹ýÈ¥£¬×¿É´ï 24 Сʱ¡£
'time'
ÒªµÈ´ýµÄʱ¼ä¡£¿ÉÒÔ°´ datetime Êý¾Ý¿É½ÓÊܵĸñʽָ¶¨
time£¬Ò²¿ÉÒÔÓþֲ¿±äÁ¿Ö¸¶ ......