Welcome to Sign in | Help
in Search

Select into vs Insert

Last post 09-17-2009, 6:38 PM by tebbaerty. 4 replies.
Sort Posts: Previous Next
  •  07-20-2009, 11:06 AM 7408

    Select into vs Insert

    Salut,

    Care este mai rapid pentru a selecta datele dintr-o tabela in alta tabela

    insert into TB1 (col1 , col2..) select (col1,col2...) from TB2 join TB3 .....

    Select col1,col2 ... into TB1 from TB2 join TB3 ....

    Create table TB 1 as Select col1,col2... from TB2 join TB3 ....


    banuiesc ca nu e una si aceeasi chestie.

    Din ce am cautat eu am gasit ca select into este mai rapid deoarece nu mai logheaza totul.
  •  09-07-2009, 12:05 PM 7573 in reply to 7408

    Re: Select into vs Insert

     Nu ma poate ajuta nimeni cu un raspuns sau o parere ? multumesc.
  •  09-07-2009, 7:59 PM 7574 in reply to 7573

    Re: Select into vs Insert

    Acuma si tu Smile
    Ca parere cred ca select into e dar mai dureaza sa gasesc unde am vazut asta....
    Ca memeoria si parerile mele Smile
  •  09-08-2009, 7:35 PM 7577 in reply to 7408

    Re: Select into vs Insert

    Vezi:
    http://msdn.microsoft.com/en-us/library/ms191244.aspx
    şi http://www.sqlmag.com/Articles/ArticleID/102462/102462.html (dacă aveţi abonament la SQL Server Magazine).

    În esenţă, în SQL Server 2005, INSERT INTO era totdeauna fully logged, însă SELECT INTO putea fi minimally logged (atunci când se foloseşte Bulk Logged Recovery Model). În SQL Server 2008, şi INSERT INTO poate fi minimally logged, cu anumite condiţii suplimentare (TABLOCK, tabelă goală, fără indecşi, etc).

    Răzvan

    PS. Chestia cu "CREATE TABLE tabela AS SELECT ... FROM ..." nu există în SQL Server (ci doar în Oracle şi MySQL, cred). În SQL Server există doar "INSERT INTO tabela SELECT ... FROM ..." sau "SELECT ... INTO tabela FROM ...".
  •  09-17-2009, 6:38 PM 7616 in reply to 7577

    Re: Select into vs Insert

    PS. Chestia cu "CREATE TABLE tabela AS SELECT ... FROM ..." nu există în SQL Server (ci doar în Oracle şi MySQL, cred). În SQL Server există doar "INSERT INTO tabela SELECT ... FROM ..." sau "SELECT ... INTO tabela FROM ...".


     da, greselea mea. Scuze.


    asa cum zice msdn

    The amount of logging for SELECT...INTO depends on the recovery model in effect for the database. Under the simple recovery model or bulk-logged recovery model, bulk operations are minimally logged. With minimal logging, using the SELECT… INTO statement can be more efficient than creating a table and then populating the table with an INSERT statement. For more information, see Operations That Can Be Minimally Logged.


    Multumesc,
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems