alter

How to rename a column name in maria DB

江枫思渺然 提交于 2020-05-14 18:22:09
问题 I am new to SQL, I was trying to change column name in my database's table. I am using 'xampp' with 'maria DB' (OS - Ubuntu 18.04) I tried all of the followings: ALTER TABLE subject RENAME COLUMN course_number TO course_id; ALTER TABLE subject CHANGE course_number course_id; ALTER TABLE subject CHANGE 'course_number' 'course_id'; ALTER TABLE subject CHANGE COLUMN 'course_number' course_id varchar(255); ALTER TABLE subject CHANGE 'course_number' 'course_id' varchar(255); But the only output I

SQL Server multiple schema object issues

我只是一个虾纸丫 提交于 2020-02-15 08:18:58
问题 I have database that has multiple schemas and objects under them. I want to consolidate the objects into one schema. I tried ALTER SCHEMA dbo TRANSFER <custom_schema>.<table_name> I get an object already exists message However, I can't see it in the Management studio and SELECT * from dbo.<table_name> returns object does not exist. Looks like some system table entry is out of whack. I looked at sysobjects and it has only one entry for . Any suggestions on how to trouble shoot/ fix this issue

How to alter column size of a view in Oracle

青春壹個敷衍的年華 提交于 2020-01-30 10:46:29
问题 I am trying to alter the column size of a view with the same command that we use for table like : alter table STUDENT modify ( ROLL_NO VARCHAR2(80) ); But its throwing error SQL Error: ORA-00942: table or view does not exist So how we can alter the column size of a view? 回答1: A view is simply saved query and "inherits" column type from underlying base table. So if you need to change metadata you should alter view definition: ALTER VIEW view_students AS SELECT CAST(roll_no AS VARCHAR2(80)) AS

MySQL Alter table, add column with unique random value

狂风中的少年 提交于 2020-01-13 13:04:18
问题 I have a table that I added a column called phone - the table also has an id set as a primary key that auto_increments. How can I insert a random value into the phone column, that won't be duplicated. The following UPDATE statement did insert random values, but not all of them unique. Also, I'm not sold I cast the phone field correctly either, but ran into issues when trying to set it as a int(11) w/ the ALTER TABLE command (mainly, it ran correctly, but when adding a row with a new phone

MySQL Alter table, add column with unique random value

ε祈祈猫儿з 提交于 2020-01-13 13:03:23
问题 I have a table that I added a column called phone - the table also has an id set as a primary key that auto_increments. How can I insert a random value into the phone column, that won't be duplicated. The following UPDATE statement did insert random values, but not all of them unique. Also, I'm not sold I cast the phone field correctly either, but ran into issues when trying to set it as a int(11) w/ the ALTER TABLE command (mainly, it ran correctly, but when adding a row with a new phone

how to add column in a sqlite table in SWIFT

删除回忆录丶 提交于 2020-01-13 10:27:08
问题 I try to add a column in a table with swift. my code : connect_db(); adddbfield("mynewfield","mytable"); . func connect_db() -> Bool { let sDBPath=<is correctly set>; if sqlite3_open(sDBPath, &db) != SQLITE_OK { println("Failed to open db") return false; }else{ return true; } } . func adddbfield(sFieldName:String, sTable:String) -> Bool { var bReturn:Bool=false; var sSQL="ALTER TABLE " + sTable + " ADD COLUMN " + sFieldName + " INTEGER DEFAULT -1"; var statement:COpaquePointer = nil if

Trigger Does not works - Alter table to add a new column before inserting in it

≡放荡痞女 提交于 2020-01-07 02:26:48
问题 I am making a trigger to alter a table that adds a new column to it and inserts the value in it. My code looks lyk dis: delimiter | CREATE TRIGGER addfield AFTER INSERT ON `entity_group_mapping` FOR EACH ROW BEGIN ALTER TABLE user_access ADD NEW.type_name INT(2) NOT NULL; END; | delimiter ; It is giving me an error: #1103 - Incorrect table name 'NEW' 回答1: From the documentation: There is a hard limit of 4096 columns per table...Every table (regardless of storage engine) has a maximum row size

Add a column to a table with check constraint SQL

白昼怎懂夜的黑 提交于 2020-01-06 03:16:06
问题 I want to add a column to a table, then add a check constraint to make sure its greater than 0. I cant seem to get this to run in oracle sl developer. Alter TABLE store101 add column Base_salary Number(7,2) constraint store101_Base_salary_ck check (Base_salary > 0); Error report - SQL Error: ORA-00904: : invalid identifier 00904. 00000 - "%s: invalid identifier" 回答1: There is no ADD COLUMN clause in ALTER TABLE syntax. It's just ADD . ALTER TABLE store101 ADD Base_salary NUMBER(7, 2) -- there

plsql get table in 'before alter' trigger

巧了我就是萌 提交于 2020-01-05 05:37:31
问题 I have a table ident, and I also have a table ident_hist, which just keeps a log from the table ident. The table ident gets altered a lot, so I want to add the new columns to ident_hist dynamically as well. I have created a procedure which does that: create or replace procedure prc_create_hist_tabel(p_naam_hist_tabel in varchar2, p_naam_tabel in varchar2) is cursor c is select 'alter table ' || p_naam_hist_tabel || ' add ' || column_name || ' ' || data_type || case when data_type = 'DATE'

Need to add constraint: date plus 10 days

做~自己de王妃 提交于 2020-01-04 03:24:08
问题 I'm trying to add a constraint to a table so that it displays one of the columns as the current date plus 10 days. Here's what I've tried so far (I'm very new to SQL): ALTER TABLE orders ADD CONSTRAINT default_date DEFAULT DATEADD (DAY,10,required_date) FOR required_date Halp! Edit: I've also tried this now: ALTER TABLE orders ALTER COLUMN required_date ADD CONSTRAINT required_date_plus_ten DEFAULT DATEADD (DAY,10,required_date) Edit: Thanks to ypercube & my classmate. The final code is: