
sql="select * from zhang"rs.open sql,conn,1,1
If Not (rs.bof And rs.eof) Then '不为空时显示
do while not rs.eof%>'<%= rs("hao") %>',<% rs.movenext
loop
Else
response.write "没有数据"
End If
rs.close
'第二处,请注意橙色语法部分
sql="select * from zhangdan where hao='"&request("danhao")&"'"
rs.open sql,conn,1,3
If Not(rs.bof And rs.eof) Then '不为空时,表示有数据才能更新
if request("act")="mod" then
rs.update
End If
rs.close
用sql语句查询数据库,ms sql server
1、查询所有表
select [id], [name] from [sysobjects] where [type] = 'u' order by [name]
2、查询所有数据库
3、select [name] from [sysdatabases] order by [name]
查询表中字段
select [name] from [syscolumns] where [name] = 'tableXXX'order by [colid]
oracle
1、查找表的所有索引(包括索引名,类型,构成列):
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 要查询的表
2、查找表的主键(包括名称,构成列):
select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'P' and au.table_name = 要查询的表
3、查找表的唯一性约束(包括名称,构成列):
select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'U' and au.table_name = 要查询的表
4、查找表的外键(包括名称,引用表的表名和对应的键名,下面是分成多步查询):
select * from user_constraints c where c.constraint_type = 'R' and c.table_name = 要查询的表
查询外键约束的列名:
select * from user_cons_columns cl where cl.constraint_name = 外键名称
查询引用表的键的列名:
select * from user_cons_columns cl where cl.constraint_name = 外键引用表的键名
5、查询表的所有列及其属性
select t.*,c.COMMENTS from user_tab_columns t,user_col_comments c where t.table_name = c.table_name and t.column_name = c.column_name and t.table_name = 要查询的表
6、查询所有表
select* from tabs
方法/步骤
第一步,双击打开MySQL Workbench,新建一个数据库worker,设置数据库编码格式是utf-8,点击“Apply”,创建数据库编码
CREATE SCHEMA `worker` DEFAULT CHARACTER SET utf8
第二步,使用worker数据库,查看数据库表情况,可以使用show命令,如下图所示:
第三步,新建一张worker信息表,创建数据库表SQL语句具体如下:
create table t_worker_info(
id int(8) primary key,
worker_id int(6) not null,
worker_name varchar(20) not null,
worker_age int(2),
worker_sex varchar(2),
worker_addr varchar(100)
)
如下图所示:
第四步,数据库表t_worker_info建好了后,向表里插入一些数据,插入数据SQL语句
insert into t_worker_info (id,worker_id,worker_name,worker_age,worker_sex,worker_addr)
values (20150101,100,'zhangsan',34,'M','hubei')
如下图所示:
第五步,创建数据库查询存储过程query_procedure,具体实现如下图所示:
第六步,编写完了存储过程后,在查询窗口调用存储过程
call query_procedure(30,'M')
如下图所示:
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)