Jump to content

MySQL error creating a column


Mikhail

Recommended Posts

Im trying to create a column in "characters" for a RP gm, im trying to create the column manually...

CREATE TABLE `testrole`.`characters` ( `lastLogin` TIMESTAMP(0000-00-00 00:00:00) NOT NULL ) ENGINE = InnoDB

Here is the main.lua 

addEventHandler( "onResourceStart", resourceRoot,
	function( )
		-- create all mysql tables
		if not exports.sql:create_table( 'characters',
			{
				{ name = 'characterID', type = 'int(10) unsigned', auto_increment = true, primary_key = true },
				{ name = 'characterName', type = 'varchar(22)' },
				{ name = 'userID', type = 'int(10) unsigned' },
				{ name = 'x', type = 'float' },
				{ name = 'y', type = 'float' },
				{ name = 'z', type = 'float' },
				{ name = 'interior', type = 'tinyint(3) unsigned' },
				{ name = 'dimension', type = 'int(10) unsigned' },
				{ name = 'skin', type = 'int(10) unsigned' },
				{ name = 'rotation', type = 'float' },
				{ name = 'health', type = 'tinyint(3) unsigned', default = 100 },
				{ name = 'armor', type = 'tinyint(3) unsigned', default = 0 },
				{ name = 'money', type = 'bigint(20) unsigned', default = 100 },
				{ name = 'created', type = 'timestamp', default = 'CURRENT_TIMESTAMP' },
				{ name = 'lastLogin', type = 'timestamp', default = '0000-00-00 00:00:00' },
				{ name = 'weapons', type = 'varchar(255)', null = true },
				{ name = 'job', type = 'varchar(20)', null = true },
				{ name = 'languages', type = 'text', null = true },
			} ) then cancelEvent( ) return end
		

 

and its gives me in the phpMyAdmin

 

#1064- something is wrong in your syntax near '-00-00 00:00:00) NOT NULL ) ENGINE = InnDB' line 1

 

please help im new in script and MySQL!

Edited by Mikhail
Link to comment
On 06/10/2018 at 17:51, Sorata_Kanda said:

Appearently, you are not supposed to set a formatting on TIMESTAMP. Which means, you simply have to use this command:


CREATE TABLE `testrole`.`characters` ( `lastLogin` TIMESTAMP NOT NULL ) ENGINE = InnoDB

 

fixed

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...