Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





On Record Creation Set Default Current Time


I'm trying to do what I thought would be a simple thing: I want set the values of certain columns at my database to the default current time.

I'm using this sql query to do so: ALTER TABLE DEPARTAMENTO ALTER COLUMN CRIADO SET DEFAULT CURRENT_TIMESTAMP

And I'm receiving the following error:

Comando SQL:

ALTER TABLE DEPARTAMENTO ALTER COLUMN CRIADO SET DEFAULT CURRENT_TIMESTAMP

Mensagens do MySQL :

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURRENT_TIMESTAMP' at line 1




View Complete Forum Thread with Replies

Related Forum Messages:
Changing The Default Time Zone Of A Current Timestamp In MySQL
I have a shared host which uses the time zone MST (GMT-7), and I cannot seem to change the time zone for my own database.

What is the best way to create a timestamp field in a table that has the default value be the current time in GMT-0?

Is setting the default value of the timestamp field to "DATE_SUB(NOW(), INTERVAL -7 HOUR)"

View Replies !
Different Timestamps For Time Of Creation And Time Of Update
What is the syntax to be used in MySQL when you want one timestamp to be set when the record is created, and the other only when it is updated?

I tried something like that but got a syntax error.

View Replies !
Compare Time Posted With Current Time Not Working
May I know how to get records with interval of 1 hour in database where the posting time is in this format '2008-05-15 00:10:40'

I tried with this :

$query="SELECT date,name FROM message WHERE (timediff(date,NOW())<=CRUDATE() CURTIME())";

But is not working. May I know what is the correct way of doing it?

View Replies !
Setting DEFAULT Value After Creation Of Field
I've been searching all over w3schools to no avail.

I have a column whos domain is varchar(6). I want to set the default value to 'active'. I already have a whole lot of values in there. Some are 'active', some are 'closed'. I just figured it would be nice to have a default value in case someone added an entity and didn't specify this particular field.

So, how do I set the default value for a column after I've already created and populated the dbase?
And are there any better resources on the web than w3schools?

View Replies !
How To Record The Current Record In A Table?
I'm looking at convert file formats to mysql.

The original file format used an "ENTRY" conception to record the current record.

But I cannot find a solution to emulate "ENTRY" conception in MySQL.

After searching MySQL's tutorials, the AUTO-INCREMENT fields would only use "mysql_insert_id()" to obtain its value. But this value cannot identify the current record, Right? This value are only last record after inserting?

Who can help me to find a better solution to emulate implementing what the "ENTRY" does.

In other words, How to obtain the auto-increment value contains AUTO-INCREMENT columns in a record which generated by SELECT statement.

View Replies !
Default Current Timestamp Issues
Using MySQL 4.1.7. I have a sole TIMESTAMP column in the table:

insert_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

Looking at the timestamp docs, a query with NULL or empty, should cause the column to use the current time for its default value, but is not automatically updated.

However, putting NULL or simply leaving blank in an INSERT query, gives 01/01/0001.
Any ideas?

View Replies !
How Can I Get The Default Value Equal Current Datatime?
i created a table.one of it's fields default value is current datatime? i write sentence like this:

CREATE TABLE `test_dbo`.`test` (
`a` DATETIME NOT NULL DEFAULT 'now()'
)ENGINE = InnoDB;
i get the prompt like this"invalid default value for 'a'"

what can i do for this?

View Replies !
Getting Time Of Row Creation
I have some rows in a table and I was wondering if it was possible to find out through some PHP or mysql function when that row was added. Unfortunately, the structure was not setup to have a time or date column with timestamps.

View Replies !
How To Set Creation Time
I have one table which i only fill with data once in a while.
then i would truncate it and fill all data using INSERT INTO ... SELECT ...

but that would not reset the creation date. so i cant know how old the data is.

so i changed my scriot to drop the table and recreate it. but then the creation date is still the same. how can that be?
i tried FLUSH with no success.

View Replies !
Current Selected Record
i need to do this and it also needs to be conditional.
Like, it needs to be the first row that sits before the currently selected row wich has a cat_id value of [comparision value].
I have read a bit about cursors, would this be a good way to do this?

View Replies !
Get Previous And Next ID Of Current Record
I want do create a "Previous" and a "Next" link, all I have is the ID of the current record. Is there a good way to get the previous and next id of a record with a single SQL Query?

example:

ID's: 4,10,7,9,13

I open my page and show all details from the record with the ID 7, now I want to create the links and I need the previous and the next ID, 10 and 9.

I could make a query that returns only the ID's and loop through the recordset till i have my ID's but that's such an ugly solution, not to mention the performance issues.

View Replies !
Referencing Other Fields In Current Record?
I am trying to insert a new record in a table, where one of the fields should contain the value of the index of the record, like this :

INSERT into mytable VALUES (default,'something',CONCAT('something',table_id))

where table_id should be the value inserted by the default in the first field. So this record would contain something like :
65 , something , something65

View Replies !
Table And/or Database Creation Time
Is there such thing as a table or database creation time in the SQL
standard, that you could avail yourself of?

I mean do databases keep this info. I think they do since they are
like little OSs and many of them have internal back up features, that
must use some kind of timing.

View Replies !
Add Seconds To Current Time
I am trying to create a statment to add a given time in second to the current time like this:

update tags.triggers set next_interval=(addtime(curtime(),300)) where id=1;

This statment adds 3 minutes to the current time. How can I add 300 seconds to the current time?

View Replies !
Comparing Difference Between Current Record And Previous, Non-sequential/variable Data
I have a locally-developed asset tracking system in which inventory operators upload batches of time stamped CSV data into a “move_log” via a handheld barcode scanner after they take an inventory of what assets are in a particular location.

I would like to be able to identify each time an item actually moved from one location to the next. Sounds simple, however:

1. An item may be inventoried multiple times without actually moving (think large items that don’t move very often, if ever). This means an entry in the “move_log” table for each inventory sweep, even if no change in location.
2. An item may move from one location to another, then back to the original location, perhaps several times. Think items such as laptops kept in a central depot and checked out for use. This means that a simple “SELECT DISTINCT” will not show the actual number of moves, just the number of different places an asset has been.

Unless I am missing something, the best way I can think to describe a “move” is to look at the entries for each asset, and then compare with the previous entry for that asset. Any difference between the current entry and the previous would count as one “move.” Of course, there is no set number of entries for a particular asset. Some assets may have been inventoried once or twice, others dozens of times.

I would like to do this entirely within MySQL if possible.

The table in question: ...

View Replies !
Current Date & Time For Datetime Variable?
I have created a table with a variable of the type "datetime". Any one knows how to update this variable with the current date and time? The function Curdate() only updates the date, not the time.

View Replies !
Assign Default Record Or ID#
I have mysql 5.0.26 running on Mac OS 10.4.8. I'm starting with some simple DBs and tables. How do I get mysql to automatically assign a recod number or ID to each row, without inputting one? Ie. the first row created is ID 1, second 2, etc., without my typing that in?

I am able to use mysql in CLI and CocoaMYSQL (interface) but never was able to get it running in phpMyAdmin. Keeps telling me it can't load the mysqli extention.

View Replies !
Change The Default Date Time Format
I am using mysql 5.1 . In that one default date time format is yyyy-mm-dd.

But I want to use it as dd-mm-yyyy. Can you anybody explain me how to change the default date time format. not only in that format in any format.

View Replies !
Date/Time As A Default Values For A Table Column
I am new to mySQL, so this question might be simple.I want to add a default value to a column that is the current date/time. I am using the mySQL Administrator and will not allow me to use a function like CURRENT_TIMESTAMP() or NOW() as a default value. I used to do this with other databases (I always add a column to all of my tables called InsertDateTime and UpdateDateTime. It helps to track down data entry problems)

View Replies !
6.500.000 Record And Time
I have this problem:
i have to search on 6.500.000 records in a InnoDB table and my application exerts 24 seconds for the search...
I have to do fastest possible.

Do you any idea?
The Table is a InnoDB, the columns(3) are all index.

View Replies !
Query To Display A Record By Recent Time
Many users uploaded their files to my mysql table through php script,
my table having the details of uploading time, file name, & uploader name.

i need to find the recent uploaded file for all uploaders.

i tried with this query,

select file_name,uploded_by,MAX(date_time) from upload group by uploded_by;

it is giving the recent time, but it is not giving the latest file, it is showing first uploaded file.

View Replies !
Select Record In Time Range Not Working
$today=date('Ymd');

"SELECT * FROM data WHERE (startdate>='".$today."' AND stopdate <='".$today."'.....

View Replies !
How To Check For Date/time Ranges Within Record (check For Schedule Conflicts)
You want to check scheduling conflicts and you have a record like:

appointments(table):
apptID
beginningDate
endingDate
beginningTime
endingTime

It's easy enough to check if a time is within that record. Say you want to
check if 8:00am to 10:00am is available, you would use this:

SELECT apptID
FROM appointments
WHERE (beginningDate = '2006-01-19' OR endingDate = '2006-01-19')
AND ('08:00:00' BETWEEN beginningTime AND endingTime
OR '10:00:00' BETWEEN beginningTime AND endingTime)

BUT, what if you have an all-day appointment (8:00am to 5:00pm) and there
exists an appointment already scheduled from 10:00am to 11:00am. The above
query would not find it.

Another question is what if the appointment is more than two days. Say, it's
from Monday - Wednesday from 8am to 5pm. The above query would not
successfully catch it if you wanted to schedule an appointment on Tuesday.

(I might be able to generate a date range using PHP, don't know if that's
the best way)

View Replies !
Automatically Record Date Of Record Entry
I have my database table set up and I have an HTML form that is PHP driven that will add the information entered into the form into to my database table.

I have a local buy-sell-trade Website. The way it has worked is that people fill out a form and the results emailed to me. I then take the information and enter it into a Web page. I only want the ads to be displayed for 30 days. I keep the ad for a total of 6 weeks (displays for 30 days and sits in limbo for 2 weeks afterwords) and if not renewed within that 2 week limbo period - I delete it.

Entering all the ads and keeping up with the dates manually has become a burden. I've only recently began looking into databases. My hosting company provides me with phpmyadmin and mysql 5.0. I'm new to all of this but I have managed to set up a database table and a HTML form that is PHP driven that allows ads to be automatically added to the database table.

There is a lot I need to do to make this ideal, but one step at a time.

First, I need to know the date (March 02, 2006) the ad was created or added to the database table. I know that I need to add some piece of code to my php form to record this information, but what code and where do I put it? I know I will need to create an extra field in my database table to house the date - I can handle this.

I've read the date and time information here http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

but there's a lot there and I don't know which is right for my needs. Plus, it doesn't tell me how or where to insert it into my php form (or does it?).

View Replies !
DB Creation.
Taken this example for a web site (like eBay) Don't care about analyze, it's
just for the example.

- table article, is a general table containing the article description.
- table seller, all the datas about a seller.
- table announce, all the datas concerning an announce
- table bill, concerning the billing process

the entities:
- the seller may have 0 or N articles (0:n)
- the annouce has (and must have) only 1 article (1:1)
- the announce belong to 1 and must belong to 1 seller. (1:1)
- the article has (and must have) only 1 announce (1:1)
- every announce must have 1 or N bills (1:n)
- every bill belong (and must belong) to 1 announce (1:1)
- any other possible reference.

May somebody give me the script for creating this database with referential
integriry (MySql 4.0)

I've no tool to create this and don't know the syntax.

View Replies !
Getting Record Before Or After The Record That Meets The Criteria
In a query I want to get all the results and then order those results by last name, but then I want to filter those results down to only the record that comes before or after the record that has 'empno' = '1259'.

I want to get all the results already ordered and then filter them down to one record either before or after (depending on what is needed) the record where 'empno' = '1259'.

View Replies !
4.0.15 Foreign Key Creation Bug?
The table creation script(at the end of this post) works fine on
4.0.1-alpha-win, but the foreign key constraints fail on 4.0.15-win. I
am starting the server with the same command for both versions:

mysqld-max-nt --console --transaction-isolation=SERIALIZABLE

In 4.0.15-win I can extract the following error after I run the table
creation script:

[test01] ERROR 1005: Can't create table '.ibdata#sql-a14_3.frm'
(errno: 150)

Also, the InnoDB status in 4.0.150-win shows:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
030930 19:38:49 Error in foreign key constraint of table
ibdata/#sql-a14_3:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint:
FOREIGN KEY (contactInfo_fk) REFERENCES contact(pk) ON DELETE SET NULL
See http://www.innodb.com/ibman.html for correct foreign key
definition.

But the above is wrong. I DO have an index defined on the foreign key,
it IS the first column in the index, and their IS NO type mismatch.
Since this works on 4.0.1, I have to think this is a bug. I need a
working version of the server that supports transaction savepoints.
Any help appreciated!!

# Connection: test01
# Host: localhost
# Saved: 2003-09-29 18:16:42
#
CREATE TABLE orderjoin (
owner BIGINT,owned BIGINT
) TYPE=InnoDB;
CREATE TABLE orders (
pk BIGINT UNSIGNED AUTO_INCREMENT NOT N.....................................

View Replies !
Format Creation
I have 2 tables:

Table1 contains (among other things):

ID Data1 Data2 Data3
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii

Table2 contains (among other things:

ID Key Value
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

I need a query that returns:

ID Data1 Data2 Data3 Value Value Value
(Key=20) (Key=30) (Key=40)
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

Any ideas?

View Replies !
Mysql Creation
I have installed Fedora core 3 with mysql database.Now I am able to connect to mysql database.But I have to create user and table .How to go ahead

View Replies !
Table Creation
I'm creating a table and would like to get the system date for my date column. How would I do this.
I tried to use date date SYSDATE with no luck.
Also when adding values to the DB, would I insert anything in this column or just leave it out like and auto increment column??

View Replies !
Index Creation
im trying to create a couple indexes for some tables and keep getting errors with these ones.

CREATE UNIQUE INDEX IX_TBLADDRESS_PRI_UNQ ON TBLADDRESS
(CASE BISPRIM WHEN 1 THEN NOWNERI ELSE NULL
END ASC,
CASE BISPRIM WHEN 1 THEN SOWNERT ELSE NULL
END ASC);

CREATE INDEX IXDELEMAILQUEUE_MODIFIED ON TBLDELETEDEMAILQUEUE
(STR(DTIMEMO,'YYYYMMDD') ASC);

CREATE INDEX IXEMAIL_LOWER_EMAIL ON TBLEMAILADDRESS
(LOWER(SEMAILA) ASC);

CREATE UNIQUE INDEX IX_SCHOOLDOM_PRI_UNQ ON TBLSCHOOLDOMAIN
(CASE BISPRIM WHEN 1 THEN NSCHOOL ELSE NULL
END ASC);

CREATE UNIQUE INDEX IX_TBLSCHOOLSTATE_SCHOOLHEAD ON TBLSCHOOLSTATE
(CASE BISHEAD WHEN 1 THEN NSCHOOL3 ELSE NULL
END ASC, CASE BISHEAD WHEN 1 THEN SMODULE ELSE NULL
END ASC);

CREATE INDEX SPONSORTRAN_LOWER_EMAIL_IDX ON TBLSPONSORLOADTRANSACTION
(LOWER(SSPONSE) ASC);

View Replies !
Foreign Key Creation
I'm creating a calendar scheduling system with PHP and MySQL to keep track of lessons. I have one form in which the user enters the information about the event that needs to be scheduled. Then I need three entries to be made in three different tables. What I have is one table that keeps track of the entries in the calendar. Then I have two more, one for how much the teacher needs to get paid as a result of the number of hours and the other is how much the student needs to pay based on the hours. The only problem is that I want the student and teacher paying tables to have the unique ID of the calendar entry to which the payments are associated.
So the problem is I can insert the entries into the calendar tables, and it will automatically create a unique ID for that entry, but then how can I take the ID for that entry and insert it into the two other tables. The best I could come up with is somehow query the last entry created but i'm not sure how, or even if that is a good way of doing it.

View Replies !
Sequence Creation
I am not able to create a sequence in MySql.. But its giving error.

Can any one pls tell me how can i do that?

View Replies !
Set Date Creation
like to set the creation date of a table or the entry of new data with an old date.

Ex: I want that a table results created on 10th December 2000.

Or data wrote in table results old, wrote like 1 month ago.

I think I can do that by using the TIMESTAMP or something like this statement.

View Replies !
Creation Of A CMS With PHP & MySQL
I'm currently trying to produce a CMS through the use of PHP & mySQL, the idea of this CMS is to allow the content of the site to be updated from a external source, i.e. The Client. Code:

View Replies !
Table Creation Sql
Is there any way to have MySQL supply the SQL used to create a table?
Sort of like it does using the command line mysqldump tool, but direct from the actual MySQL server (i.e. one I could use to get the SQL from MySQL using PHP)?



View Replies !
Foreign Key Creation
I have a website that pulls data from a database. For some reason, after I add data to the database, from the site, the site will pull it up fine on the page, but then, sometimes, out of the blue, it does not. The data will be in the database, but it won't appear on the page. The strange thing about the whole situation is that when I add a new entry to the database, the site will find the information it couldn't find before and it will appear on the page...

View Replies !
Multiple Databases Creation
I know that Mysql handles large database very well, but there is a project
that requires more than 2000 small databases(about 20 talbes with a few
rows) to be created within a Mysql server. Could somebody tell me does it
make sense?

View Replies !
Table Creation Error
I'm getting a MySQL error creating my table (see image's below). I'm compltely puzzled, it looks fine to me!

View Replies !
Table Creation Command
I tried using MySQL Admin, but am finding that it is buggy AND I am having touble creating a table with an auto increment key as well as setting another field UNIQUE.
Would it be easier for me to create my tables manually or is there less buggy freeware out there for table creation?

View Replies !
Table Creation Syntax
The following was produced by the latest version of EngInSite from a database in existence on the server (4.51) where I want to replicate my database. I'm getting a syntax error message. Can anyone here see a problem with this? Code:

View Replies !
Table Creation Date?
Is there a way to retrieve table creation date(creation date of frm file) from PHP?

View Replies !
Mysql Database Creation
I am using MySQL Control Center 0.9.4 beta to manage my MYSQL databases. I've installed MySQL version 4.1.21 with the standard configuration. Whenever I create a database using MySQLCC it creates it with no problems.

It also allows me to create tables and input information into the tables without any trouble. When I close the interface and reopen and reconnect to the server, the database I have created is not there. Yet if I create a new database with that same db name, It contains all the information the original database I had created before had.

I receive only this error when I reopen MySQLCC after previously closing it:
The database: db1 in server: root@localhost:3306 was not found.

(Where db1 is the name of my database I've created)

What is going on? Is this a MySQL problem or a MySQL Control Center problem?

View Replies !
Object Creation And Maintenance
how to create a schema in mysql? and also, how to maintain objects like tables, tablespaces, databases, etc. i really need them since i am doing a documentation regarding mysql.

View Replies !
Login Page Creation
i am trying to create a login page on my site with user name and password i mainly work in dreamweiver on a mac platform.

how can i use the mysql database to store the information and link dreamweiver to get the info i have no idea how mysql works so you have to be patient with me and guide me step by step.

View Replies !
Database Creation Question
I want to know if mysql can merge two tables in a way that one certain column of both databases subtract each other. One table adds up all the numbers in that certain while it subtracts all numbers from the other table. At the end, it will output an answer for the total of the operation.

I want to use this on my accounting database wherein the ORDERS table will be subtracted by the CREDIT MEMO table.

View Replies !
Stored Proc Creation
I'm having trouble creating a stored proc with a user account. The administrator account can create it without problems. I have granted CREATE ROUTINE to this user, both globally and for the DB I'm using. I've tried GRANT ALL, still I receive this error:

ERROR 1044 (42000): Access denied for user 'username'@'%' to database 'dbname'

The mysql.proc table exists. I'm not sure what to try next. I don't want this used to have SUPER privileges, not that I've tried granting them yet, but I have a feeling it would solve the problem.

View Replies !
Database Creation Permissions
I have setup different MySQL users. I have removed all permissions for the users, and granted them full permission to their default databases I created for the.

My question is, how can I grant the users permission to create databases. I want them to have full control to create databases, and delete any that they create. Is this possible, or do I need to create and remove databases for them as requested?

I'm running mysql 3.2.5 on Redhat 9. I am not using any host permissions, table, or row permissions on the databases.

View Replies !
Creation Of Mysqlorary Table
I have written a java program in Netbeans platform, and at some point I need to create a mysqlorary table.

So I'm executing this statement:

create mysqlorary table `customers_orderdetails`(`customers_customerName` VARCHAR(50) NULL, `orderdetails_priceEach` DOUBLE(22) NULL);

but I'm getting this MySQL exception: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') NULL)' at line 1"

View Replies !

Copyright 2005-08 www.BigResource.com, All rights reserved