友情提示:如果本网页打开太慢或显示不完整,请尝试鼠标右键“刷新”本网页!
SQL 21日自学通(V3.0)(PDF格式)-第62部分
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部! 如果本书没有阅读完,想下次继续接着阅读,可使用上方 "收藏到我的浏览器" 功能 和 "加入书签" 功能!
CREATE VIEW
CREATE VIEW '(column1; column2。。。)' AS
SELECT
FROM
使用 CREATE VIEW 语句创建视图以后 你就可以使用它来查询数据并对视图内的数
据进行更改
499
…………………………………………………………Page 500……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
DEALLOCATE CURSOR
deallocate cursor cursor_name
DEALLOCATE CURSOR 语句可以彻底地从内存中将游标删除并释放游标的名字使
它可以为其它的游标使用 在释放它之前你应该先使用CLOSE CURSOR命令把游标关闭
DECLARE CURSOR
declare cursor_name cursor
for select_statement
DECLARE CURSOR 语句可以从 SELECT 语句中创建一个新的游标 FETCH语句可以翻阅
游标中的数据直到变量载入 然后游标跳到下一个记录上
DROP DATABASE
DROP DATABASE database_name
DROP DATABASE 语句可以彻底地删除数据库 包括数据库中的数据和它在磁盘上的
物理结构
DROP INDEX
DROP INDEX index_name
DROP INDEX 可以将表的索引删除
DROP PROCEDURE
drop procedure procedure_name
DROP PROCEDURE 语句可以从数据库中删除一个存储过程 它的功能与DROP
TABLE 和DROP INDEX 语句相似
DROP TABLE
DROP TABLE table_name;
DROP TABLE 语句可以从数据库中删除表
500
…………………………………………………………Page 501……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
DROP TRIGGER
DROP TRIGGER trigger_name
DROP TRIGGER 可以从数据库中删除触发机制
DROP VIEW
DROP VIEW view_name;
DROP VIEW 语句可以从数据库中删除视图
EXECUTE
execute '@return_status = '
procedure_name
''@parameter_name =' value |
'@parameter_name =' @variable 'output'。。。''
EXECUTE 命令可以运行一个包含有 SQL 语句的存储过程 在存贮过程中可以输入参
数 如果使用了 output 关键字的话数据还可以从参数中返回
FETCH
fetch cursor_name 'into fetch_target_list'
FETCH 命令可以将游标的内容装填到提供的程序变量中 在变量载入以后 游标就会
跳跃到下一条记录
FROM
FROM '; 。。。'
FROM 指定了联接的是哪一个表
501
…………………………………………………………Page 502……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
GRANT
GRANT role TO user 或 GRANT system_privilege TO {user_name | role | PUBLIC}
GRANT 命令可以给由命令CREATE USER所创建的用户授予规则权限
GROUP BY
GROUP BY '; 。。。'
GROUP BY 语句可以将所以列名相同的行组织在一起
HAVING
HAVING
HAVING 只有在 GROUP BY下有效 它用以限制选择的组要满足指定的搜索条件
INTERSECT
INTERSECT
INTERSECT 返回两个SELECT语句中的所有公共元素
ORDER BY
ORDER BY
ORDER BY 语句可以通过指定列句来对内容进行排序
ROLLBACK TRANSACTION
ROLLBACK TRANSACTION 语句的作用是使一个事务 从BEGIN TRANSACTION语
句运行时起 中的所有工作全部取消
REVOKE
REVOKE role FROM user
502
…………………………………………………………Page 503……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
或 REVOKE {object_priv | ALL 'PRIVILEGES'}
'; {object_priv | ALL 'PRIVILEGES'} ' 。。。
ON 'schema。'object
FROM {user | role | PUBLIC} '; {user | role | PUBLIC}' 。。。
REVOKE 命令将删除一个用户的所有的数据库权限 — — 无论是系统权限还是规则
SELECT
SELECT 'DISTINCT | ALL'
SELECT 语句是每一个获得数据的语句的开始 修正字 DISTINCT 可以指定让它返回
一个重复的数值 ALL 是默认的 返回全部数据
SET TRANSACTION
SQL》 SET TRANSACTION (READ ONLY | USE ROLLBACK SEGMENT);
SET TRANSACTION 可以让用户指定什么时候事务应该开始 READ ONLY 选项会
锁定一组记录集直到事务结束以确保在这一过程中数据没有被改变过
UNION
UNION
UNION 语句会返回两个SELECT语句中的所有元素
WHERE
WHERE
WHERE 语句限制返回的行必须满足指定的条件
*
* 可以代替一个表中的所有的列
503
…………………………………………………………Page 504……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
附件 B 在第 14 天中的 C++源代码清单
// tyssqvw。h : interface of the CTyssqlView class
//
/////////////////////////////////////////////////////////////////////////////
class CTyssqlSet;
class CTyssqlView : public CRecordView
{
protected: // create from serialization only
CTyssqlView();
DECLARE_DYNCREATE(CTyssqlView)
public:
//{{AFX_DATA(CTyssqlView)
enum { IDD = IDD_TYSSQL_FORM };
CTyssqlSet* m_pSet;
//}}AFX_DATA
// Attributes
public:
CTyssqlDoc* GetDocument();
// Operations
public:
virtual CRecordset* OnGetRecordset();
// Implementation
public:
virtual ~CTyssqlView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
504
…………………………………………………………Page 505……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
protected:
virtual void DoDataExchange(CDataExchange* pDX);// DDX/DDV support
virtual void OnInitialUpdate(); // called first time after construct
// Generated message map functions
protected:
//{{AFX_MSG(CTyssqlView)
// NOTE the ClassWizard will add and remove member functions here。
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in tyssqvw。cpp
inline CTyssqlDoc* CTyssqlView::GetDocument()
{ return (CTyssqlDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
// tyssql。h : main header file for the TYSSQL application
//
#ifndef __AFXWIN_H__
#error include 'stdafx。h' before including this file for PCH
#endif
#include 〃resource。h〃 // main symbols
/////////////////////////////////////////////////////////////////////////////
// CTyssqlApp:
// See tyssql。cpp for the implementation of this class
//
class CTyssqlApp : public CWinApp
{
public:
CTyssqlApp();
505
…………………………………………………………Page 506……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
// Overrides
virtual BOOL InitInstance();
// Implementation
//{{AFX_MSG(CTyssqlApp)
afx_msg void OnAppAbout();
// NOTE the ClassWizard will add and remove member functions here。
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// tyssqset。h : interface of the CTyssqlSet class
//
/////////////////////////////////////////////////////////////////////////////
class CTyssqlSet : public CRecordset
{
DECLARE_DYNAMIC(CTyssqlSet)
public:
CTyssqlSet(CDatabase* pDatabase = NULL);
// Field/Param Data
//{{AFX_FIELD(CTyssqlSet; CRecordset)
CString m_NAME;
CString m_ADDRESS;
CString m_STATE;
CString m_ZIP;
CString m_PHONE;
CString m_REMARKS;
//}}AFX_FIELD
// Implementation
protected:
506
…………………………………………………………Page 507……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
virtual CString GetDefaultConnect(); // Default connection string
virtual CString GetDefaultSQL(); // default SQL for Recordset
virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support
};
// tyssqdoc。h : interface of the CTyssqlDoc class
//
/////////////////////////////////////////////////////////////////////////////
class CTyssqlDoc : public CDocument
{
protected: // create from serialization only
CTyssqlDoc();
DECLARE_DYNCREATE(CTyssqlDoc)
// Attributes
public:
CTyssqlSet m_tyssqlSet;
// Operations
public:
// Implementation
public:
virtual ~CTyssqlDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
virtual BOOL OnNewDocument();
// Generated message map functions
protected:
//{{AFX_MSG(CTyssqlDoc)
// NOTE the ClassWizard will add and remove member functions here。
507
…………………………………………………………Page 508……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// stdafx。h : include file for standard system include files;
// or project specific include files that are used frequently; but
// are changed infrequently
//
#include // MFC core and standard ponents
#include // MFC extensions (including VB)
#include // MFC database classes
////////////////////////////////////////////////////////////
//{{NO_DEPENDENCIES}}
// App Studio generated include file。
// Used by TYSSQL。RC
//
#define IDR_MAINFRAME 2
#define IDD_ABOUTBOX 100
#define IDD_TYSSQL_FORM 101
#define IDP_FAILED_OPEN_DATABASE 103
#define IDC_NAME 1000
#define IDC_ADDRESS 1001
#define IDC_STATE 1002
#define IDC_ZIP 1003
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
508
…………………………………………………………Page 509……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
#define _APS_NEXT_MAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
///////////////////////////////////////////////////
// mainfrm。h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
509
…………………………………………………………Page 510……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE the ClassWizard will add and remove member functions here。
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// tyssqvw。cpp : implementation of the CTyssqlView class
//
#include 〃stdafx。h〃
#include 〃tyssql。h〃
#include 〃tyssqset。h〃
#include 〃tyssqdoc。h〃
#include 〃tyssqvw。h〃
#ifdef _DEBUG
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部!
温馨提示: 温看小说的同时发表评论,说出自己的看法和其它小伙伴们分享也不错哦!发表书评还可以获得积分和经验奖励,认真写原创书评 被采纳为精评可以获得大量金币、积分和经验奖励哦!