sql语句实例学习汇总(编辑修改稿)内容摘要:
个数据库表 DROP TABLE 从数据库中删除表 ALTER TABLE 修改数据库表结构 10 CREATE VIEW 创建一个视图 DROP VIEW 从数据库中删除视图 CREATE INDEX 为数据库表创建一个索引 DROP INDEX 从数据库中删除索引 CREATE PROCEDURE 创建一个存储过程 DROP PROCEDURE 从数据库中删除存储过程 CREATE TRIGGER 创建一个触发器 DROP TRIGGER 从数据库中删除触发器 CREATE SCHEMA 向数据库添加一个新模式 DROP SCHEMA 从数据库中删除一个模式 CREATE DOMAIN 创建一个数据值域 ALTER DOMAIN 改变域定义 DROP DOMAIN 从数据库中删除一个域 数据控制 GRANT 授予用户访问权限 DENY 拒绝用户访问 REVOKE 解除用户访问权限 事务控制 COMMIT 结束当前事务 ROLLBACK 中止当前事务 SET TRANSACTION 定义当前事务数据访问特征 程序化 SQL DECLARE 为查询设定游标 EXPLAN 为查询描述数据访问计划 11 OPEN 检索查询结果打开一个游标 FETCH 检索一行查询结果 CLOSE 关闭游标 PREPARE 为动态执行准备 SQL 语句 EXECUTE 动态地执行 SQL 语句 DESCRIBE 描述准备好的查询 局部变量 declare @id char(10) set @id = 39。 1001000139。 select @id = 39。 1001000139。 全局变量 必须以 @@开头 IF ELSE 以下是引用片段: declare @x int @y int @z int select @x = 1 @y = 2 @z=3 if @x @y print 39。 x y39。 打印字符串 39。 x y39。 else if @y @z print 39。 y z39。 else print 39。 z y39。 CASE 以下是引用片段: use pangu update employee set e_wage = case when job_level = ’1’ then e_wage* when job_level = ’2’ then e_wage* when job_level = ’3’ then e_wage* 12 else e_wage* end WHILE CONTINUE BREAK 以下 是引用片段: declare @x int @y int @c int select @x = 1 @y=1 while @x 3 begin print @x 打印变量 x 的值 while @y 3 begin select @c = 100*@x + @y print @c 打印变量 c 的值 select @y = @y + 1 end select @x = @x + 1 select @y = 1 end WAITFOR 例 等待 1 小时 2 分零 3 秒后才执行 SELECT 语句 以下是引用片段: waitfor delay ’01:02:03’ select * from employee 例 等到晚上 11 点零 8 分后才执行 SELECT 语句 以下是引用片段: waitfor time ’23:08:00’ select * from employee ***SELECT*** 以下是引用片段: select *(列名 ) from table_name(表名 ) where column_name operator value ex:(宿主 ) select * from stock_information where stockid = str(nid) 13 stockname = 39。 str_name39。 stockname like 39。 % find this %39。 stockname like 39。 [azAZ]%39。 ([]指定值的范围 ) stockname like 39。 [^FM]%39。 (^排除指定范围 ) 只能在使用 like 关键字的 where 子句中使用通配符 ) or stockpath = 39。 stock_path39。 or stocknumber 1000 and stockindex = 24 not stock*** = 39。 man39。 stocknumber between 20 and 100 stocknumber in(10,20,30) order by stockid desc(asc) 排序, desc降序, asc升序 order by 1,2 by 列号 stockname = (select stockname from stock_information where stockid = 4) 子查询 除非能确保内层 select 只返回一个行的值, 否则应在外层 where 子句中用一个 in 限定符 以下是引用片段: select distinct column_name form table_name distinct指定检索独有的列值,不重复 select stocknumber ,stocknumber + 10 = stocknumber + 10 from table_name select stockname , stocknumber = count(*) from table_name group by stockname group by 将表按行分组 ,指定列中有相同的 值 以下是引用片段: having count(*) = 2 having 选定指定的组 select * from table1, table2 where *= 左外部连接, table1 中有的而 table2 中没有得以 null 表示 =* 右外部连接 select stockname from table1 union [all] union 合并查询结果集, all保留重复行 14 select stockname from table2 ***insert*** 以下是引用片段: insert into table_name (Stock_name,Stock_number) value (xxx,xxxx) value (select Stockname , Stocknumber from Stock_table2)value为 select 语句 ***update*** 以下是引用片段: update table_name set Stockname = xxx [where Stockid = 3] Stockname = default Stockname = null Stocknumber = Stockname + 4 ***delete*** 以下是引用片段: delete from table_name where Stockid = 3 truncate table_name 删除表中所有行,仍保持表的完整性 drop table table_name 完全删除表 ***alter table*** 修改 数据库 表结构 以下是引用片段: alter table add column_name char(2) null ..... sp_help table_name 显示表已有特征 create table table_name (name char(20), age smallint, lname varchar(30)) insert into table_name select ......... 实现删除列的方法(创建新表 ) alter table table_name drop constraint Stockname_default 删除 Stockname 的 default 约束 ***function(/*常用函数 */)*** 统计函数。sql语句实例学习汇总(编辑修改稿)
相关推荐
与快速发展的不适应,并逐步成为制约电信企业参与全球化竞争的主要因素。 ERP、管理和组织模式的改革创新以及企业特色人文环境的建设是实施企业发展战略应考虑的焦点问题。 中国电信现有的基础设施不能为用 户提供特色服务。 中国电信虽然拥有比较完善的网络基础设施,但这大都不是根据市场的实际需要建设的,而是为了满足普遍服务的需要。 拆分让中国电信由主体电信企业降级到一个区域性的电信企业。
then it dawned upon him that miracles were possible even with matches. He stretched out a hand. “Let ther be a match in that hand,” he said. He felt some light object fall across his palm, and his
n chains, lakes and plains D) rivers, lakes and plains 60. From the passage we know that________. A) New Zealand has a very short coastline B) earthquakes have greatly influenced North Island39。 s
择出来,再去进行分页处理,那么就会多多的浪费掉许多的系统处理时间。 为了能够把效率提高,所以现在我们就只选择我们需要的数据,减少数据库的处理时间,以下就是常用 SQL 分页处理: SQL Server、 Access数据库 这都微软的数据库,都是一家人,基本的操作都是差不多,常采用如下分页语句: PAGESIZE:每页显示的记录数 CURRENTPAGE:当前页号 数据表的名字是:
nder: TObject)。 begin := crHourglass。 try { First, disable the TTable object. } if then。 { Open the selected table } with ListBox1 do := [ItemIndex]。 with ListBox2 do := [ItemIndex]。 { Open the table
(A) ID=49 这类注入的参数是数字型, SQL语句原貌大致如下: Select * from 表名 where 字段 =49 注入的参数为 ID=49 And [查询条件 ],即是生成语句: Select * from 表名 where 字段 =49 And [查询条件 ] (B) Class=连续剧 这类注入的参数是字符型, SQL语句原貌大致概如下: Select * from 表名