1. 获取取数据库服务器上所有数据库的名字 SELECT name FROM master.dbo.sysdatabases 2. 获取取数据库服务器上所有非系统数据库的名字 SELECT [name] FROM master.dbo.sysdatabases ORDER BY [Name] 3. 获取数据库下所有的表名 SELECT name from sys.tables 4. 获取表结构(字段名,属性) SELECT C.name as [字段名],T.name as [字段类型] ,c
example1: select * from users where username='$username' and password='$password' test data: $username = 1' or '1'='1 $password=1' or '1'='1 select * from users where username='1' or '1'='1' and password='1' or '1'='1' 如果参数值是GET方法传递到服务器,则访问请求是: http:
1.数据库压缩日志 GO ALTER DATABASE website SET RECOVERY SIMPLE;--设置简单恢复模式 GO DBCC SHRINKFILE (website_Log, 1); GO ALTER DATABASE website SET RECOVERY FULL;--恢复为原模式 GO 2.重建所有索引 exec sp_msforeachtable 'DBCC DBREINDEX(''?'')'
1.批量导入 INSERT INTO Table2(field1,field2,...) SELECT value1,value2,... FROMTable1 要求目标表Table2必须存在 2.批量导入 SELECT vale1, value2 INTO Table2 FROM Table1 要求目标表Table2不存在,因为在插入时会自动创建表Table2,并将Table1中指定字段数据复制到Table2中 3.去重并保留一项 DELETE FROM tableName WHERE Id
查看各表的数据行数 SELECT o.name, i. ROWS FROM sysobjects o, sysindexes i WHERE o.id = i.id AND o.Xtype = 'U' AND i.indid < 2 ORDER BY o.name; 计算数据库中各个表每行记录所占用空间 --SELECT * FROM Employees AS e; CREATE TABLE #tablespaceinfo ( nameinfo VARCHAR(50) , rowsinfo BI