Search Results

Search found 31606 results on 1265 pages for 'generate table'.

Page 40/1265 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • Issue with creating index organized table

    - by mtim
    I'm having a weird problem with index organized table. I'm running Oracle 11g standard. i have a table src_table SQL> desc src_table; Name Null? Type --------------- -------- ---------------------------- ID NOT NULL NUMBER(16) HASH NOT NULL NUMBER(3) ........ SQL> select count(*) from src_table; COUNT(*) ---------- 21108244 now let's create another table and copy 2 columns from src_table set timing on SQL> create table dest_table(id number(16), hash number(20), type number(1)); Table created. Elapsed: 00:00:00.01 SQL> insert /*+ APPEND */ into dest_table (id,hash,type) select id, hash, 1 from src_table; 21108244 rows created. Elapsed: 00:00:15.25 SQL> ALTER TABLE dest_table ADD ( CONSTRAINT dest_table_pk PRIMARY KEY (HASH, id, TYPE)); Table altered. Elapsed: 00:01:17.35 It took Oracle < 2 min. now same exercise but with IOT table SQL> CREATE TABLE dest_table_iot ( id NUMBER(16) NOT NULL, hash NUMBER(20) NOT NULL, type NUMBER(1) NOT NULL, CONSTRAINT dest_table_iot_PK PRIMARY KEY (HASH, id, TYPE) ) ORGANIZATION INDEX; Table created. Elapsed: 00:00:00.03 SQL> INSERT /*+ APPEND */ INTO dest_table_iot (HASH,id,TYPE) SELECT HASH, id, 1 FROM src_table; "insert" into IOT takes 18 hours !!! I have tried it on 2 different instances of Oracle running on win and linux and got same results. What is going on here ? Why is it taking so long ?

    Read the article

  • Does Table.InsertOnSubmit create a copy of the original table?

    - by Bryan
    Using InsertOnSubmit seems to have some memory overhead. I have a System.Data.Linq.Table<User> table. When I do table.InsertOnSubmit(user) and then int count = table.Count(), the memory usage of my application increases by roughly the size of the User table, but the count is the number of items before user was inserted. So I'm guess an enumeration after InsertOnSubmit will create a copy of the table. Is that true?

    Read the article

  • hibernate modeling relationships managed through an intermediate table

    - by shikarishambu
    I have a datamodel that has an intermediate table to manage relationships between entities. For example, tables Person and Organization are related through the Relationship table Party (table) - ID Person (table) - ID (references Party.ID) - name Organization (table) -ID (references Party.ID) -name Relationship (table) -ID (PK) -type (references relationshiptype lookup) -fromID (references Party.ID) -ToID (references Party.ID) -fromDate -ToDate Type+fromID+ToID+fromDate+ToDate is guaranteed to be unique. How do I manage this using hibernate? TIA

    Read the article

  • Table index design

    - by Swoosh
    I would like to add index(s) to my table. I am looking for general ideas how to add more indexes to a table. Other than the PK clustered. I would like to know what to look for when I am doing this. So, my example: This table (let's call it TASK table) is going to be the biggest table of the whole application. Expecting millions records. IMPORTANT: massive bulk-insert is adding data in this table table has 27 columns: (so far, and counting :D ) int x 9 columns = id-s varchar x 10 columns bit x 2 columns datetime x 5 columns INT COLUMNS all of these are INT ID-s but from tables that are usually smaller than Task table (10-50 records max), example: Status table (with values like "open", "closed") or Priority table (with values like "important", "not so important", "normal") there is also a column like "parent-ID" (self - ID) join: all the "small" tables have PK, the usual way ... clustered STRING COLUMNS there is a (Company) column (string!) that is something like "5 characters long all the time" and every user will be restricted using this one. If in Task there are 15 different "Companies" the logged in user would only see one. So there's always a filter on this one. Might be a good idea to add an index to this column? DATE COLUMNS I think they don't index these ... right? Or can / should be?

    Read the article

  • Why I can't use template table in dynamic query SQL SERVER 2005

    - by StuffHappens
    Hello! I have the following t-sql code which generates an error Declare @table TABLE ( ID1 int, ID2 int ) INSERT INTO @table values(1, 1); INSERT INTO @table values(2, 2); INSERT INTO @table values(3, 3); DECLARE @field varchar(50); SET @field = 'ID1' DECLARE @query varchar(MAX); SET @query = 'SELECT * FROM @table WHERE ' + @field + ' = 1' EXEC (@query) The error is Must declare the table variable "@table". What's wrong with the query. How to fix it?

    Read the article

  • Generate XSD from 2005 SQL Server Database

    - by Robert Finlayson
    What is the easiest method to generate an XSD schema from a 2005 SQL Server Database? Would it be possible to generate one XSD schema for the entire Database (~100 tables)? I searched online and found a SQL example that generates one XSD for the one table: DECLARE @schema xml SET @schema = (SELECT * FROM MyTableName FOR XML AUTO, ELEMENTS, XMLSCHEMA('MyTableNameSchema')) SELECT @schema Outside of SQL Server, is there a third party tool that could generate the XSD file from the 2005 Database?

    Read the article

  • Table Variables in SSIS

    - by aceinthehole
    In one SQL Task can I create a table variable DELCARE @TableVar TABLE (...) Then in another SQL Task or DataSource destination and select or insert into the table variable? The other option I have considered is using a Temp Table. CREATE TABLE #TempTable (...) I would prefer to use Table Variable so that it remains in memory. But can use temp table if it is not possible to use table variable. Also I cannot use the record set destination as I need to preform straight SQL tasks on it later on.

    Read the article

  • Clustered index on frequently changing reference table of one or more foreign keys

    - by Ian
    My specific concern is related to the performance of a clustered index on a reference table that has many rapid inserts and deletes. Table 1 "Collection" collection_pk int (among other fields) Table 2 "Item" item_pk int (among other fields) Reference Table "Collection_Items" collection_pk int, item_pk int (combined primary key) Because the primary key is composed of both pks, a clustered index is created and the data physically ordered in the table according to the combined keys. I have many users creating and deleting collections and adding and removing items to those collections very frequently affecting the "Collection_Items" table, and its clustered index. QUESTION PART: Since the "Collection_Items" table is so dynamic, wouldn't there be a big performance hit on constantly resorting the table rows because of the clustered index ? If yes, what should I do to minimize this ?

    Read the article

  • Query performs poorly unless a temp table is used

    - by Paul McLoughlin
    The following query takes about 1 minute to run, and has the following IO statistics: SELECT T.RGN, T.CD, T.FUND_CD, T.TRDT, SUM(T2.UNITS) AS TotalUnits FROM dbo.TRANS AS T JOIN dbo.TRANS AS T2 ON T2.RGN=T.RGN AND T2.CD=T.CD AND T2.FUND_CD=T.FUND_CD AND T2.TRDT<=T.TRDT JOIN TASK_REQUESTS AS T3 ON T3.CD=T.CD AND T3.RGN=T.RGN AND T3.TASK = 'UPDATE_MEM_BAL' GROUP BY T.RGN, T.CD, T.FUND_CD, T.TRDT (4447 row(s) affected) Table 'TRANSACTIONS'. Scan count 5977, logical reads 7527408, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. Table 'TASK_REQUESTS'. Scan count 1, logical reads 11, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. SQL Server Execution Times: CPU time = 58157 ms, elapsed time = 61437 ms. If I instead introduce a temporary table then the query returns quickly and performs less logical reads: CREATE TABLE #MyTable(RGN VARCHAR(20) NOT NULL, CD VARCHAR(20) NOT NULL, PRIMARY KEY([RGN],[CD])); INSERT INTO #MyTable(RGN, CD) SELECT RGN, CD FROM TASK_REQUESTS WHERE TASK='UPDATE_MEM_BAL'; SELECT T.RGN, T.CD, T.FUND_CD, T.TRDT, SUM(T2.UNITS) AS TotalUnits FROM dbo.TRANS AS T JOIN dbo.TRANS AS T2 ON T2.RGN=T.RGN AND T2.CD=T.CD AND T2.FUND_CD=T.FUND_CD AND T2.TRDT<=T.TRDT JOIN #MyTable AS T3 ON T3.CD=T.CD AND T3.RGN=T.RGN GROUP BY T.RGN, T.CD, T.FUND_CD, T.TRDT (4447 row(s) affected) Table 'Worktable'. Scan count 5974, logical reads 382339, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. Table 'TRANSACTIONS'. Scan count 4, logical reads 4547, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. Table '#MyTable________________________________________________________________000000000013'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. SQL Server Execution Times: CPU time = 1420 ms, elapsed time = 1515 ms. The interesting thing for me is that the TASK_REQUEST table is a small table (3 rows at present) and statistics are up to date on the table. Any idea why such different execution plans and execution times would be occuring? And ideally how to change things so that I don't need to use the temp table to get decent performance? The only real difference in the execution plans is that the temp table version introduces an index spool (eager spool) operation.

    Read the article

  • Sum of distinc rows after a 1-many table join

    - by Lock
    I have 2 tables that I am joining. Table 1 has 1-many relationship with table 2. That is, table 2 can return multiple rows for a single row of table 1. Because of this, the records of table 1 is duplicated for as many rows as are on table 2.. which is expected. Now, I have a sum on one of the columns from table 1, but because of the multiple rows that get returned on the join, the sum is obviously multiplying. Is there a way to get this number back to its original number? I tried dividing by the count of rows from table 2 but this didnt quite give me the expected result. Are there any analytical functions that could do this? I almost want something like "if this row has not yet been counted in the sum, add it to the sum"

    Read the article

  • how do I integrate the aspnet_users table (asp.net membership) into my existing database

    - by ooo
    i have a database that already has a users table COLUMNS: userID - int loginName - string First - string Last - string i just installed the asp.net membership table. Right now all of my tables are joined into my users table foreign keyed into the "userId" field How do i integrate asp.net_users table into my schema? here are the ideas i thought of: Add a membership_id field to my users table and on new inserts, include that new field in my users table. This seems like the cleanest way as i dont need to break any existing relationships. break all existing relationship and move all of the fields in my user table into the asp.net_users table. This seems like a pain but ultimately will lead to the most simple, normalized solution any thoughts?

    Read the article

  • Using an objects date (without time) for a table header instead of an objects date and time (iphone)

    - by billywilliamton
    I've been working on an iphone project and have run into an issue. Currently In the table view where it displays all the objects, I use headers based on the objects datePerformed field. The only problem is that my code apparently creates a header that contains both the date and time resulting in objects not being grouped solely by their date as I intended, but rather based on their date and time. I'm not sure if it matters, but when an object is created I use a date picker to pick the date, but not the time. I was wondering if anyone could give me any suggestions or advice. Here is the code where i set up the fetchedResultsController - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil) { return fetchedResultsController; } // Create and configure a fetch request with the Exercise entity. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Exercise" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; // Create the sort descriptors array using date and name NSSortDescriptor *dateDescriptor = [[NSSortDescriptor alloc] initWithKey:@"datePerformed" ascending:NO]; NSSortDescriptor *nameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:dateDescriptor, nameDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; // Create and initialize the fetch results controller NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"datePerformed" cacheName:@"Root"]; self.fetchedResultsController = aFetchedResultsController; fetchedResultsController.delegate = self; // Memory management calls [aFetchedResultsController release]; [fetchRequest release]; [dateDescriptor release]; [nameDescriptor release]; [sortDescriptors release]; return fetchedResultsController; } Here's where I set up the table header properties - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { // Display the exercise' date as section headings. return [[[fetchedResultsController sections] objectAtIndex:section] name]; } Any suggestions welcome. Thanks for your time. -Billy Williamton

    Read the article

  • Is there a standard SQL Table design for overriding 'big picture' default values with lower level de

    - by RichardHowells
    Here's an example. Suppose we are trying to calculate a service charge. Say sales in the USA attract a 10 dollar charge, sales in the UK attract a 20 dollar charge So far it's easy - we are starting to imagine a table that lists charges by country. Now lets assume that Alaska and Hawaii are treated as special cases they are both 15 dollars That suggests a table with states, Alaska and Hawaii are charged at 15, but presumably we need 48 (redundant) rows all saying 10. This gives us a maintainance problem, our user only wants to type 10 once NOT 48 times. It does not sit well with the UK either. The UK does not have states. Suppose we throw in another couple of cross cutting rules. If you order by phone there is a 10% supplement on the charge. If you order via the web there is a 10% discount. But for some reason best known to the owners of the business the web/phone supplement/discount are not applied in Hawaii. It seems to me that this is quite a common kind of problem and there is probably a well known arrangement of tables to store the data. Most cases get handled by broad brush answers, but there are some very detailed low level variations that give rise to a huge number of theoretical combinations, most of which are not used.

    Read the article

  • Problem with joining to an empty table

    - by Imran Omar Bukhsh
    I use the following query: select * from A LEFT JOIN B on ( A.t_id != B.t_id) to get all the records in A that are not in B. The results are fine except when table B is completely empty, but then I do not get any records, even from table A. Later It wont work yet! CREATE TABLE IF NOT EXISTS T1 ( id int(11) unsigned NOT NULL AUTO_INCREMENT, title varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, t_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table T1 INSERT INTO T1 (id, title, t_id) VALUES (1, 'apple', 1), (2, 'orange', 2); -- -- Table structure for table T2 CREATE TABLE IF NOT EXISTS T2 ( id int(11) NOT NULL AUTO_INCREMENT, title varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, t_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table T2 INSERT INTO T2 (id, title, t_id) VALUES (1, 'dad', 2); Now I want to get all records in T1 that do not have a corresponding records in T2 I try SELECT * FROM T1 LEFT OUTER JOIN T2 ON T1.t_id != T2.t_id and it won't work

    Read the article

  • deleting and reusing a temp table in a stored precedures

    - by Sheagorath
    Hi I need to SELECT INTO a temp table multiple times with a loop but I just can't do it, because after the table created( in SELECT into you can't simply drop the table at the end of the loop because you can't delete a table and create it again in the same batch. so how can I delete a table in a stored procedure and create it again? here is a snippet of where I am actualy using the temp table which is supposed to be a pivoting algorithm: WHILE @offset<@NumDays BEGIN SELECT bg.*, j.ID, j.time, j.Status INTO #TEMP1 FROM #TEMP2 AS bg left outer join PersonSchedule j on bg.PersonID = j.PersonID and bg.TimeSlotDateTime = j.TimeSlotDateTime and j.TimeSlotDateTime = @StartDate + @offset DROP TABLE #TEMP2; SELECT * INTO #TEMP2 FROM #TEMP1 DROP TABLE #TEMP1 SET @offset = @offset + 1 END

    Read the article

  • rails script/generate scaffold problem

    - by palecoder
    I'm new to rails and was trying out the scaffold command - the following scaffold runs and works when I view it via web brick script/generate book title:string the following fails - gives me a weird route error script/generate application name:string the following works script/generate app name:string can anyone shed some light on this? Is 'application' a reserved word?

    Read the article

  • How to insert the recently inserteddata of a table to others DB's Table? See description...

    - by Parth
    I am using MySQL DB and I have created a PHP script for the following, now i need the idea for the below asked question.... please help... I have a table called audit trail whose structure is: id, trackid, table, operation, newvalue, oldvalue, field, changedone I have created triggers for insert/update/delete for every table of same DB, now whenever there is change in ny DB the triggers get activated and updates the Audit trail table accordingly.. I am tracking these changes so that i can use these changes to be done on production DB which is of same structure as of this test DB. Also when the admin finds that he does not need the changes recently he did for production DB then he can rollback it using the Old Data it stored in Ausittrail table of test db. Now here in audit trail table structure, there will be an insert for every single field change like-wise if a table has 4 fields then the change in that tavle will insert 4 rows in audit trail.. Coming to the question now, How can i find the latest change done from the Audit table so that I can insert these changes in Production DB.

    Read the article

  • how to integrate my users database table with the aspnet_users table that comes with asp.net members

    - by ooo
    i have a database that already has a users table COLUMNS: userID - int loginName - string First - string Last - string i just installed the asp.net membership table. Right now all of my tables are joined into my users table foreign keyed into the "userId" field How do i integrate asp.net_users table into my schema? here are the ideas i thought of: Add a membership_id field to my users table and on new inserts, include that new field in my users table. This seems like the cleanest way as i dont need to break any existing relationships. break all existing relationship and move all of the fields in my user table into the asp.net_users table. This seems like a pain but ultimately will lead to the most simple, normalized solution any thoughts?

    Read the article

  • Control-Break Style ADF Table - Comparing Values with Previous Row

    - by Steven Davelaar
    Sometimes you need to display data in an ADF Faces table in a control-break layout style, where rows should be "indented" when the break column has the same value as in the previous row. In the screen shot below, you see how the table breaks on both the RegionId column as well as the CountryId column. To implement this I didn't use fancy SQL statements. The table is based on a straightforward Locations ViewObject that is based on the Locations entity object and the Countries reference entity object, and the join query was automatically created by adding the reference EO. To get the indentation in the ADF Faces table, we simple use two rendered properties on the RegionId and CountryId outputText items:  <af:column sortProperty="RegionId" sortable="false"            headerText="#{bindings.LocationsView1.hints.RegionId.label}"            id="c5">   <af:outputText value="#{row.RegionId}" id="ot2"                  rendered="#{!CompareWithPreviousRowBean['RegionId']}">     <af:convertNumber groupingUsed="false"                       pattern="#{bindings.LocationsView1.hints.RegionId.format}"/>   </af:outputText> </af:column> <af:column sortProperty="CountryId" sortable="false"            headerText="#{bindings.LocationsView1.hints.CountryId.label}"            id="c1">   <af:outputText value="#{row.CountryId}" id="ot5"                  rendered="#{!CompareWithPreviousRowBean['CountryId']}"/> </af:column> The CompareWithPreviousRowBean managed bean is defined in request scope and is a generic bean that can be used for all the tables in your application that needs this layout style. As you can see the bean is a Map-style bean where we pass in the name of the attribute that should be compared with the previous row. The get method in the bean that is called returns boolean false when the attribute has the same value in the same row. Here is the code of the get method:  public Object get(Object key) {   String attrName = (String) key;   boolean isSame = false;   // get the currently processed row, using row expression #{row}   JUCtrlHierNodeBinding row = (JUCtrlHierNodeBinding) resolveExpression(getRowExpression());   JUCtrlHierBinding tableBinding = row.getHierBinding();   int rowRangeIndex = row.getViewObject().getRangeIndexOf(row.getRow());   Object currentAttrValue = row.getRow().getAttribute(attrName);   if (rowRangeIndex > 0)   {     Object previousAttrValue = tableBinding.getAttributeFromRow(rowRangeIndex - 1, attrName);     isSame = currentAttrValue != null && currentAttrValue.equals(previousAttrValue);   }   else if (tableBinding.getRangeStart() > 0)   {     // previous row is in previous range, we create separate rowset iterator,     // so we can change the range start without messing up the table rendering which uses     // the default rowset iterator     int absoluteIndexPreviousRow = tableBinding.getRangeStart() - 1;     RowSetIterator rsi = null;     try     {       rsi = tableBinding.getViewObject().getRowSet().createRowSetIterator(null);       rsi.setRangeStart(absoluteIndexPreviousRow);       Row previousRow = rsi.getRowAtRangeIndex(0);       Object previousAttrValue = previousRow.getAttribute(attrName);       isSame = currentAttrValue != null && currentAttrValue.equals(previousAttrValue);     }     finally     {       rsi.closeRowSetIterator();     }   }   return isSame; } The row expression defaults to #{row} but this can be changed through the rowExpression  managed property of the bean.  You can download the sample application here.

    Read the article

  • [PHP] building html tables from query data... faster?

    - by Andrew Heath
    With my limited experience/knowledge I am using the following structure to generate HTML tables on the fly from MySQL queries: $c = 0; $t = count($results); $table = '<table>'; while ($c < $t) { $table .= "<tr><td>$results[0]</td><td>$results[1]</td> (etc etc) </tr>"; ++$c; } $table .= '</table>'; this works, obviously. But for tables with 300+ rows there is a noticeable delay in pageload while the script builds the table. Currently the maximum results list is only about 1,100 rows, and the wait isn't long, but there's clearly a wait. Are there other methods for outputting an HTML table that are faster than my WHILE loop? (PHP only please...)

    Read the article

  • Building html tables from query data... faster?

    - by Andrew Heath
    With my limited experience/knowledge I am using the following structure to generate HTML tables on the fly from MySQL queries: $c = 0; $t = count($results); $table = '<table>'; while ($c < $t) { $table .= "<tr><td>$results[0]</td><td>$results[1]</td> (etc etc) </tr>"; ++$c; } $table .= '</table>'; this works, obviously. But for tables with 300+ rows there is a noticeable delay in pageload while the script builds the table. Currently the maximum results list is only about 1,100 rows, and the wait isn't long, but there's clearly a wait. Are there other methods for outputting an HTML table that are faster than my WHILE loop? (PHP only please...)

    Read the article

  • Database Design Question

    - by deniz
    Hi, I am designing a database for a project. I have a table that has 10 columns, most of them are used whenever the table is accessed, and I need to add 3 more rows; View Count Thumbs Up (count) Thumbs Down (Count) which will be used on %90 of the queries when the table is accessed. So, my question is that whether it is better to break the table up and create new table which will have these 3 columns + Foreign ID, or just make it 13 columns and use no joins? Since these columns will be used frequently, I guess adding 3 more columns is better, but if I need to create 10 more columns which will be used %90 of the time, should I add them as well, or create a new table and use joins? I am not sure when to break the table if the columns are used very frequently. Do you have any suggestions? Thanks in advance,

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >