表的一个字段varchar类型,select * from a where f1var(传入参数)f1比如为"AA,BGF,YH",var为"BGF,YH,AA".也就是说相同的值,只是排列顺序不同.怎么写个简单函数来判断相等?当然可以SUBSTRING()一个一个取来判断,显得比较麻烦. --创建用户定义函数create f…
SQL Server 2005相对于SQL Server 2000改进很大,有些还是非常实用的。
举几个例子来简单说明 这些例子我引用了Northwind库。
1. TOP 表达式 SQL Server 2000的TOP是个固定值,是不是觉得不爽,现在改进了,可以使用表达式。 --前…
总结了一些有代表性的贴子,具体见http://expert.csdn.net/Expert/topic/2440/2440306.xml?temp.6941645
1: 列转为行:eg1:Create table test (name char(10),km char(10),cj int)goinsert test values(张三,语文,80)insert test values(张三,数学,86)insert test …
create table #TemTable(ids int)
alter table #TemTable add a int 修改表结构
insert into #TemTable --这句插入的时候会出现问题 select 1,1 这样会出错,以前一直不理解,现在知道了,不管是临时表,还是实体表&…
原文地址为:
Can not issue data manipulation statements with executeQuery()错误解决强烈建议:尽信书,不如无书!!! 下午没事,就练习了下连接数据库,结果发现了一个问题ÿ…
有表內容﹕
編號 內容
A abc
A aaa
A dddd
B 1223
B fkdjfd
....
實現結果﹕A abc,aaa,ddddB 1223,fkdjfd要求用一條SQL實現﹐如﹕select sum(內容) from table group by 編號--该问题,写一个合并函数,后,分组合并既可!--测试数据create Table …
C# 字符串相似度的算法(用sqlserver函数实现)CREATE function get_semblance_By_2words ( word1 varchar(50), word2 varchar(50) ) returns nvarchar(4000) as begin declare re int declare maxLenth int declare i int,l int declare tb1 table(c…
create trigger trInsertTest on InsertTest --取代插入操作的触发器instead of insertasif rowcount0return
select * into #t from(select * from InsertTestunion select * from inserted) a
truncate table InsertTest
insert into InsertTestselect * from #t
--…
一简单的复制
复制表1中id,r_p,r_p1,r_p2,r_p3,r_p4到表2的r_id,x_p,x_p1,x_p2,x_p3中,x_id为以固定值(1)。主要是方便从某表初始化某些值insert into 表2(x_id,r_id,x_p,x_p1,x_p2,x_p3)select 1,id,r_p,r_p1,r_p2,r_p3 from 表1
二所有表数据一起复制(一个数据…
在初始化数据库数据时,遇到了插入特殊字符‘&’的问题,例如有一菜单表:id,name,url。插入数据:insert into MENU values(1,产品类型,/productType.do?methodlist&type01);由于有特殊字符&&…
1.删除用户下的所有内容:drop user xxx cascade; 2.删除表空间:drop tablespace AA including contents; 3.查看当前用户默认表空间:select * from user_users 4.查看、修改表空间大小:select * from dba_data_files where…
本文实例,运行于 MySQL 5.0 及以上版本。 MySQL 赋予用户权限命令的简单格式可概括为:
grant 权限 on 数据库对象 to 用户一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
grant select on testdb.* to comm…
1.启动数据库db2start2.停止数据库db2stop3.连接数据库db2 connect to o_yd user db2 using pwd4.读数据库管理程序配置db2 get dbm cfg5.写数据库管理程序配置db2 update dbm cfg using 参数名 参数值6.读…
因为农历的日期,是由天文学家推算出来的,到现在只有到2049年的,以后的有了还可以加入!
CREATE TABLE SolarData
(
yearId int not null,
data char(7) not null,
dataInt int not null
)
--插入数据
INSERT INTO
SolarData SELEC…
sqlite数据库只用一个文件就ok,小巧方便,所以是一个非常不错的嵌入式数据库,SQLite大量的被用于手机,PDA,MP3播放器以及机顶盒设备。 Mozilla Firefox使用SQLite作为数据库。 Mac计算机中的包含了多份SQLite的…
这是一个有关于最小堆的算法源码。
/**Heap.h*/#include<iostream>using namespace std;template<class T>class Heap{private:T * heap; //Point to the heap arrayint size; //Maxsize of the Heapint n; //Number of element in the heapvo…
将所有死锁的死锁的
id找出来,然后再kill。
SET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS OFF GO
create procedure sp_who_lockasbegindeclare spid int,bl int,intTransactionCountOnEntry int,intRowcount int,intCountProperties int,intCounter int
create …
如果只是查用户表有哪些直接查系统表就可以了/*獲取用戶表信息游標*/
SET NOCOUNT ON
DECLARE find_user_table CURSOR
FOR
SELECT [name],crdate FROM sysobjects
WHERE typeU /*這裡只查詢用戶定義的表*/
ORDER BY [name]DECLARE cName VARCHAR(128) /*定義儲存表名變量*/
DE…
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22828 Accepted: 9949 题目链接:http://poj.org/problem?id2352
Description
Astronomers often examine star maps wherestars are represented by points on a plane and each star has…
原贴地址:http://community.csdn.net/Expert/topic/3798/3798231.xml?temp.9782984在SQLServer中建了一个Link(nameXXLink)把相应数据导入倒Oracle数据库中,具体INSERT语句如下:INSERT INTO openquery(XXLink,SELECT col1,col2,col3 FROM Ta…
--生成测试数据CREATE TABLE T_TABLE(id int IDENTITY(1,1) NOT NULL,upid int NULL,title [varchar](50))
INSERT INTO T_TABLE (upid,title) values(0,1TITLE)INSERT INTO T_TABLE (upid,title) values(0,2TITLE)INSERT INTO T_TABLE (upid,title) values(0,3TITLE)INSERT I…
当 IDENTITY_INSERT 设置为 OFF 时,不能向表 txl_info 中的标识列插入显式值。
出现这个异常的原因就是向自动增长的列插入了值.
it just means you have a column in files table that is an identity column (whose value is supposed to be generated by the d…
情景:批量插入。 附件条件:传入多个参数。 代码: CREATE PROCEDURE batInsertRuiLinkDesc(in versions VARCHAR(4000), in ruidescIds VARCHAR(4000), in versionLength INTEGER, in ruidescIdLength INTEGER)
BEGINDECLARE i int default 0;…
vim的学习曲线相当的大(参看各种文本编辑器的学习曲线),所以,如果你一开始看到的是一大堆VIM的命令分类,你一定会对这个编辑器失去兴趣的。下面的文章翻译自《Learn Vim Progressively》,我觉得这是给新手最…
(1)创建EXCEL文件c:/temp.xls(2)执行查询insert into OPENROWSET(Microsoft.Jet.OLEDB.4.0,Excel 5.0;HDRYES;DATABASEc:/temp.xls,sheet1$)select * from tablename
同样在sql server中查询excel的记录
select * from OPENROWSET(Microsoft.Jet.OLEDB.4.0,Excel 5.0;HDRYE…
--数据装载Create Table #T(Column1 varchar(20))insert #T select 040011union all select 010021union all select 024综合union all select 021不知道union all select 031不union all select 不3union all select 知道
--1:求包含数字,且长度为6的集合(包含了中文)
selec…
可以将 XML 文档大容量导入到 SQL Server 数据库中,也可以从 SQL Server 数据库中大容量导出 XML 文档。本主题提供了这两种情况的示例。 若要将数据从一个数据文件大容量导入 SQL Server 表或未分区视图,可以使用以下工具或命令: bcp 实用工…
如果能够得到存储过程结果集的表结构insert into #tmp exec sp_who
否则select * into #tmp from OPENROWSET(SQLOLEDB,SERVERserver;uidsa;pwdsapwd;Databasemaster,exec 存储过程名) as a 如果存储过程中用到临时表,要用set fmtonly offselect * into #tmp from …
oracle分页查询的时候,不能使用limit,所以只能这样 1. select * from table_name where rownum>begin and rownum< end 2.sql "select * from table" con.prepareCall("SELECT * FROM(SELECT A.…
创建操作日志字典 -------------------------------------------------------------Susue--------- 如表已存在,先删除--if exists(select 1 from sysobjects where nameS_LOG and XtypeU) drop table S_LOG ;go--------- 建新表和主键create table S_LOG ( P_ID int IDENTIT…
原贴地址:http://community.csdn.net/Expert/topic/3693/3693091.xml?temp.6086542http://community.csdn.net/Expert/TopicView.asp?id3724743测试tablecreate table table1 (id int,name char)insert into table1select 1,qunion all select 2,runion all select 3,3union …
Oracle 分析函数——CUBE , ROLLUP
CUBE
功能描述:
注意: ROLLUP
功能描述:
注意: 如果是 ROLLUP(A, B, C) 的话, GROUP BY 顺序
(A 、 B 、 C)
(A 、 B)
(A)
最后对全表进行 GROUP BY 操作。
如…
/*范例表create table 表1 ( 號數 char(10), 成績 integer, 科目 char(10) ) insert into 表1 select 1,60,数学 union select 1,43,物理 union select 1,100,语文 union select 2,87,语文 union select 2,99,数学 union select 2,89,物理 union select 2,87,语文 *…
GRANT 语句的语法如下:GRANT privileges (columns)ON whatTO user IDENTIFIEDBY "password"WITH GRANT OPTION对用户授权mysql>grant rights on database.* to userhost identified by "pass";例1:增加一个用户test1密码为abc,让…
if not exists (select * from dbo.sysobjects where id object_id(N[dbo].[tablespaceinfo]) and OBJECTPROPERTY(id, NIsUserTable) 1) create table tablespaceinfo --创建临时表 (nameinfo varchar(50) , --表名 rowsinfo int , --表中现有的行数 reserved varchar(20) ,…
一、原题 View the Exhibit and examine the structure of the CUSTOMERS table. NEW_CUSTOMERS is a new table with the columns CUST_ID, CUST_NAME and CUST_CITY that have the same data types and size as the corresponding columns in the CUSTOMERS table. Evaluat…
原文地址为:
Oracle:用一条 INSERT 语句批量插入多条记录用一条 INSERT 语句批量插入多条记录,实例如下: 先建立这样一个表 T: SQL> DESC T Name Null? Type ------------------------…
MicrosoftSQL Server 2008将包含用于合并两个行集(rowset)数据的新句法。根据一个源数据表对另一个数据表进行确定性的插入、更新和删除这样复杂的操作,运用新的MERGE语句,开发者只需使用一条命令就可以完成。
在对两个表进行信息同步时,有…
C STL set和multiset的使用1,set的含义是集合,它是一个有序的容器,里面的元素都是排序好的,支持插入,删除,查找等操作,就 像一个集合一样。所有的操作的都是严格在logn时间之内完成,…
格式:insert into ...... on conflict(column_name) do ......
例子:
uxdb# create table tbl_c (id int unique, name varchar(2));
CREATE TABLE
uxdb# insert into tbl_c values (1, a);
INSERT 0 1
uxdb# table tbl_c;id | name
----------1 | a
(1…
血一般的教训,请慎用insert into select。同事应用之后,导致公司损失了近10w元,最终被公司开除。 事情的起因
公司的交易量比较大,使用的数据库是mysql,每天的增量差不多在百万左右,公司并没有分库分表&am…
单列索引和组合索引 为了形象地对比两者,再建一个表: create table myindex ( i_testid int not null auto_increment, vc_name varchar(50) not null, vc_city varchar(50) not null, i_age int not null, i_schoolid int not null, primary key (i_tes…
Web 应用程序中,数据库的应用是不可缺少的,这也是 Web 应用程序开发的重头戏。 ASP 技术支持访问 Web 服务器数据库系统的对象模型 ADO(ActiveX Data Objects),它可以使页面开发人员轻松存取 Internet 数据。
10.1 Web 站点数据库应用概述 A…
转自:http://java.mblogger.cn/flowercat/
1、case表达式select country_name,region_id, case region_id when 1 then europe when 2 then america when 3then asia else other end continent from countries where country_name like I%;在9i中提供的case表达式&…
转自http://java.mblogger.cn/flowercat/1.删除表空间 DROP TABLESPACE TableSpaceName [INCLUDING CONTENTS [AND DATAFILES]]
2.删除用户 DROP USER User_Name CASCADE
3.删除表的注意事项 在删除一个表中的全部数据时ÿ…
假设如果我要更新数百万以上的数据, 我大概会选择不去’更新’ (UPDATE)吧. 我很有可能会用以下的方法: CREATE TABLE new_table as select <在此更新> from old_table; index new_table (给新的表创建索引) grant on new table (授权于新的表) add constraints on new…
如果用了insert /* append */ into table as select .. from table 这样的操作来insert,必须在操作后commit,或是rollback,不然就不能再insert /* append */ into table as select .. from table 。ORACLE报出错误如下:ORA-12838: cannot read/modify an object aft…
目的:mybatis 循环插入多条数据
dao
void savaUploadImgInfo(Param("albumList") List<Album> albumList);
mapper:
<insert id"savaUploadImgInfo" parameterType"java.util.List">insert into album va…
ORACLE函数大全(整理转帖修改) SQL中的单记录函数1.ASCII返回与指定的字符对应的十进制数;SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dual; A A ZERO SPACE--------- --------- --------- ---------65 97 48 322.CHR给出整数,返回对应的字符;SQ…
MYSQL 的事务处理主要有两种方法。 1 、用 begin,rollback,commit 来实现 begin 开始一个事务 rollback 事务回滚 commit 事务确认 2 、直接用 set 来改变 mysql 的自动提交模式 MYSQL 默认是自动提交的,也就是你提交一个 QUERY ,它就直接执行&…
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: select id from t …
前段时间 写Oracle 的存储过程 遇到了很多问题 ,用存储过程 显示一个select * from table 就那么费劲吗?在Google和Baidu上找了好长时间,终于找到了正确答案。 Result Sets from Stored Procedures In Oracle A frequently asked question is: Id like …
void CTestDlg::ShowInfo(CString str, int code)
{m_ListInfo.InsertString(m_ListInfo.GetCount(),str);m_ListInfo.SetCurSel(m_ListInfo.GetCount()-1);
}如上所示: m_ListInfo为继承自CListBox的列表框: class CTestListBox : public CListBox
{
// Construction
public:C…
//--------------ORACLE 保存图片 grant create any directory to scott; grant create any library to scott; create or replace directory utllobdir as d:/oracle ; create table bfile_tab (bfile_column BFILE); create tab…
sql语句根据特定条件改变排序及效率测试 两个解决方案:
SELECT * FROM T_Admin
ORDER BY CASE WHEN admin_name loo THEN 0 ELSE 1 END
另外一种:
SELECT *, 0 AS tmp_o
FROM t_admin
WHERE admin_name loo
UNION
SELECT *, 1 AS tmp_o
FROM t_admin
…
插入(Insert)
1.简单形式
说明:new一个对象,使用InsertOnSubmit方法将其加入到对应的集合中,使用SubmitChanges()提交到数据库。
NorthwindDataContext db new NorthwindDataContext();var newCustomer new Customer{CustomerID "…
LINQ to SQL支持以下String方法。但是不同的是默认情况下System.String 方法区分大小写。而SQL则不区分大小写。
1.字符串串联(String Concatenation)
var q from c in db.Customersselect new{c.CustomerID,Location c.City ", " c.Country};
语句描述&#x…
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14190 Accepted: 5226 题目链接:http://poj.org/problem?id1035
Description
You, as a member of a development team for a new spellchecking program, are to write a module…
一、原题 View the Exhibit and examine the structure of ORDERS and CUSTOMERS tables. There is only one customer with the cust_last_name column having value Roberts. Which INSERT statement should be used to add a row into the ORDERS table for the customer …
001 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。 002 003 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: 004 …
对于codeigniter的增删改,在此我用自己的一个例子来说明一下: 创建数据库: CREATE TABLE IF NOT EXISTS users (id int(10) NOT NULL AUTO_INCREMENT,username varchar(50) NOT NULL,password varchar(50) NOT NULL,email varchar(100) NOT N…
http://www.sdau.edu.cn/support/mysq_doc/manual_Clients.html#C 20 MySQL客户工具和API
20.1 MySQL C API
C API代码是随MySQL分发的,它被包含在mysqlclient库且允许C程序存取一个数据库。
在 MySQL源代码分发中的很多客户是用C编写的。如果你正在寻找演示怎样…
Eclipse快捷键 Menus
F10 Main menu
Shift F10 Context menu
Ctrl F10 View menu
Alt - Active views menu Workspace navigation
F12 Activate editor
Ctrl Shift W Switch editor
Ctrl F6 Next editor
Ctrl Shift F6 Prev editor
Ctrl F7 Next workspace
Ctrl Shif…
oracle 手工创建Scott用户
1.登录数据库 sqlplus / as sysdba
2.创建scott用户 create user scott identified by tiger; 3.为scott用户分配权限 grant connect,resource to scott; 4.用scott用户登录 conn scott/tiger 5.执行demobld.sql脚本,脚本内容是…
(一)
1、使用JdbcTemplate的execute()方法执行SQL语句 Java代码 jdbcTemplate.execute("CREATE TABLE USER (user_id integer, name varchar(100))"); jdbcTemplate.execute("CREATE TABLE USER (user_id integer, name varchar(100))…
一、原题 Examine the structure of the EMPLOYEES table:You want to create a SQL script file that contains an INSERT statement. When the script is run,the INSERT statement should insert a row with the specified values into the EMPLOYEES table.The INSERT sta…
一、原题 View the Exhibit and examine the structure of the CUSTOMERS table. NEW_CUSTOMERS is a new table with the columns CUST_ID, CUST_NAME and CUST_CITY that have the same data types and size as the corresponding columns in the CUSTOMERS table. Evaluat…
转自:http://www.cnblogs.com/welkinwalker/archive/2010/05/11/1732622.html 几句话道出map和hash_map的区别 1. STL map is an associative array where keys are stored in sorted order using balanced trees. While hash_map is a hashed associated container…
REPORT ZPROG.parameters:l_prg(60).TYPES text(255) TYPE c.DATA: text_tab TYPE TABLE OF text.READ REPORT l_prg INTO text_tab.if sy-subrc 0. EDITOR-CALL FOR text_tab. if sy-subrc 0. INSERT REPORT l_prg FROM text_tab. endif.endif.
(0)目录 走,是一辈子,不走,也是一辈子(程序猿之路) Navicat连接mysql出现2003——cant connect to mysql server on localhost(10061) mysql 数据库导入导出方法总结(是时候总结) 1࿱…