search
HomeDatabaseMysql Tutorial 事物索引视图

虽然学过SQLServer,但是在脑海里总是觉得很乱,并且有很多疑问和盲点,如今走入工作岗位,那么这些关于自己知识和技术的漏洞是不应该存在了,至少学一种语言或是技术,最起码要知道是什么、做什么、有什么用、什么时候用、怎么用。如果连这一点都不是很清楚

虽然学过SQLServer,但是在脑海里总是觉得很乱,并且有很多疑问和盲点,如今走入工作岗位,那么这些关于自己知识和技术的漏洞是不应该存在了,至少学一种语言或是技术,最起码要知道是什么、做什么、有什么用、什么时候用、怎么用。如果连这一点都不是很清楚的话那么我不敢相信你做出来的东西有多好,香港服务器,有多强。以前在学习的时候,总觉得这些理论知识,自己知道就行了,不必太在意,会操作,能使用就行了,可是如今我不这么认为了,可能这些很基础的理论知识学起来很抽象,很枯燥,但是他们真的很有用。作为一名技术人员,没有清晰透彻的理论作为基础,那么在技术这条道路上是走不远,飞不高的。。。最近我在业余时间抽空复习自己所学的东西,找到一些不错的资料,在此分享给正在学习中的朋友们,我相信这些资源对你们的学习是很有用的。好了,废话有点多了,咱们开始吧。声明:一下内容是我转载的一些内容,稍作些许加工,以下有地址来源。。。 SQL教程: 事务

我们知道各种子查询的用法,包括简单子查询、IN子查询和EXISTS子查询。除此之外,我们在实际开发中还会用到一些比较特殊的高级查询,包括事务、索引和视图。

例如,银行转账问题:假定资金从账户A转到账户B,至少需要两步,网站空间,即账户A的资金减少,然后账户B的资金相应增加。在进行资金转账时,系统必须保证:这些步骤是一个整体,如果其间任一步骤失败,则将撤销对这两个账户数据所做的任何修改,这时就需要使用事务处理。事务是指一个工作单元,该单元可以包含多个步骤来完成所需的任务。一个事务作为一个整体,要么成功,要么失败。

正如汉语字典中的汉字按页存放一样,SQL Server中的数据记录也是按页存放的,每页容量一般为4KB。为了加快查找的速度,汉语字(词)典一般都有按拼音、笔画、偏旁部首等排序的目录(索引),我们可以选择按拼音或笔画查找,快速查找到需要的字(词)。同理,SQL Server允许用户在表中创建索引,指定按某列预先排序,从而大大提高查询速度。

同一星球,用望远镜从不同的角度或方位观看,将看到星球的不同位置,从而得到不同的结果。同一张员工信息表数据,因为公司保密的原因,可能要求不同权限的人员看到不同的员工信息。例如:财务人员只能查看员工的姓名、工资、奖金等;技术部经理只能查看员工的姓名,职称、技能等;人事部经理只能查看员工的姓名、工作经历和发展方向等;总经理当然可以全部查看。如何更加安全、直观地显示数据结果呢?SQL Server中允许用户创建视图,在同一原始数据表的基础上,为不同的用户选择不同的列,从而达到不同用户的需求。

下面我们将详细讨论事务、索引和视图的具体使用。

事务(Transaction)是单个的工作单元。如果某一事务成功,则在该事务中进行的所有数据更改均会提交,香港虚拟主机,成为数据库中的永久组成部分。如果事务遇到错误且必须取消或回滚,则所有数据更改均被清除。

一、为什么需要事务

一般来说,只要是同一银行(例如都是农行),一般都支持账户间直接转账。我们来看看上述提及的转账问题,假定张三的账户直接转账1000元到李四的账户,就需要创建账户表,存放用户的账户信息,T-SQL语句如示例1

/* stuDB (sysobjects ) DROP TABLE bank bank ( customerName CHAR(10), --顾客姓名 currentMoney ) bank ) bank(customerName,currentMoney) ,1000) ,1) bank --customerNamebank customerName bank GO

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

MySQL: How to Add a User RemotelyMySQL: How to Add a User RemotelyMay 12, 2025 am 12:10 AM

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

The Ultimate Guide to MySQL String Data Types: Efficient Data StorageThe Ultimate Guide to MySQL String Data Types: Efficient Data StorageMay 12, 2025 am 12:05 AM

TostorestringsefficientlyinMySQL,choosetherightdatatypebasedonyourneeds:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseTEXTforlong-formtextcontent.4)UseBLOBforbinarydatalikeimages.Considerstorageov

MySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMay 11, 2025 am 12:13 AM

When selecting MySQL's BLOB and TEXT data types, BLOB is suitable for storing binary data, and TEXT is suitable for storing text data. 1) BLOB is suitable for binary data such as pictures and audio, 2) TEXT is suitable for text data such as articles and comments. When choosing, data properties and performance optimization must be considered.

MySQL: Should I use root user for my product?MySQL: Should I use root user for my product?May 11, 2025 am 12:11 AM

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQL String Data Types Explained: Choosing the Right Type for Your DataMySQL String Data Types Explained: Choosing the Right Type for Your DataMay 11, 2025 am 12:10 AM

MySQLstringdatatypesshouldbechosenbasedondatacharacteristicsandusecases:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseBINARYorVARBINARYforbinarydatalikecryptographickeys.4)UseBLOBorTEXTforlargeuns

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version