In Oracle, I have a table with a column of data type NUMBER. I need to insert a string into a new row I’m about to create. The other rows can certainly remain NUMBERs because usually that’s what I need to insert in them. So is there a way to insert a new row with a string sort of like this(this wouldn’t work for me)?
INSERT INTO keyboard_learning (emplid,wpm,date_completed,exercise,attempt)
VALUES (seq_keyboard_learning.nextval,to_char('LEVEL 3'),'14-JUN-2012','Meteor typing blast',1)
I want to create a new row where usually I would put a number like for example ‘ 23 ‘ in a new row of the WPM column. This time I want to put ‘LEVEL 3’instead just the number 23
Assuming that
WPMis theNUMBERcolumn that we’re talking about, no, there is no way to insert a string like"LEVEL 3"into that column without changing the definition of the column. You could convert the column to aVARCHAR2but that would cause numerous headaches down the line when you want to treatWPMlike a number (i.e. have them sort numerically rather than alphabetically, compute percentage improvements, etc.).Why do you want to store a string in a
WPMcolumn in the first place? It seems likely that the problem is that you need a new column or, perhaps, a new entity in your data model.