Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:47:28+00:00 2026-05-27T21:47:28+00:00

I have two tables in two separate sqlite3 databases. The datatypes are identical, but

  • 0

I have two tables in two separate sqlite3 databases. The datatypes are identical, but the schemas slightly different. I want them to be a single table in a single database with the same schema as Table 2

Table 1

CREATE TABLE temp_entries (
    id INTEGER PRIMARY KEY, 
    sensor NUMERIC, 
    temp NUMERIC, 
    date NUMERIC);

Table 2

CREATE TABLE "restInterface_temp_entry" (
    "id" integer NOT NULL PRIMARY KEY,
    "dateTime" integer NOT NULL,
    "sensor" integer NOT NULL,
    "temp" integer NOT NULL
);

id is not unique between the two tables. I would like to create another table with the same schema as Table 2. I would like the id for the entries in Table 1 to start from 0 and then the entries from table 2 to start after the last entry from table 1.

Ideally I would like to just add the entries from Table 1 to Table 2 and “reindex” the primary key so that it was in the same ascending order that “dateTime” is.

UPDATE: I now have both tables using the same schema, I did this by creating a new table with the same schema as Table 2 into the database that held Table 1. I than copied the data to the new table with something like:

INSERT INTO restInterface_temp_entry(id,dateTime,sensor,temp)
   ...> select id,date,sensor,temp FROM temp_entries;

Background

I used to record a bunch of temp_entries to a csv file. I wanted to put the data into a format that was easier to work with and chose sqlite3. I wrote a program that pulled all of the entries out and put them into Table 1. I wasn’t sure what I was doing at the time, and used Table 2 for all new entries. Now I want to combine them all, hopefully keeping id and date in ascending order.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:47:29+00:00Added an answer on May 27, 2026 at 9:47 pm

    Figured it out.

    • Open current database.
    • Attach to original database

      ATTACH '/orig/db/location' as orig
      
    • Move records from current database to old database, leaving out the PK

      insert into orig.restInterface_temp_entry(dateTime,sensor,temp)
      ...> select dateTime,sensor,temp from main.restInterface_temp_entry;
      
    • Clear current databases table

      delete from main.restInterface_temp_entry where id > 0
      
    • Copy everything updated records from original databases table back to current.

      insert into main.restInterface_temp_entry(id,dateTime,sensor,temp)
      ...> select id,dateTime,sensor,temp
      ...> from orig.restInterface_temp_entry;
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of addresses in two separate tables that are slightly off
I have two separate tables both with user id columns uid . I want
I have two tables I'd like to compare. They are in separate databases and
I have a view table which is a union of two separate tables (say
I have two tables containing Tasks and Notes, and want to retrieve a list
I have two separate tables used for categories. One is Categories(ID, Title, Description) ,
I have two separate tables TVs and Receivers that I am using the FOR
I have two tables in my access database that I want to be able
I have two tables that contain completely separate information: table: tires columns: Tire_id name
I have a two separate tables that contain parts of user name (don't ask

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.