PHP mySQL – Insert new record into table with auto-increment on primary key

Use the DEFAULT keyword: $query = “INSERT INTO myTable VALUES (DEFAULT,’Fname’, ‘Lname’, ‘Website’)”; Also, you can specify the columns, (which is better practice): $query = “INSERT INTO myTable (fname, lname, website) VALUES (‘fname’, ‘lname’, ‘website’)”; Reference: http://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html

SQL Populate table with random data

I dont know exactly if this fits the requirement for a “random description”, and it’s not clear if you want to generate the full data: but, for example, this generates 10 records with consecutive ids and random texts: test=# SELECT generate_series(1,10) AS id, md5(random()::text) AS descr; id | descr —-+———————————- 1 | 65c141ee1fdeb269d2e393cb1d3e1c09 2 | … Read more

Is there a standard way of moving a range into a vector?

You use a move_iterator with insert: v1.insert(v1.end(), make_move_iterator(v2.begin()), make_move_iterator(v2.end())); The example in 24.5.3 is almost exactly this. You’ll get the optimization you want if (a) vector::insert uses iterator-tag dispatch to detect the random-access iterator and precalculate the size (which you’ve assumed it does in your example that copies), and (b) move_iterator preserves the iterator category … Read more

postgresql: INSERT INTO … (SELECT * …)

As Henrik wrote you can use dblink to connect remote database and fetch result. For example: psql dbtest CREATE TABLE tblB (id serial, time integer); INSERT INTO tblB (time) VALUES (5000), (2000); psql postgres CREATE TABLE tblA (id serial, time integer); INSERT INTO tblA SELECT id, time FROM dblink(‘dbname=dbtest’, ‘SELECT id, time FROM tblB’) AS … Read more