SQL Server: SQL queries compared to general programming

血红的双手。 提交于 2019-12-25 02:48:08

问题


I'm just starting out with SQL Server 2008 Express and spent the last hour or so trying out some basic queries. How does SQL scripting (correct term?) compare to general computer programming? Is writing SQL queries as involved, lengthy to learn, needs as much practice, etc. as software development? Is writing advanced SQL queries comparable to software development, at least to some degree, and if so could you explain that?

Also, I found a couple of tutorial and reference sites for learning SQL but could you also recommend some other sites.

Also(2), I was playing around with the SQL query designer in SQL Server and it seems like a good tool to learn writing SQL commands, but is there a way to use the designer to INSERT data. it seems that it's only for SELECT ing data.

Any other general comments for learning, better understanding, etc SQL would be appreciated. thanks


回答1:


SQL is a declarative language and it primarily deals with sets.

As such it it very different from procedural languages.

I would say it is somewhere between procedural languages and functional languages in terms of style.

I would recommend Joe Celko's books, this one by Hernandez, and this one by Bowman.

In SSMS, you can paste data into a table (usually from Excel).

Typically no users enter data through SSMS, usually loading data using a tool like SSIS.

You can INSERT data using INSERT INTO tbl VALUES (x, y, z), and SQL Server 2008 has a multi-row insertion ability through row constructors: INSERT INTO tbl VALUES (x, y, z), (a, b, c)




回答2:


Cade's answer is good. I'd like to add that (advanced) SQL is a slightly different mindset - one where you play with sets, indeed (check out mathematics manuals for the basics, if you like). It's possible to generate really advanced SQL queries, resulting in very complex sets, but often you'll find you'll want a stored procedure at some point (even if just for legibility). Once you're at that point, it becomes much more like traditional programming.



来源:https://stackoverflow.com/questions/3305402/sql-server-sql-queries-compared-to-general-programming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!