cffood Posted November 15, 2014 Share Posted November 15, 2014 so my database table already exists but i need to add new columns to the table so this is how the table looks now CREATE TABLE IF NOT EXISTS `users` ( `id` int(255) NOT NULL AUTO_INCREMENT, `birthday` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '1-1-1990', `comment_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `confirm_followers` int(11) NOT NULL DEFAULT '0', `current_city` text COLLATE utf8_unicode_ci NOT NULL, `follow_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `gender` varchar(6) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'male', `hometown` text COLLATE utf8_unicode_ci NOT NULL, `message_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `post_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `timeline_post_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; and this is what I need it to look.... but every time I insert in the sql to do the update but it does not do it as the table already there... CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT NOT NULL, `job_title` mediumtext COLLATE utf8_unicode_ci NOT NULL, `job_at` mediumtext COLLATE utf8_unicode_ci NOT NULL, `birthday` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '1-1-1990', `comment_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `confirm_followers` int(11) NOT NULL DEFAULT '0', `current_city` text COLLATE utf8_unicode_ci NOT NULL, `relationship` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Not Applicable', `relationship_to` mediumtext COLLATE utf8_unicode_ci NOT NULL, `follow_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `gender` varchar(6) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'male', `hometown` text COLLATE utf8_unicode_ci NOT NULL, `message_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `post_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', `timeline_post_privacy` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'everyone', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; how can I do this update>? its ok i know how to do this.. but the code i sell needs this update but i cant get them to delete there table as there mybe data already in the table Quote Link to comment https://forums.phpfreaks.com/topic/292487-updating-sql-database/ Share on other sites More sharing options...
Solution Barand Posted November 15, 2014 Solution Share Posted November 15, 2014 You need an "ALTER TABLE" query to add the new columns http://dev.mysql.com/doc/refman/5.6/en/alter-table.html Quote Link to comment https://forums.phpfreaks.com/topic/292487-updating-sql-database/#findComment-1496673 Share on other sites More sharing options...
cffood Posted November 15, 2014 Author Share Posted November 15, 2014 thank you its been awhile since i studied sql...totaly forgot about ALTER TABLE Quote Link to comment https://forums.phpfreaks.com/topic/292487-updating-sql-database/#findComment-1496684 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.