Home > database >  New oracle SQL for help
New oracle SQL for help

Time:09-26

I am learning new Oracle SQL, consult everybody a great god, and I'd like to add three fields, based on existing table "whether the real-name", "phone state", and "in the network time,
Specific requirements:
Whether the real-name: such as a real-name, show "is"; No, no;" If there are no queries to the results, it is empty, "
Mobile phone status: need to display "is not enabled", "normal", "down", "not", "" or" unable to query, "
In the network time: need to display "under 1 months", "two months", "3-6 months", "7-12 months", "13-24 months", "25 to 36 months", "more than 37 months", "mobile phone is not in the network" or "the phone number does not exist,"
Consult everybody a great god, and the specific code should be how to write, thank you!

CodePudding user response:

Increase the fields in this syntax

The alter table t add column real-name varchar (20)

To display the "yes" and "no", these data come from?

CodePudding user response:

Whether there is a problem, now inside the table without ` real-name ` field, if you want to add this field, on the condition that if real-name, display is, if it is not done real-name, reality, if there is no query to the results, show that is empty, if just add such a field, not to judge, that should be how to write

CodePudding user response:

Do you can't specifically how to write, look from your meaning, is to have a specific data, where the data come from

CodePudding user response:

Should be to play tag, such as the case when b.s erv_number is not null then 'Y' else 'N' end is_online

CodePudding user response:

Add fields syntax: alter table tablename add (column datatype [default value] [null/not null],... .);
You add fields, under the table structure column, SQL statements can be prepared corresponding logic,

CodePudding user response:

Give you a reference building table:
- Create table
The create table T_SP_SQL_RESULT
(
Project_id VARCHAR2 (40),
Select_id VARCHAR2 (40),
Data_from VARCHAR2 (40),
Instance_name VARCHAR2 (100),
Text_st LONG,
If_correct VARCHAR2 (40),
Etl_sige VARCHAR2 (40),
Daylog DATE,
Branchid VARCHAR2 (40),
Starttime0 DATE,
Starttime1 VARCHAR2 (40),
Starttime2 VARCHAR2 (40),
Starttime3 VARCHAR2 (40),
Starttime4 DATE,
Starttime5 DATE,
Endtime DATE,
The total NUMBER,
Data_no_num NUMBER,
Fail_record_num NUMBER,
Fail_data_no_num NUMBER,
Update_data_no_num NUMBER,
Db_table_name VARCHAR2 (200),
Id NUMBER,
Type_fage NUMBER
)
In tablespace TBS_URS_SERVICE
Pctfree 10
Initrans 1
Maxtrans 255
Storage
(
Initial 64 k
Next 1 m
Minextents 1
The maxextents unlimited
);
- Add comments to the columns
Comment on the column T_SP_SQL_RESULT. Project_id
Is' item number ';
Comment on the column T_SP_SQL_RESULT. Select_id
Is the 'instructions';
Comment on the column T_SP_SQL_RESULT. Data_from
Is' data source v8, universal, short risk;
Comment on the column T_SP_SQL_RESULT. Instance_name
Is' instance;
Comment on the column T_SP_SQL_RESULT. Text_st
Is' SQL text;
Comment on the column T_SP_SQL_RESULT. If_correct
Is' is correct;
Comment on the column T_SP_SQL_RESULT. Etl_sige
Is' state of etl, 0 initial stay, 1 in the operation of the MSSQL, 2 MSSQL synchronization run out, 3 MSQLL push, 4 oracle processing, 6, 9 'failure.
Comment on the column T_SP_SQL_RESULT. Daylog
Is' number update time project instructions;
Comment on the column T_SP_SQL_RESULT. Branchid
Is' institutions';
Comment on the column T_SP_SQL_RESULT. Starttime0
Initial stay time is' 0 ';
Comment on the column T_SP_SQL_RESULT. Starttime1
Is' 1 time in the operation of the MSSQL, MSSQL software updates';
Comment on the column T_SP_SQL_RESULT. Starttime2
Is' 2 MSSQL synchronization run out of time, MSSQL software updates';
Comment on the column T_SP_SQL_RESULT. Starttime3
Is' 3 MSQLL push completion time, MSSQL software updates';
Comment on the column T_SP_SQL_RESULT. Starttime4
Is' 4 oracle treatment start time;
Comment on the column T_SP_SQL_RESULT. Endtime
Is' end time;
Comment on the column T_SP_SQL_RESULT. Total
Is' number project instructions;
Comment on the column T_SP_SQL_RESULT. Data_no_num
Number is' project instructions, according to the policy number to heavy summary ';
Comment on the column T_SP_SQL_RESULT. Fail_record_num
Is' failure to the total number of records;
Comment on the column T_SP_SQL_RESULT. Fail_data_no_num
The policy record number 'is' failure;
Comment on the column T_SP_SQL_RESULT. Update_data_no_num
Is' update quantity;
Comment on the column T_SP_SQL_RESULT. Db_table_name
Is' intermediate table (orace and MSSQL);
Comment on the column T_SP_SQL_RESULT. Id
Is the 'number';
Comment on the column T_SP_SQL_RESULT. Type_fage
Is' type, 0 for the field, 1 means';
  • Related