alter

How to move columns in a MySQL table?

偶尔善良 提交于 2019-12-17 07:01:09
问题 Currently I am having the following MySQL table: Employees (empID, empName, department); I want to change the table to the following: Employees (empID, department, empName); How can this be done using ALTER statements? Note: I want to change only column positions. 回答1: If empName is a VARCHAR(50) column: ALTER TABLE Employees MODIFY COLUMN empName VARCHAR(50) AFTER department; EDIT Per the comments, you can also do this: ALTER TABLE Employees CHANGE COLUMN empName empName VARCHAR(50) AFTER

How to add new column to MYSQL table

爷,独闯天下 提交于 2019-12-17 04:48:24
问题 I am trying to add a new column to my MYSQL table using PHP. I am unsure how to alter my table so that the new column is created. In my assessment table I have assessmentid | q1 | q2 | q3 | q4 | q5 Say I have a page with a textbox and i type q6 in to the textbox and press a button then the table is updated to assessmentid | q1 | q2 | q3 | q4 | q5 | q6 Thanks in advance <?php include 'core/init.php'; include 'core/admininit.php'; include 'includes/overall/overall_header.php'; adminprotect_page

MySQL alter table generating “error on rename”

倖福魔咒の 提交于 2019-12-13 15:03:59
问题 Here's a print of my error: mysql> ALTER TABLE Price DROP FOREIGN KEY Id ERROR 1025 (HY000): Error on rename of '.\testdb\Price' to '.\t estdb\#sql2-bcc-16' (errno: 152) I've read this page which suggests that the problem may be due to a left-over table from some earlier alter table error, and recommends you snoop around in your data directory and delete any table with a name such as 'B-xxx.frm'. My error is similar to this, but there is no '#sql2-bcc-16' in my data directory. And there

SQL Server Flyway script - drop column constraint issue

戏子无情 提交于 2019-12-13 03:46:29
问题 I'm working on SQL Server and am trying to drop a column. The table schema is as below: CREATE TABLE [dbo].[XYZ]( [ID] [int] NOT NULL, [DSC] [varchar](255) NULL, [LOWER_LIMIT] [int] NOT NULL, [UPPER_LIMIT] [int] NOT NULL, CONSTRAINT [XP_XYZ] PRIMARY KEY CLUSTERED ( [ID] ASC ) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO When I attempt to drop the column : ALTER

mysql error: Specified key was too long; max key length is 767 bytes

烂漫一生 提交于 2019-12-13 02:09:54
问题 I had to run this command to alter a column in one of my table. ALTER table XYZ modify value VARCHAR(1024); When I run it, I get this error. ERROR 1071 (42000) at line 1: Specified key was too long; max key length is 767 bytes The original column size was 250. Here is the strange part. I have a 2nd MySQL server with identical configurations and it is doing 2 way replication with the 1st server. When I run this "alter table" command on my 2nd MySQL server, I didn't get this error. In fact,

Creating calculated fields in sql

我的未来我决定 提交于 2019-12-12 09:54:40
问题 This will seem rudimentary but I can't find a concise example online that matches up. I have three fields; m1 , m2 , and m3 . I need to create a column or field that is the average of them three. The calculated field would be titled employment. Would the following code be suffice? ALTER TABLE dbo.tablename ADD Employment AS Select ((m1+m2+m3)/3) Sample data m1 20 20 30 m2 15 17 25 m3 60 77 13 desired result. Name m1 m2 m3 Employment Auto body 20 20 30 23 Auto Parts 15 17 25 19 Auto Sales 60

ALTER postgreSQL sequence

跟風遠走 提交于 2019-12-12 06:46:01
问题 I am quite very new to postgreSQL. I am have a sequence which starts from 1 by default. What I am looking for is that if I want to move my next value, which is now 87, to 2000. I am unable to do that. Can any one suggest me how to go about doing the change? 回答1: You can ALTER the sequence using the following code: ALTER SEQUENCE seq_name RESTART 2000. I request you to please go through the postgres SQL manuals. http://www.postgresql.org/docs/current/static/sql-altersequence.html 来源: https:/

Other thread wont let me change Activity layout!? Android

混江龙づ霸主 提交于 2019-12-12 05:37:35
问题 SOLUTION: It might not be the best or the prettiest solution, but it works. Start a new thread so the main thread can display a ProgressDialog while the new thread retrieves, assigns and interrupts the main thread with a new runnable to initiate views. For the ProgressDialog to be shown while all the activity in the new thread is going on, the ProgressDialog must, as mentioned, be started in the main thread and dismissed of course at the end of the new thread. The ProgressDialog must be

Oracle foreign key

寵の児 提交于 2019-12-11 14:49:19
问题 So i have two tables CREATE TABLE Client( ID NUMBER(10) NOT NULL, (PRIMARY KEY) Name VARCHAR(30) NOT NULL, Surname VARCHAR(30) NOT NULL, Phone NUMBER(11) NOT NULL, Email VARCHAR(70)); CREATE TABLE Boss( B_Surname VARCHAR(30) NOT NULL, (PRIMARY KEY) B_Name VARCHAR(30) NOT NULL); I need to put foreign key (B_surname from Boss table) to Client table. I've tried use ALTER TABLE: ALTER TABLE Client ADD CONSTRAINT Boss_Client_fk FOREIGN KEY (B_Surname) REFERENCES Client(ID); After that I got errors

SQL Server : ALTER TABLE ADD COLUMN MAXDOP=1

笑着哭i 提交于 2019-12-11 14:12:22
问题 I am trying to suppress parallelism in SQL Server while altering a table to add a column with the option maxdop=1 . However I get an error in the syntax. I tried several ways but I can make it work, does anybody know how to use this option when adding a column? ALTER TABLE [dbo].[mytable] ADD neColumn varchar(max) WITH (MAXDOP = 1); 回答1: Pretty sure you can't use query hint for an alter table. See list at https://msdn.microsoft.com/en-us/library/ms181714.aspx Depending on what you want to do,