Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sqlÓï¾ä²éѯ±íµÄ×Ö¶ÎÃû

select name from syscolumns where id in (select id from sysobjects where type = 'u' and name = 'ÏàÓ¦±íÃû')  
ÓÃÒÔÉÏsqlÓï¾äÊäÈëÏàÓ¦±íÃû¾Í¿ÉÒԲ鵽±íµÄ×Ö¶ÎÃû£¬¶ÔÓ¦ºÃÊý¾Ý¿â ²éѯÊÇ·ñ´æÔڸñíÓï¾ä
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tb_cost]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tb_cost]
GO
´´±íÓï¾ä
CREATE TABLE [dbo].[tb_cost] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[inputtime] [datetime] NOT NULL ,
[pushcount] [int] NOT NULL ,
[revertcount] [int] NOT NULL ,
[revertrate] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[unitprice] [float] NOT NULL ,
[cost] [float] NOT NULL ,
[income] [float] NOT NULL ,
[rate] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[pushinfor] [varchar] (8000) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
½¨Ë÷Òý½Å±¾£º
create clustered index Ë÷ÒýÃû on ±íÃû(±í.×Ö¶Î)
ÔÚ±íÔö¼ÓÒ»¸ö×ֶΣ¬ÀýÈçfa×Ö¶Î
alter table ±íÃû add fa int not null default 0
Ñ¡ÔñÇ°Ãæ m-n ÌõÊý¾ÝµÄÓï¾ä
ÀýÈçÑ¡ÔñÇ°ÃæµÚ 5-10£¨m=10£¬n=5£© Ìõ¼Ç¼µÄsqlÓï¾äÈçÏ£º
sql="select top 6 * from table where (id not in (select top 4 id from table order by id desc)) order by id desc"
ÆäÖÐ6£¬4 ÊÇÕâÑùµÃÀ´µÄ
sql="select top m-n+1 * from table where (id not  in (select top n-1 id from table))


Ïà¹ØÎĵµ£º

¾«ÃîSQLÓï¾äѧϰ

SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname ......

SQL¹ØÓÚÁ½±í¹ØÁªµÄupdate

¹ØÓÚÁ½±í¹ØÁªµÄupdate£¬µ«Óï¾äÔõôд¶¼²»ÕýÈ·£¬ÀÏÊDZ¨´í£¬ÓÚÊÇÐľªÈâÌø£¨¾ÍŲ»Äܼ°Ê±Íê³É²Ù×÷£©È¥²éÁËһϣ¬NND£¬Ô­À´°ÑSQLд³ÉÁËÔÚSQL ServerÏÂÃæµÄÌØÓÐÐÎʽ£¬ÕâÖÖÓï·¨ÔÚOracleÏÂÃæÊÇÐв»Í¨µÄ£¬¼±Ã¦¸Ä»ØÀ´£¬¼°Ê±Íê³ÉÁËÈÎÎñ¡£Ë³±ãÒ²°Ñ²éµ½µÄSQLÌû³öÀ´£¬ÄÄÌìÔÙÍü¼ÇÁË£¬Ò²ºÃÔÚÕâÀïÕÒ»ØÀ´£º
   update customers a ......

SQL ServerºÍOracleµÄ³£Óú¯Êý¶Ô±È

---------Êýѧº¯Êý
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.È¡Õû£¨½ØÈ¡£©
S:select cast(-1.002 as int) v ......

SQL¼¶Áª¸üкͼ¶ÁªÉ¾³ý

alter table ±íÃû
add constraint Ô¼ÊøÃû
foreign key(×Ö¶ÎÃû) references Ö÷±íÃû(×Ö¶ÎÃû)
on delete cascade
Óï·¨£º
Foreign Key
(column[,...n])
references referenced_table_name[(ref_column[,...n])]
[on delete cascade]
[on update cascade]
×¢ÊÍ£º
column:ÁÐÃû
referenced_table_name:Íâ¼ü²Î¿¼µÄÖ÷¼ü± ......

java½«excelµ¥Ôª¸ñÊý¾Ýת»»³ÉsqlÓï¾ä

Ê×ÏÈÒªÓÐjxlÀà¿â¡£
³ÌÐòÈçÏ£º
import java.io.*;
import jxl.*;
public class ExcelToSql {
  public static void main(String args[])
  {
   try
   {
    Workbook book= Workbook.getWorkbook(new File("D:\\workspaceuse6\\foundation\\test\\com\\gres ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ